aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/node/filternode.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'node/filternode.cpp')
-rw-r--r--node/filternode.cpp70
1 files changed, 70 insertions, 0 deletions
diff --git a/node/filternode.cpp b/node/filternode.cpp
index 433f3c7..8fe99c3 100644
--- a/node/filternode.cpp
+++ b/node/filternode.cpp
@@ -1,6 +1,76 @@
#include "filternode.h"
FilterNode::FilterNode()
+ : m_diceResult(new DiceResult()),m_eachValue(false)
{
+ m_result = m_diceResult;
+}
+
+FilterNode::~FilterNode()
+{
+ if(NULL!=m_validator)
+ {
+ delete m_validator;
+ }
+}
+void FilterNode::setValidator(Validator* validator)
+{
+ m_validator = validator;
+}
+void FilterNode::run(ExecutionNode* previous)
+{
+ m_previousNode = previous;
+ if(NULL==previous)
+ {
+ return;
+ }
+ DiceResult* previousDiceResult = static_cast<DiceResult*>(previous->getResult());
+ m_result->setPrevious(previousDiceResult);
+ if(NULL!=previousDiceResult)
+ {
+ QList<Die*> diceList=previousDiceResult->getResultList();
+ QList<Die*> diceList2;
+
+
+ for(Die* tmp : diceList)
+ {
+ if(m_validator->hasValid(tmp,m_eachValue))
+ {
+ diceList2.append(tmp);
+ }
+ else
+ {
+ tmp->setHighlighted(false);
+ }
+ }
+
+ m_diceResult->setResultList(diceList2);
+ if(NULL!=m_nextNode)
+ {
+ m_nextNode->run(this);
+ }
+ }
+}
+
+QString FilterNode::toString(bool wl) const
+{
+ if(wl)
+ {
+ return QString("%1 [label=\"FilterNode\"]").arg(m_id);
+ }
+ else
+ {
+ return m_id;
+ }
+}
+qint64 FilterNode::getPriority() const
+{
+ qint64 priority=0;
+ if(NULL!=m_nextNode)
+ {
+ priority = m_nextNode->getPriority();
+ }
+
+ return priority;
}