blob: f48c2547e6204fcd7ec5b3dd40456b999b417bf2 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
#include "variablenode.h"
#include "parsingtoolbox.h"
VariableNode::VariableNode() {}
void VariableNode::run(ExecutionNode* previous)
{
m_previousNode= previous;
if((nullptr != m_data) && (m_data->size() > m_index))
{
auto value= (*m_data)[m_index];
value= ParsingToolBox::getLeafNode(value);
if(nullptr != value)
{
auto result= value->getResult();
if(result)
{
auto copy= result->getCopy();
auto diceResult= dynamic_cast<DiceResult*>(result);
if(nullptr != diceResult)
{
for(auto& die : diceResult->getResultList())
{
die->setDisplayed(false);
}
}
m_result= copy;
if(nullptr != m_nextNode)
{
m_nextNode->run(this);
}
}
}
}
else
{
m_errors.insert(Dice::ERROR_CODE::NO_VARIBALE, QObject::tr("No variable at index:%1").arg(m_index + 1));
}
}
QString VariableNode::toString(bool withLabel) const
{
if(withLabel)
{
return QString("%1 [label=\"VariableNode index: %2\"]").arg(m_id).arg(m_index + 1);
}
else
{
return m_id;
}
}
qint64 VariableNode::getPriority() const
{
qint64 priority= 4;
if(nullptr != m_previousNode)
{
priority= m_previousNode->getPriority();
}
return priority;
}
ExecutionNode* VariableNode::getCopy() const
{
VariableNode* node= new VariableNode();
node->setIndex(m_index);
if(nullptr != m_data)
{
node->setData(m_data);
}
if(nullptr != m_nextNode)
{
node->setNextNode(m_nextNode->getCopy());
}
return node;
}
quint64 VariableNode::getIndex() const
{
return m_index;
}
void VariableNode::setIndex(quint64 index)
{
m_index= index;
}
std::vector<ExecutionNode*>* VariableNode::getData() const
{
return m_data;
}
void VariableNode::setData(std::vector<ExecutionNode*>* data)
{
m_data= data;
}
|