From 488a7a8b217f3636b2887257e38e8477041b566e Mon Sep 17 00:00:00 2001 From: Renaud G Date: Mon, 20 Jan 2014 07:52:58 +0100 Subject: adding parantheses management (unworking yet) --- node/node.pri | 6 ++++-- node/parenthesesnode.cpp | 29 +++++++++++++++++++++++++++++ node/parenthesesnode.h | 17 +++++++++++++++++ 3 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 node/parenthesesnode.cpp create mode 100644 node/parenthesesnode.h (limited to 'node') diff --git a/node/node.pri b/node/node.pri index 090483e..4a7d55d 100644 --- a/node/node.pri +++ b/node/node.pri @@ -8,7 +8,8 @@ HEADERS += \ node/sortresult.h \ node/keepdiceexecnode.h \ node/countexecutenode.h \ - node/explosedicenode.h + node/explosedicenode.h \ + node/parenthesesnode.h SOURCES += \ node/dicerollernode.cpp \ @@ -20,4 +21,5 @@ SOURCES += \ node/sortresult.cpp \ node/keepdiceexecnode.cpp \ node/countexecutenode.cpp \ - node/explosedicenode.cpp + node/explosedicenode.cpp \ + node/parenthesesnode.cpp diff --git a/node/parenthesesnode.cpp b/node/parenthesesnode.cpp new file mode 100644 index 0000000..7bd5a6a --- /dev/null +++ b/node/parenthesesnode.cpp @@ -0,0 +1,29 @@ +#include "parenthesesnode.h" + +ParenthesesNode::ParenthesesNode() +{ + +} +void ParenthesesNode::setInternelNode(ExecutionNode* node) +{ + m_internalNode = node; +} +void ParenthesesNode::run(ExecutionNode* /*previous*/) +{ + if(NULL!=m_internalNode) + { + m_internalNode->run(this); + ExecutionNode* temp=m_internalNode; + while(NULL!=temp->getNextNode()) + { + temp=temp->getNextNode(); + } + m_result = m_internalNode->getResult(); + } + + + if(NULL!=m_nextNode) + { + m_nextNode->run(this); + } +} diff --git a/node/parenthesesnode.h b/node/parenthesesnode.h new file mode 100644 index 0000000..3347ba4 --- /dev/null +++ b/node/parenthesesnode.h @@ -0,0 +1,17 @@ +#ifndef PARENTHESESNODE_H +#define PARENTHESESNODE_H + +#include "executionnode.h" + +class ParenthesesNode : public ExecutionNode +{ +public: + ParenthesesNode(); + virtual void run(ExecutionNode* previous = NULL)=0; + + void setInternelNode(ExecutionNode* node); +private: + ExecutionNode* m_internalNode; +}; + +#endif // PARENTHESESNODE_H -- cgit v1.2.3-70-g09d2