COPASI API  4.16.103
CEvaluationNodeOperator.h
Go to the documentation of this file.
1 // Begin CVS Header
2 // $Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/function/CEvaluationNodeOperator.h,v $
3 // $Revision: 1.32 $
4 // $Name: $
5 // $Author: shoops $
6 // $Date: 2012/05/16 23:11:32 $
7 // End CVS Header
8 
9 // Copyright (C) 2012 - 2010 by Pedro Mendes, Virginia Tech Intellectual
10 // Properties, Inc., University of Heidelberg, and The University
11 // of Manchester.
12 // All rights reserved.
13 
14 // Copyright (C) 2008 by Pedro Mendes, Virginia Tech Intellectual
15 // Properties, Inc., EML Research, gGmbH, University of Heidelberg,
16 // and The University of Manchester.
17 // All rights reserved.
18 
19 // Copyright (C) 2001 - 2007 by Pedro Mendes, Virginia Tech Intellectual
20 // Properties, Inc. and EML Research, gGmbH.
21 // All rights reserved.
22 
23 #ifndef COPASI_CEvaluationNodeOperator
24 #define COPASI_CEvaluationNodeOperator
25 
26 class ASTNode;
27 class CCopasiDataModel;
28 
29 /**
30  * This is the class for nodes presenting operators used in an evaluation trees.
31  */
33 {
34 public:
35  /**
36  * Enumeration of possible node types.
37  */
38  enum SubType
39  {
40  INVALID = 0x00FFFFFF,
41  POWER = 0x00000000,
42  MULTIPLY = 0x00000001,
43  DIVIDE = 0x00000002,
44  MODULUS = 0x00000003,
45  PLUS = 0x00000004,
46  MINUS = 0x00000005
47  };
48 
49  // Operations
50 private:
51  /**
52  * Default constructor
53  */
55 
56 public:
57  /**
58  * Default constructor
59  * @param const SubType & subType
60  * @param const Data & data
61  */
63  const Data & data);
64 
65  /**
66  * Copy constructor
67  * @param const CEvaluationNodeOperator & src
68  */
70 
71  /**
72  * Destructor
73  */
74  virtual ~CEvaluationNodeOperator();
75 
76  /**
77  * Calculate the numerical result of the node. It is assumed that
78  * all child nodes are up to date.
79  */
80  virtual inline void calculate()
81  {
82  switch (mType & 0x00FFFFFF)
83  {
84  case POWER:
85  mValue = pow(mpLeft->getValue(), mpRight->getValue());
86  break;
87 
88  case MULTIPLY:
90  break;
91 
92  case DIVIDE:
94  break;
95 
96  case MODULUS:
97 
98  if ((C_INT32) mpRight->getValue() == 0)
99  mValue = std::numeric_limits< C_FLOAT64 >::quiet_NaN();
100  else
102 
103  break;
104 
105  case PLUS:
107  break;
108 
109  case MINUS:
111  break;
112 
113  default:
114  break;
115  }
116  }
117 
118  /**
119  * Compile a node;
120  * @param const CEvaluationTree * pTree
121  * @return bool success;
122  */
123  virtual bool compile(const CEvaluationTree * pTree);
124 
125  /**
126  * Retrieve the infix value of the node and its eventual child nodes.
127  * @return const Data & value
128  */
129  virtual std::string getInfix(const std::vector< std::string > & children) const;
130 
131  /**
132  * Retrieve the display string of the node and its eventual child nodes.
133  * @return const Data & value
134  */
135  virtual std::string getDisplayString(const std::vector< std::string > & children) const;
136 
137  /**
138  * Retrieve the display string of the node and its eventual child nodes in C.
139  * @return const Data & value
140  */
141  virtual std::string getCCodeString(const std::vector< std::string > & children) const;
142 
143  /**
144  * Retrieve the display string of the node and its eventual child nodes
145  * in Berkeley Madonna format.
146  * @return const Data & value
147  */
148  virtual std::string getBerkeleyMadonnaString(const std::vector< std::string > & children) const;
149 
150  /**
151  * Retrieve the display string of the node and its eventual child nodes
152  * in XPPAUT format.
153  * @return const Data & value
154  */
155  virtual std::string getXPPString(const std::vector< std::string > & children) const;
156 
157  /**
158  * Creates a new CEvaluationNodeCall from an ASTNode and the given children
159  * @param const ASTNode* pNode
160  * @param const std::vector< CEvaluationNode * > & children
161  * @return CEvaluationNode * pCretedNode
162  */
163  static CEvaluationNode * fromAST(const ASTNode * pASTNode, const std::vector< CEvaluationNode * > & children);
164 
165  /**
166  * Create a new ASTNode corresponding to this OperatorNode.
167  * @return ASTNode* return a pointer to the newly created node;
168  */
169  virtual ASTNode* toAST(const CCopasiDataModel* pDataModel) const;
170 
171  /**
172  * Create a simplified node for an operatorNode with children from vector (if not exist, = NULL),
173  * and assign new children
174  * @return CEvaluationNode* return a pointer to the simplified node;
175  */
176  virtual CEvaluationNode* simplifyNode(const std::vector<CEvaluationNode*>& children) const;
177 
178  /**
179  * Convert our modulo to something SBML understands
180  * @param const CEvaluationNodeOperator* pNode the modulo
181  * operator node to be converted.
182  * @param const ASTNode* pASTNode the root node for the SBML math expression
183  * @return bool which is true on sucessfull conversion.
184  */
185  bool createModuloTree(const CEvaluationNodeOperator* pNode, ASTNode* pASTNode, const CCopasiDataModel* pDataModel) const;
186 
187  /**
188  * Build the MathML string
189  * @param const std::vector< std::string > & children
190  * @param bool expand = true
191  * @param const std::vector< std::vector< std::string > > & variables
192  * @return std::string MMLString
193  */
194  virtual std::string getMMLString(const std::vector< std::string > & children,
195  bool expand,
196  const std::vector< std::vector< std::string > > & variables) const;
197 
199  const CEvaluationNode * getLeft() const;
201  const CEvaluationNode * getRight() const;
202 
203  // Attributes
204 private:
206 
208 };
209 
210 #endif // COPASI_CEvaluationNodeOperator
virtual std::string getDisplayString(const std::vector< std::string > &children) const
virtual std::string getBerkeleyMadonnaString(const std::vector< std::string > &children) const
bool createModuloTree(const CEvaluationNodeOperator *pNode, ASTNode *pASTNode, const CCopasiDataModel *pDataModel) const
virtual std::string getMMLString(const std::vector< std::string > &children, bool expand, const std::vector< std::vector< std::string > > &variables) const
virtual bool compile(const CEvaluationTree *pTree)
const C_FLOAT64 & getValue() const
virtual ASTNode * toAST(const CCopasiDataModel *pDataModel) const
#define C_INT32
Definition: copasi.h:90
virtual std::string getXPPString(const std::vector< std::string > &children) const
virtual std::string getCCodeString(const std::vector< std::string > &children) const
virtual CEvaluationNode * simplifyNode(const std::vector< CEvaluationNode * > &children) const
static Type subType(const Type &type)
virtual std::string getInfix(const std::vector< std::string > &children) const
#define C_FLOAT64
Definition: copasi.h:92
static CEvaluationNode * fromAST(const ASTNode *pASTNode, const std::vector< CEvaluationNode * > &children)