File indexing completed on 2024-06-16 05:12:06
0001 /*************************************************************************** 0002 * Copyright (C) 2016 by Renaud Guezennec * 0003 * https://rolisteam.org/contact * 0004 * * 0005 * rolisteam is free software; you can redistribute it and/or modify * 0006 * it under the terms of the GNU General Public License as published by * 0007 * the Free Software Foundation; either version 2 of the License, or * 0008 * (at your option) any later version. * 0009 * * 0010 * This program is distributed in the hope that it will be useful, * 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0013 * GNU General Public License for more details. * 0014 * * 0015 * You should have received a copy of the GNU General Public License * 0016 * along with this program; if not, write to the * 0017 * Free Software Foundation, Inc., * 0018 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 0019 ***************************************************************************/ 0020 #ifndef SCALAROPERATORFNODE_H 0021 #define SCALAROPERATORFNODE_H 0022 0023 #include "charactersheet_formula/formula_global.h" 0024 #include "formulanode.h" 0025 /** 0026 * @brief the Formula namespace is gathering all classes to manage the computation formula. 0027 */ 0028 namespace Formula 0029 { 0030 /** 0031 * @brief The ScalarOperatorFNode class manages basic arithmetic operation. 0032 */ 0033 class CHARACTERSHEET_FORMULA_EXPORT ScalarOperatorFNode : public FormulaNode 0034 { 0035 public: 0036 /** 0037 * @brief The ArithmeticOperator enum 0038 */ 0039 enum ArithmeticOperator 0040 { 0041 PLUS, 0042 MINUS, 0043 DIVIDE, 0044 MULTIPLICATION 0045 }; 0046 /** 0047 * @brief ScalarOperatorFNode 0048 */ 0049 ScalarOperatorFNode(); 0050 /** 0051 * @brief ~ScalarOperatorFNode 0052 */ 0053 virtual ~ScalarOperatorFNode(); 0054 /** 0055 * @brief run 0056 * @param previous 0057 * @return 0058 */ 0059 bool run(FormulaNode* previous); 0060 /** 0061 * @brief getInternalNode 0062 * @return 0063 */ 0064 FormulaNode* getInternalNode() const; 0065 /** 0066 * @brief setInternalNode 0067 * @param internalNode 0068 */ 0069 void setInternalNode(FormulaNode* internalNode); 0070 /** 0071 * @brief getArithmeticOperator 0072 * @return 0073 */ 0074 ArithmeticOperator getArithmeticOperator() const; 0075 /** 0076 * @brief setArithmeticOperator 0077 * @param arithmeticOperator 0078 */ 0079 void setArithmeticOperator(const ArithmeticOperator& arithmeticOperator); 0080 /** 0081 * @brief getResult 0082 * @return 0083 */ 0084 virtual QVariant getResult(); 0085 /** 0086 * @brief getPriority 0087 * @return 0088 */ 0089 int getPriority(); 0090 0091 private: 0092 FormulaNode* m_internalNode; 0093 ArithmeticOperator m_arithmeticOperator; 0094 QVariant m_value; 0095 }; 0096 } // namespace Formula 0097 0098 #endif // SCALAROPERATORFNODE_H