aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/node
diff options
context:
space:
mode:
authorRenaud G <renaud@rolisteam.org>2015-03-03 22:57:16 +0100
committerRenaud G <renaud@rolisteam.org>2015-03-03 22:57:16 +0100
commit9f57feb3052ef74c9ee6aa08b39f04ee61f6839c (patch)
tree7628e1e7138d8314f1d87dc939a991dd5cf039ad /node
parentd51884f5c6ea38f3bf06b3a0ef185056fa0a7558 (diff)
downloadOneRoll-9f57feb3052ef74c9ee6aa08b39f04ee61f6839c.tar.gz
OneRoll-9f57feb3052ef74c9ee6aa08b39f04ee61f6839c.zip
-store pointeur to previous node.
Diffstat (limited to 'node')
-rw-r--r--node/countexecutenode.cpp2
-rw-r--r--node/dicerollernode.cpp1
-rw-r--r--node/executionnode.cpp4
-rw-r--r--node/executionnode.h11
-rw-r--r--node/explosedicenode.cpp1
-rw-r--r--node/helpnode.cpp1
-rw-r--r--node/keepdiceexecnode.cpp2
-rw-r--r--node/node.pri6
-rw-r--r--node/numbernode.cpp1
-rw-r--r--node/parenthesesnode.cpp2
-rw-r--r--node/rerolldicenode.cpp2
-rw-r--r--node/scalaroperatornode.cpp1
-rw-r--r--node/sortresult.cpp2
-rw-r--r--node/startingnode.cpp2
14 files changed, 29 insertions, 9 deletions
diff --git a/node/countexecutenode.cpp b/node/countexecutenode.cpp
index ce0249f..a663544 100644
--- a/node/countexecutenode.cpp
+++ b/node/countexecutenode.cpp
@@ -15,7 +15,7 @@ void CountExecuteNode::setValidator(Validator* validator)
void CountExecuteNode::run(ExecutionNode *previous)
{
-// qDebug() << "CountExecuteNode node";
+ m_previousNode = previous;
if(NULL==previous)
{
return;
diff --git a/node/dicerollernode.cpp b/node/dicerollernode.cpp
index 6a203b9..8eecf0d 100644
--- a/node/dicerollernode.cpp
+++ b/node/dicerollernode.cpp
@@ -41,6 +41,7 @@ DiceRollerNode::DiceRollerNode(quint64 faces)
}
void DiceRollerNode::run(ExecutionNode* previous)
{
+ m_previousNode = previous;
if(NULL!=previous)
{
Result* result=previous->getResult();
diff --git a/node/executionnode.cpp b/node/executionnode.cpp
index cec9036..e1b71b0 100644
--- a/node/executionnode.cpp
+++ b/node/executionnode.cpp
@@ -30,3 +30,7 @@ QString ExecutionNode::getHelp()
{
return QString();
}
+ExecutionNode* ExecutionNode::getPreviousNode() const
+{
+ return m_previousNode;
+}
diff --git a/node/executionnode.h b/node/executionnode.h
index ef5fce8..e10ccb6 100644
--- a/node/executionnode.h
+++ b/node/executionnode.h
@@ -27,7 +27,7 @@ public:
* @brief getResult
* @return
*/
- Result* getResult();
+ virtual Result* getResult();
/**
* @brief setNextNode
*/
@@ -37,6 +37,11 @@ public:
* @return
*/
ExecutionNode* getNextNode();
+ /**
+ * @brief getPreviousNode
+ * @return
+ */
+ virtual ExecutionNode* getPreviousNode() const;
/**
* @brief toString
* @return
@@ -59,6 +64,10 @@ public:
*/
virtual QString getHelp();
protected:
+ /**
+ * @brief m_nextNode
+ */
+ ExecutionNode* m_previousNode;
/**
* @brief m_result
*/
diff --git a/node/explosedicenode.cpp b/node/explosedicenode.cpp
index 9228190..42b3c2d 100644
--- a/node/explosedicenode.cpp
+++ b/node/explosedicenode.cpp
@@ -7,6 +7,7 @@ ExploseDiceNode::ExploseDiceNode()
}
void ExploseDiceNode::run(ExecutionNode* previous)
{
+ m_previousNode = previous;
if((NULL!=previous)&&(NULL!=previous->getResult()))
{
DiceResult* previous_result = static_cast<DiceResult*>(previous->getResult());
diff --git a/node/helpnode.cpp b/node/helpnode.cpp
index a46d29a..9a0504e 100644
--- a/node/helpnode.cpp
+++ b/node/helpnode.cpp
@@ -6,6 +6,7 @@ HelpNode::HelpNode()
}
void HelpNode::run(ExecutionNode* previous)
{
+ m_previousNode = previous;
StringResult* txtResult = dynamic_cast<StringResult*>(m_result);
qDebug() << m_result->hasResultOfType(Result::SCALAR) << m_result->hasResultOfType(Result::STRING);
diff --git a/node/keepdiceexecnode.cpp b/node/keepdiceexecnode.cpp
index c219e77..62b4c8f 100644
--- a/node/keepdiceexecnode.cpp
+++ b/node/keepdiceexecnode.cpp
@@ -12,7 +12,7 @@ KeepDiceExecNode::KeepDiceExecNode()
void KeepDiceExecNode::run(ExecutionNode* previous)
{
-// qDebug() << "KeepDiceExecNode node";
+m_previousNode = previous;
if(NULL==previous)
{
return;
diff --git a/node/node.pri b/node/node.pri
index fadbd22..d65d3e7 100644
--- a/node/node.pri
+++ b/node/node.pri
@@ -10,7 +10,8 @@ HEADERS += \
node/countexecutenode.h \
node/explosedicenode.h \
node/parenthesesnode.h \
- node/helpnode.h
+ node/helpnode.h \
+ $$PWD/jumpbackwardnode.h
SOURCES += \
node/dicerollernode.cpp \
@@ -24,4 +25,5 @@ SOURCES += \
node/countexecutenode.cpp \
node/explosedicenode.cpp \
node/parenthesesnode.cpp \
- node/helpnode.cpp
+ node/helpnode.cpp \
+ $$PWD/jumpbackwardnode.cpp
diff --git a/node/numbernode.cpp b/node/numbernode.cpp
index e30426e..4e9d9a3 100644
--- a/node/numbernode.cpp
+++ b/node/numbernode.cpp
@@ -7,6 +7,7 @@ NumberNode::NumberNode()
}
void NumberNode::run(ExecutionNode* previous)
{
+ m_previousNode = previous;
if(NULL!=previous)
{
m_result->setPrevious(previous->getResult());
diff --git a/node/parenthesesnode.cpp b/node/parenthesesnode.cpp
index 0f7002a..f76d33c 100644
--- a/node/parenthesesnode.cpp
+++ b/node/parenthesesnode.cpp
@@ -10,7 +10,7 @@ void ParenthesesNode::setInternelNode(ExecutionNode* node)
}
void ParenthesesNode::run(ExecutionNode* /*previous*/)
{
-// qDebug() << "ParenthesesNode node";
+ m_previousNode = NULL;
if(NULL!=m_internalNode)
{
m_internalNode->run(this);
diff --git a/node/rerolldicenode.cpp b/node/rerolldicenode.cpp
index 397d791..56bef61 100644
--- a/node/rerolldicenode.cpp
+++ b/node/rerolldicenode.cpp
@@ -8,7 +8,7 @@ RerollDiceNode::RerollDiceNode()
}
void RerollDiceNode::run(ExecutionNode* previous)
{
-// qDebug() << "RerollDiceNode node";
+m_previousNode = previous;
if((NULL!=previous)&&(NULL!=previous->getResult()))
{
DiceResult* previous_result = static_cast<DiceResult*>(previous->getResult());
diff --git a/node/scalaroperatornode.cpp b/node/scalaroperatornode.cpp
index fb7a110..6cef1a9 100644
--- a/node/scalaroperatornode.cpp
+++ b/node/scalaroperatornode.cpp
@@ -18,6 +18,7 @@ ScalarOperatorNode::ScalarOperatorNode()
void ScalarOperatorNode::run(ExecutionNode* previous)
{
+ m_previousNode = previous;
if(NULL!=m_internalNode)
{
m_internalNode->run(this);
diff --git a/node/sortresult.cpp b/node/sortresult.cpp
index c80ebec..5d7f142 100644
--- a/node/sortresult.cpp
+++ b/node/sortresult.cpp
@@ -12,7 +12,7 @@ SortResultNode::SortResultNode()
}
void SortResultNode::run(ExecutionNode* node)
{
-// qDebug() << "SortResultNode node";
+ m_previousNode = node;
if(NULL==node)
{
return;
diff --git a/node/startingnode.cpp b/node/startingnode.cpp
index 9395e53..7ce1e38 100644
--- a/node/startingnode.cpp
+++ b/node/startingnode.cpp
@@ -7,7 +7,7 @@ StartingNode::StartingNode()
}
void StartingNode::run(ExecutionNode*)
{
-// qDebug() << "starting node";
+ m_previousNode = NULL;
if(NULL!=m_nextNode)
{
m_nextNode->run(this);