diff options
Diffstat (limited to 'node')
| -rw-r--r-- | node/scalaroperatornode.cpp | 36 | ||||
| -rw-r--r-- | node/scalaroperatornode.h | 10 |
2 files changed, 29 insertions, 17 deletions
diff --git a/node/scalaroperatornode.cpp b/node/scalaroperatornode.cpp index 67fda8d..22bbdac 100644 --- a/node/scalaroperatornode.cpp +++ b/node/scalaroperatornode.cpp @@ -26,13 +26,13 @@ ScalarOperatorNode::ScalarOperatorNode() - : m_internalNode(NULL),m_scalarResult(new ScalarResult()),m_operator(PLUS) + : m_internalNode(NULL),m_scalarResult(new ScalarResult()),m_arithmeticOperator(PLUS) { - m_scalarOperationList.insert('+',PLUS); + /*m_scalarOperationList.insert('+',PLUS); m_scalarOperationList.insert('-',MINUS); m_scalarOperationList.insert('x',MULTIPLICATION); m_scalarOperationList.insert('*',MULTIPLICATION); - m_scalarOperationList.insert('/',DIVIDE); + m_scalarOperationList.insert('/',DIVIDE);*/ m_result = m_scalarResult; } @@ -72,7 +72,7 @@ void ScalarOperatorNode::run(ExecutionNode* previous) m_internalNode->getResult()->setPrevious(previousResult); } - switch(m_operator) + switch(m_arithmeticOperator) { case PLUS: m_scalarResult->setValue(add(previousResult->getResult(Result::SCALAR).toReal(),internalResult->getResult(Result::SCALAR).toReal())); @@ -99,7 +99,7 @@ void ScalarOperatorNode::run(ExecutionNode* previous) } } -bool ScalarOperatorNode::setOperatorChar(QChar c) +/*bool ScalarOperatorNode::setOperatorChar(QChar c) { if(m_scalarOperationList.contains(c)) { @@ -107,7 +107,7 @@ bool ScalarOperatorNode::setOperatorChar(QChar c) return true; } return false; -} +}*/ void ScalarOperatorNode::setInternalNode(ExecutionNode* node) { @@ -134,16 +134,26 @@ qint64 ScalarOperatorNode::multiple(qint64 a,qint64 b) { return a*b; } +ScalarOperatorNode::ArithmeticOperator ScalarOperatorNode::getArithmeticOperator() const +{ + return m_arithmeticOperator; +} + +void ScalarOperatorNode::setArithmeticOperator(const ScalarOperatorNode::ArithmeticOperator &arithmeticOperator) +{ + m_arithmeticOperator = arithmeticOperator; +} + QString ScalarOperatorNode::toString(bool wl) const { QString op=""; - switch(m_operator) + switch(m_arithmeticOperator) { - case PLUS: - op="+"; - break; - case MINUS: - op="-"; + case PLUS: + op="+"; + break; + case MINUS: + op="-"; break; case MULTIPLICATION: op="*"; @@ -166,7 +176,7 @@ QString ScalarOperatorNode::toString(bool wl) const } qint64 ScalarOperatorNode::getPriority() const { - if((m_operator==PLUS)||(m_operator==MINUS)) + if((m_arithmeticOperator==PLUS)||(m_arithmeticOperator==MINUS)) { return 1; } diff --git a/node/scalaroperatornode.h b/node/scalaroperatornode.h index ca6f3ac..a8f930a 100644 --- a/node/scalaroperatornode.h +++ b/node/scalaroperatornode.h @@ -35,11 +35,11 @@ class ScalarOperatorNode : public ExecutionNode { public: - enum ScalarOperator {PLUS,MINUS,DIVIDE,MULTIPLICATION}; + enum ArithmeticOperator {PLUS,MINUS,DIVIDE,MULTIPLICATION}; ScalarOperatorNode(); virtual ~ScalarOperatorNode(); virtual void run(ExecutionNode*); - bool setOperatorChar(QChar c); + void setInternalNode(ExecutionNode* node); virtual QString toString(bool wl)const; @@ -52,6 +52,9 @@ public: */ virtual QMap<ExecutionNode::ERROR_CODE,QString> getExecutionErrorMap(); + ScalarOperatorNode::ArithmeticOperator getArithmeticOperator() const; + void setArithmeticOperator(const ScalarOperatorNode::ArithmeticOperator &arithmeticOperator); + private: static qint64 add(qint64,qint64); static qint64 substract(qint64,qint64); @@ -59,10 +62,9 @@ private: static qint64 multiple(qint64,qint64); private: - ScalarOperator m_operator; + ArithmeticOperator m_arithmeticOperator; ScalarResult* m_scalarResult; ExecutionNode* m_internalNode; - QMap<QChar,ScalarOperator> m_scalarOperationList; }; #endif // SCALAROPERATORNODE_H |