From ae81e675a117819aa5a2eb7f9be687aff5a6bb9f Mon Sep 17 00:00:00 2001 From: Renaud G Date: Thu, 20 Aug 2015 11:56:10 +0200 Subject: add bool parameter to toString() function in node. --- node/dicerollernode.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'node/dicerollernode.cpp') diff --git a/node/dicerollernode.cpp b/node/dicerollernode.cpp index 06148fc..213c8ec 100644 --- a/node/dicerollernode.cpp +++ b/node/dicerollernode.cpp @@ -71,9 +71,16 @@ quint64 DiceRollerNode::getFaces() { return m_faces; } -QString DiceRollerNode::toString() const +QString DiceRollerNode::toString(bool wl) const { - return QString("DiceRollerNode"); + if(wl) + { + return QString("%1 [label=DiceRollerNode]").arg(m_id); + } + else + { + return m_id; + } } qint64 DiceRollerNode::getPriority() const { -- cgit v1.2.3-70-g09d2 From 4c96c3f33cbb0552275e4a87046ac0a8fa88162c Mon Sep 17 00:00:00 2001 From: Renaud G Date: Thu, 20 Aug 2015 15:25:26 +0200 Subject: fix little issues --- node/dicerollernode.cpp | 7 ++----- node/keepdiceexecnode.cpp | 2 +- node/startingnode.cpp | 2 +- 3 files changed, 4 insertions(+), 7 deletions(-) (limited to 'node/dicerollernode.cpp') diff --git a/node/dicerollernode.cpp b/node/dicerollernode.cpp index 213c8ec..fa73185 100644 --- a/node/dicerollernode.cpp +++ b/node/dicerollernode.cpp @@ -61,10 +61,7 @@ void DiceRollerNode::run(ExecutionNode* previous) m_nextNode->run(this); } } - } - - - + } } quint64 DiceRollerNode::getFaces() @@ -75,7 +72,7 @@ QString DiceRollerNode::toString(bool wl) const { if(wl) { - return QString("%1 [label=DiceRollerNode]").arg(m_id); + return QString("%1 [label=DiceRollerNode faces: %2]").arg(m_id).arg(m_faces); } else { diff --git a/node/keepdiceexecnode.cpp b/node/keepdiceexecnode.cpp index 492e69c..7407d30 100644 --- a/node/keepdiceexecnode.cpp +++ b/node/keepdiceexecnode.cpp @@ -66,7 +66,7 @@ QString KeepDiceExecNode::toString(bool wl) const { if(wl) { - return QString("%1 [label=\"KeepDiceExecNode %1\"]").arg(m_id).arg(m_numberOfDice); + return QString("%1 [label=\"KeepDiceExecNode %2\"]").arg(m_id).arg(m_numberOfDice); } else { diff --git a/node/startingnode.cpp b/node/startingnode.cpp index b57c630..42fba6f 100644 --- a/node/startingnode.cpp +++ b/node/startingnode.cpp @@ -17,7 +17,7 @@ QString StartingNode::toString(bool withlabel) const { if(withlabel) { - return QString("%1 [label=\"StartingNode %2\"]").arg(m_id); + return QString("%1 [label=\"StartingNode\"]").arg(m_id); } else { -- cgit v1.2.3-70-g09d2 From 4a7faef6ead8e92839f7d615bc510218cc8dd63f Mon Sep 17 00:00:00 2001 From: Renaud G Date: Thu, 20 Aug 2015 16:11:34 +0200 Subject: add comments --- node/dicerollernode.cpp | 25 +------------------------ node/dicerollernode.h | 36 ++++++++++++++++++++++-------------- 2 files changed, 23 insertions(+), 38 deletions(-) (limited to 'node/dicerollernode.cpp') diff --git a/node/dicerollernode.cpp b/node/dicerollernode.cpp index fa73185..73a7218 100644 --- a/node/dicerollernode.cpp +++ b/node/dicerollernode.cpp @@ -8,30 +8,7 @@ #include -//DiceRoller::DiceRoller(QMutex* mutex,DiceResult* diceResult,int faces,int count) -// : m_mutex(mutex),m_sharedDiceResult(diceResult),m_faces(faces),m_diceCount(count) -//{ -//} - -//void DiceRoller::run() -//{ -// for(quint64 i=0; i < m_diceCount ; ++i) -// { -// Die* die = new Die(); -// die->setFaces(m_faces); -// die->roll(); -// m_mutex->lock(); -// m_sharedDiceResult->insertResult(die); -// m_mutex->unlock(); -// } -//} - - - -////////////////////////////////////////////////// -/// \brief DiceRollerNode::DiceRollerNode -////////////////////////////////////////////////// DiceRollerNode::DiceRollerNode(quint64 faces,qint64 offset) : m_faces(faces),m_diceResult(new DiceResult()),m_offset(offset) { @@ -72,7 +49,7 @@ QString DiceRollerNode::toString(bool wl) const { if(wl) { - return QString("%1 [label=DiceRollerNode faces: %2]").arg(m_id).arg(m_faces); + return QString("%1 [label=\"DiceRollerNode faces: %2\"]").arg(m_id).arg(m_faces); } else { diff --git a/node/dicerollernode.h b/node/dicerollernode.h index 402ef40..808676f 100644 --- a/node/dicerollernode.h +++ b/node/dicerollernode.h @@ -2,35 +2,43 @@ #define DICEROLLERNODE_H #include -#include -#include #include "executionnode.h" #include "result/diceresult.h" -//class DiceRoller : public QRunnable -//{ -//public: -// DiceRoller(QMutex* mutex,DiceResult* diceResult,int faces,int count); -// virtual void run (); -//private: -// QMutex* m_mutex; -// DiceResult* m_sharedDiceResult; -// int m_faces; -// quint64 m_diceCount; -//}; /** - * @brief The DiceRollerNode class + * @brief The DiceRollerNode class rolls dice of one kind. */ class DiceRollerNode : public ExecutionNode { public: + /** + * @brief DiceRollerNode builds an instance + * @param faces, number of faces of dices + * @param offset, first value of dice. + */ DiceRollerNode(quint64 faces, qint64 offset = 1); + /** + * @brief run - starts to roll dice. + */ virtual void run(ExecutionNode*); + /** + * @brief getFaces accessor + * @return the face count + */ quint64 getFaces(); + /** + * @brief toString + * @param wl + * @return use to generate dot tree; + */ virtual QString toString(bool wl)const; + /** + * @brief getPriority + * @return priority for dice roll: 4 (higher) + */ virtual qint64 getPriority() const; //private members private: -- cgit v1.2.3-70-g09d2