From cb1dcb5ee28994a2cd691ad696a5ba4c3c3802ea Mon Sep 17 00:00:00 2001 From: Renaud Guezennec Date: Wed, 23 Oct 2024 15:42:08 +0200 Subject: Add execute node. --- src/libparser/node/occurencecountnode.cpp | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) (limited to 'src/libparser/node/occurencecountnode.cpp') 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 mapOccurence; - if(nullptr == m_previousNode) - return; DiceResult* previousDiceResult= dynamic_cast(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& mapOcc m_diceResult->insertResult(die); } } - - if(nullptr != m_nextNode) - { - m_nextNode->run(this); - } } -- cgit v1.2.3-70-g09d2