aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/node
diff options
context:
space:
mode:
Diffstat (limited to 'node')
-rw-r--r--node/countexecutenode.cpp11
-rw-r--r--node/countexecutenode.h1
-rw-r--r--node/dicerollernode.cpp8
-rw-r--r--node/dicerollernode.h3
-rw-r--r--node/executionnode.cpp10
-rw-r--r--node/explosedicenode.cpp9
-rw-r--r--node/explosedicenode.h1
-rw-r--r--node/jumpbackwardnode.h8
-rw-r--r--node/keepdiceexecnode.cpp5
-rw-r--r--node/listaliasnode.cpp11
-rw-r--r--node/listaliasnode.h6
-rw-r--r--node/listsetrollnode.cpp8
-rw-r--r--node/listsetrollnode.h1
-rw-r--r--node/rerolldicenode.cpp10
-rw-r--r--node/rerolldicenode.h28
-rw-r--r--node/scalaroperatornode.cpp18
-rw-r--r--node/scalaroperatornode.h3
17 files changed, 116 insertions, 25 deletions
diff --git a/node/countexecutenode.cpp b/node/countexecutenode.cpp
index 281fc80..ff3d67b 100644
--- a/node/countexecutenode.cpp
+++ b/node/countexecutenode.cpp
@@ -4,7 +4,7 @@
CountExecuteNode::CountExecuteNode()
- : m_scalarResult(new ScalarResult())
+ : m_scalarResult(new ScalarResult()),m_validator(NULL)
{
m_result = m_scalarResult;
}
@@ -12,6 +12,13 @@ void CountExecuteNode::setValidator(Validator* validator)
{
m_validator = validator;
}
+CountExecuteNode::~CountExecuteNode()
+{
+ if(NULL!=m_validator)
+ {
+ delete m_validator;
+ }
+}
void CountExecuteNode::run(ExecutionNode *previous)
{
@@ -28,7 +35,7 @@ void CountExecuteNode::run(ExecutionNode *previous)
qint64 sum = 0;
foreach(Die* dice,diceList)
{
- sum+=m_validator->hasValid(dice,true);
+ sum+=m_validator->hasValid(dice,true,true);
}
m_scalarResult->setValue(sum);
diff --git a/node/countexecutenode.h b/node/countexecutenode.h
index c7ecdfd..519403b 100644
--- a/node/countexecutenode.h
+++ b/node/countexecutenode.h
@@ -16,6 +16,7 @@ public:
* @brief CountExecuteNode
*/
CountExecuteNode();
+ virtual ~CountExecuteNode();
/**
* @brief run
* @param previous
diff --git a/node/dicerollernode.cpp b/node/dicerollernode.cpp
index 1fd1a2f..f32a033 100644
--- a/node/dicerollernode.cpp
+++ b/node/dicerollernode.cpp
@@ -33,11 +33,9 @@
/// \brief DiceRollerNode::DiceRollerNode
//////////////////////////////////////////////////
DiceRollerNode::DiceRollerNode(quint64 faces)
- : m_faces(faces),m_myDiceResult(new DiceResult())
+ : m_faces(faces),m_diceResult(new DiceResult())
{
- m_mutex=new QMutex();
- m_result=m_myDiceResult;
-
+ m_result=m_diceResult;
}
void DiceRollerNode::run(ExecutionNode* previous)
{
@@ -55,7 +53,7 @@ void DiceRollerNode::run(ExecutionNode* previous)
Die* die = new Die();
die->setFaces(m_faces);
die->roll();
- m_myDiceResult->insertResult(die);
+ m_diceResult->insertResult(die);
}
if(NULL!=m_nextNode)
{
diff --git a/node/dicerollernode.h b/node/dicerollernode.h
index d50fe95..744a4b5 100644
--- a/node/dicerollernode.h
+++ b/node/dicerollernode.h
@@ -36,8 +36,7 @@ public:
private:
quint64 m_diceCount;
quint64 m_faces; /// faces
- DiceResult* m_myDiceResult;
- QMutex* m_mutex;
+ DiceResult* m_diceResult;
};
#endif // DICEROLLERNODE_H
diff --git a/node/executionnode.cpp b/node/executionnode.cpp
index 8bcd6e4..343e8d9 100644
--- a/node/executionnode.cpp
+++ b/node/executionnode.cpp
@@ -8,6 +8,16 @@ ExecutionNode::ExecutionNode()
ExecutionNode::~ExecutionNode()
{
+ if(NULL!=m_result)
+ {
+ delete m_result;
+ m_result = NULL;
+ }
+ if(NULL!=m_nextNode)
+ {
+ delete m_nextNode;
+ m_nextNode = NULL;
+ }
}
Result* ExecutionNode::getResult()
diff --git a/node/explosedicenode.cpp b/node/explosedicenode.cpp
index 42b3c2d..4eae270 100644
--- a/node/explosedicenode.cpp
+++ b/node/explosedicenode.cpp
@@ -1,7 +1,7 @@
#include "explosedicenode.h"
ExploseDiceNode::ExploseDiceNode()
- : m_diceResult(new DiceResult())
+ : m_diceResult(new DiceResult()),m_validator(NULL)
{
m_result = m_diceResult;
}
@@ -33,6 +33,13 @@ void ExploseDiceNode::run(ExecutionNode* previous)
}
}
}
+ExploseDiceNode::~ExploseDiceNode()
+{
+ if(NULL!=m_validator)
+ {
+ delete m_validator;
+ }
+}
void ExploseDiceNode::setValidator(Validator* val)
{
m_validator = val;
diff --git a/node/explosedicenode.h b/node/explosedicenode.h
index b00af1a..f5d0f6e 100644
--- a/node/explosedicenode.h
+++ b/node/explosedicenode.h
@@ -13,6 +13,7 @@ class ExploseDiceNode : public ExecutionNode
{
public:
ExploseDiceNode();
+ virtual ~ExploseDiceNode();
virtual void run(ExecutionNode* previous = NULL);
virtual void setValidator(Validator* );
virtual QString toString()const;
diff --git a/node/jumpbackwardnode.h b/node/jumpbackwardnode.h
index 4ea3d11..c6c1e4d 100644
--- a/node/jumpbackwardnode.h
+++ b/node/jumpbackwardnode.h
@@ -6,8 +6,14 @@
class JumpBackwardNode : public ExecutionNode
{
public:
+ /**
+ * @brief JumpBackwardNode allows to get result from remote node in the execution tree.
+ */
JumpBackwardNode();
-
+ /**
+ * @brief run - performs the actions
+ * @param previous
+ */
virtual void run(ExecutionNode* previous = NULL);
/**
diff --git a/node/keepdiceexecnode.cpp b/node/keepdiceexecnode.cpp
index 62b4c8f..e8cfac8 100644
--- a/node/keepdiceexecnode.cpp
+++ b/node/keepdiceexecnode.cpp
@@ -26,6 +26,11 @@ m_previousNode = previous;
diceList2 = diceList.mid(0,m_numberOfDice);
+ foreach(Die* tmp,diceList.mid(m_numberOfDice,-1))
+ {
+ tmp->setHighlighted(false);
+ }
+
m_diceResult->setResultList(diceList2);
if(NULL!=m_nextNode)
{
diff --git a/node/listaliasnode.cpp b/node/listaliasnode.cpp
index 1d50c80..b85d4c9 100644
--- a/node/listaliasnode.cpp
+++ b/node/listaliasnode.cpp
@@ -1,7 +1,7 @@
#include "listaliasnode.h"
-ListAliasNode::ListAliasNode(QMap<QString,QString>* apAlias)
- : m_mapAlias(apAlias)
+ListAliasNode::ListAliasNode(QList<DiceAlias*>* apAlias)
+ : m_aliasList(apAlias)
{
m_result = new StringResult();
}
@@ -29,14 +29,13 @@ void ListAliasNode::run(ExecutionNode* previous )
m_nextNode->run(this);
}
}
-QString ListAliasNode::toString()const
+QString ListAliasNode::toString() const
{
QString result(QObject::tr("List of Alias:\n"));
- foreach(QString key, m_mapAlias->keys())
+ foreach(DiceAlias* key, *m_aliasList)
{
- result+=QString("%1 : %2\n").arg(key).arg(m_mapAlias->value(key));
+ result+=QString("%1 : %2\n").arg(key->getCommand()).arg(key->getValue());
}
-
return result;
}
diff --git a/node/listaliasnode.h b/node/listaliasnode.h
index d01d17a..ea70fe7 100644
--- a/node/listaliasnode.h
+++ b/node/listaliasnode.h
@@ -3,12 +3,12 @@
#include "executionnode.h"
#include "result/stringresult.h"
-
+#include "dicealias.h"
class ListAliasNode : public ExecutionNode
{
public:
- ListAliasNode(QMap<QString,QString>* mapAlias);
+ ListAliasNode(QList<DiceAlias*>* mapAlias);
/**
* @brief run
* @param previous
@@ -27,7 +27,7 @@ public:
virtual qint64 getPriority() const;
private:
- QMap<QString,QString>* m_mapAlias;
+ QList<DiceAlias*>* m_aliasList;
};
#endif // LISTALIASNODE_H
diff --git a/node/listsetrollnode.cpp b/node/listsetrollnode.cpp
index 3ab9a69..777f7b0 100644
--- a/node/listsetrollnode.cpp
+++ b/node/listsetrollnode.cpp
@@ -6,6 +6,14 @@ ListSetRollNode::ListSetRollNode()
{
m_result = m_stringResult;
}
+ListSetRollNode::~ListSetRollNode()
+{
+ if(NULL!=m_diceResult)
+ {
+ delete m_diceResult;
+ m_diceResult =NULL;
+ }
+}
QStringList ListSetRollNode::getList()
{
diff --git a/node/listsetrollnode.h b/node/listsetrollnode.h
index 26fb378..c7925b8 100644
--- a/node/listsetrollnode.h
+++ b/node/listsetrollnode.h
@@ -12,6 +12,7 @@ class ListSetRollNode : public ExecutionNode
{
public:
ListSetRollNode();
+ virtual ~ListSetRollNode();
virtual void run(ExecutionNode* previous = NULL);
virtual QString toString()const;
virtual qint64 getPriority() const;
diff --git a/node/rerolldicenode.cpp b/node/rerolldicenode.cpp
index 81b5e01..a7cc8c4 100644
--- a/node/rerolldicenode.cpp
+++ b/node/rerolldicenode.cpp
@@ -2,10 +2,18 @@
RerollDiceNode::RerollDiceNode()
- : m_myDiceResult(new DiceResult()),m_adding(false)
+ : m_myDiceResult(new DiceResult()),m_adding(false),m_validator(NULL)
{
m_result=m_myDiceResult;
}
+RerollDiceNode::~RerollDiceNode()
+{
+ if(NULL!=m_validator)
+ {
+ delete m_validator;
+ m_validator = NULL;
+ }
+}
void RerollDiceNode::run(ExecutionNode* previous)
{
m_previousNode = previous;
diff --git a/node/rerolldicenode.h b/node/rerolldicenode.h
index 4674a3e..a97e448 100644
--- a/node/rerolldicenode.h
+++ b/node/rerolldicenode.h
@@ -12,16 +12,44 @@ class RerollDiceNode : public ExecutionNode
{
public:
+ /**
+ * @brief The ReRollMode enum
+ */
enum ReRollMode {EQUAL,LESSER,GREATER};
+ /**
+ * @brief RerollDiceNode
+ */
RerollDiceNode();
+ /**
+ * @brief ~RerollDiceNode
+ */
+ virtual ~RerollDiceNode();
+ /**
+ * @brief run
+ * @param previous
+ */
virtual void run(ExecutionNode* previous);
+ /**
+ * @brief setValidator
+ */
virtual void setValidator(Validator* );
+ /**
+ * @brief toString
+ * @return
+ */
virtual QString toString()const;
+ /**
+ * @brief setAddingMode
+ */
virtual void setAddingMode(bool);
+ /**
+ * @brief getPriority
+ * @return
+ */
virtual qint64 getPriority() const;
private:
diff --git a/node/scalaroperatornode.cpp b/node/scalaroperatornode.cpp
index 95fd077..34eb6b8 100644
--- a/node/scalaroperatornode.cpp
+++ b/node/scalaroperatornode.cpp
@@ -15,6 +15,14 @@ ScalarOperatorNode::ScalarOperatorNode()
m_result = m_scalarResult;
}
+ScalarOperatorNode::~ScalarOperatorNode()
+{
+ if(NULL!=m_internalNode)
+ {
+ delete m_internalNode;
+ m_internalNode = NULL;
+ }
+}
void ScalarOperatorNode::run(ExecutionNode* previous)
{
@@ -43,7 +51,7 @@ void ScalarOperatorNode::run(ExecutionNode* previous)
m_internalNode->getResult()->setPrevious(previousResult);
}
- switch(m_myOperator)
+ switch(m_operator)
{
case PLUS:
m_scalarResult->setValue(add(previousResult->getResult(Result::SCALAR).toReal(),internalResult->getResult(Result::SCALAR).toReal()));
@@ -74,7 +82,7 @@ bool ScalarOperatorNode::setOperatorChar(QChar c)
{
if(m_scalarOperationList.contains(c))
{
- m_myOperator = m_scalarOperationList.value(c);
+ m_operator = m_scalarOperationList.value(c);
return true;
}
return false;
@@ -110,10 +118,14 @@ QString ScalarOperatorNode::toString() const
}
qint64 ScalarOperatorNode::getPriority() const
{
- if((m_myOperator==PLUS)||(m_myOperator==MINUS))
+ if((m_operator==PLUS)||(m_operator==MINUS))
+ {
return 1;
+ }
else
+ {
return 2;
+ }
}
void ScalarOperatorNode::generateDotTree(QString& s)
{
diff --git a/node/scalaroperatornode.h b/node/scalaroperatornode.h
index a67e296..7193118 100644
--- a/node/scalaroperatornode.h
+++ b/node/scalaroperatornode.h
@@ -12,6 +12,7 @@ class ScalarOperatorNode : public ExecutionNode
public:
enum ScalarOperator {PLUS,MINUS,DIVIDE,MULTIPLICATION};
ScalarOperatorNode();
+ virtual ~ScalarOperatorNode();
virtual void run(ExecutionNode*);
bool setOperatorChar(QChar c);
void setInternalNode(ExecutionNode* node);
@@ -28,7 +29,7 @@ private:
qint64 multiple(qint64,qint64);
private:
- ScalarOperator m_myOperator;
+ ScalarOperator m_operator;
ExecutionNode* m_internalNode;
QMap<QChar,ScalarOperator> m_scalarOperationList;
ScalarResult* m_scalarResult;