diff options
Diffstat (limited to 'src/libparser/node/occurencecountnode.cpp')
| -rw-r--r-- | src/libparser/node/occurencecountnode.cpp | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/src/libparser/node/occurencecountnode.cpp b/src/libparser/node/occurencecountnode.cpp index fc5c2f2..780ca08 100644 --- a/src/libparser/node/occurencecountnode.cpp +++ b/src/libparser/node/occurencecountnode.cpp @@ -27,13 +27,14 @@ OccurenceCountNode::OccurenceCountNode() : ExecutionNode() {} void OccurenceCountNode::run(ExecutionNode* previous) { + if(isValid(!previous, Dice::ERROR_CODE::NO_PREVIOUS_ERROR, tr("No Previous node"))) + return; + m_previousNode= previous; std::map<qint64, qint64> mapOccurence; - if(nullptr == m_previousNode) - return; DiceResult* previousDiceResult= dynamic_cast<DiceResult*>(m_previousNode->getResult()); - if(nullptr == previousDiceResult) + if(isValid(!previousDiceResult, Dice::ERROR_CODE::NO_VALID_RESULT, tr("No Valid result"))) return; auto const& diceList= previousDiceResult->getResultList(); @@ -52,14 +53,10 @@ void OccurenceCountNode::run(ExecutionNode* previous) } std::sort(vec.begin(), vec.end()); - if(nullptr == m_nextNode) - { + if(!m_nextNode) runForStringResult(mapOccurence, vec); - } else - { runForDiceResult(mapOccurence); - } } QString OccurenceCountNode::toString(bool label) const { @@ -177,9 +174,4 @@ void OccurenceCountNode::runForDiceResult(const std::map<qint64, qint64>& mapOcc m_diceResult->insertResult(die); } } - - if(nullptr != m_nextNode) - { - m_nextNode->run(this); - } } |