COPASI API  4.16.103
CEvaluationNodeCall.h
Go to the documentation of this file.
1 // Copyright (C) 2010 - 2013 by Pedro Mendes, Virginia Tech Intellectual
2 // Properties, Inc., University of Heidelberg, and The University
3 // of Manchester.
4 // All rights reserved.
5 
6 // Copyright (C) 2008 - 2009 by Pedro Mendes, Virginia Tech Intellectual
7 // Properties, Inc., EML Research, gGmbH, University of Heidelberg,
8 // and The University of Manchester.
9 // All rights reserved.
10 
11 // Copyright (C) 2005 - 2007 by Pedro Mendes, Virginia Tech Intellectual
12 // Properties, Inc. and EML Research, gGmbH.
13 // All rights reserved.
14 
15 #ifndef COPASI_CEvaluationNodeCall
16 #define COPASI_CEvaluationNodeCall
17 
18 #include <limits>
19 
21 
22 class CFunction;
23 class CExpression;
25 class CCopasiDataModel;
26 
27 /**
28  * This is the class for nodes presenting operators used in an evaluation trees.
29  */
31 {
32 public:
33  /**
34  * Enumeration of possible node types.
35  */
36  enum SubType
37  {
38  INVALID = 0x00FFFFFF,
39  FUNCTION = 0x00000000,
40  EXPRESSION = 0x00000001
41  };
42 
43  // Operations
44 private:
45  /**
46  * Default constructor
47  */
49 
50 public:
51  /**
52  * Default constructor
53  * @param const SubType & subType
54  * @param const Data & data
55  */
57  const Data & data);
58 
59  /**
60  * Copy constructor
61  * @param const CEvaluationNodeCall & src
62  */
64 
65  /**
66  * Destructor
67  */
68  virtual ~CEvaluationNodeCall();
69 
70  /**
71  * Calculate the numerical result of the node. It is assumed that
72  * all child nodes are up to date.
73  */
74  virtual void calculate();
75 
76  /**
77  * Compile a node;
78  * @param const CEvaluationTree * pTree
79  * @return bool success;
80  */
81  virtual bool compile(const CEvaluationTree * pTree);
82 
83  /**
84  * Check whether node the calls any tree in the list
85  * @param std::set< std::string > & list
86  * @return bool calls
87  */
88  bool calls(std::set< std::string > & list) const;
89 
90  /**
91  * Retrieve the infix value of the node and its eventual child nodes.
92  * @return const Data & value
93  */
94  virtual std::string getInfix(const std::vector< std::string > & children) const;
95 
96  /**
97  * Retrieve the value of the node.
98  * @return const Data & value
99  */
100  virtual const Data & getData() const;
101 
102  /**
103  * Set the data of the Node.
104  * @param const Data & data
105  * @return bool success
106  */
107  virtual bool setData(const Data & data);
108 
109  /**
110  * Retrieve the display string of the node and its eventual child nodes.
111  * @return const Data & value
112  */
113  virtual std::string getDisplayString(const std::vector< std::string > & children) const;
114 
115  /**
116  * Retrieve the display string of the node and its eventual child nodes in C.
117  * @return const Data & value
118  */
119  virtual std::string getCCodeString(const std::vector< std::string > & children) const;
120 
121  /**
122  * Retrieve the display string of the node and its eventual child nodes
123  * in Berkeley Madonna format.
124  * @return const Data & value
125  */
126  virtual std::string getBerkeleyMadonnaString(const std::vector< std::string > & children) const;
127 
128  /**
129  ** Retrieve the display string of the node and its eventual child nodes
130  ** in XPPAUT format.
131  ** @return const Data & value
132  **/
133  virtual std::string getXPPString(const std::vector< std::string > & children) const;
134 
135  /**
136  * Creates a new CEvaluationNodeCall from an ASTNode and the given children
137  * @param const ASTNode* pNode
138  * @param const std::vector< CEvaluationNode * > & children
139  * @return CEvaluationNode * pCretedNode
140  */
141  static CEvaluationNode * fromAST(const ASTNode * pASTNode, const std::vector< CEvaluationNode * > & children);
142 
143  /**
144  * Create a new ASTNode corresponding to this choice node.
145  * @return ASTNode* return a pointer to the newly created node;
146  */
147  virtual ASTNode* toAST(const CCopasiDataModel* pDataModel) const;
148 
149  /**
150  * Add a child to a node.
151  * If pAfter == this the child will be inserted at the front of the list
152  * of children.
153  * @param CCopasiNode< Data > * pChild
154  * @param CCopasiNode< Data > * pAfter
155  * (default: NULL appended to the list of children)
156  * @return bool Success
157  */
158  virtual bool addChild(CCopasiNode< Data > * pChild,
159  CCopasiNode< Data > * pAfter = NULL);
160 
161  /**
162  * Remove a child from a node.
163  * @param CCopasiNode< Data > * pChild
164  * @return bool Success
165  */
166  virtual bool removeChild(CCopasiNode< Data > * pChild);
167 
168  /**
169  * Retrieve the tree which is called from this node
170  * @return const CEvaluationTree * calledTree
171  */
172  const CEvaluationTree * getCalledTree() const;
173 
174  /**
175  * Build the MathML string
176  * @param const std::vector< std::string > & children
177  * @param bool expand = true
178  * @param const std::vector< std::vector< std::string > > & variables
179  * @return std::string MMLString
180  */
181  virtual std::string getMMLString(const std::vector< std::string > & children,
182  bool expand,
183  const std::vector< std::vector< std::string > > & variables) const;
184 
185  /**
186  * returns the vector of child nodes, corresponding to the arguments of a function call
187  */
188  const std::vector<CEvaluationNode *> getListOfChildNodes() const {return mCallNodes;}
189 
190  /**
191  * Set whether the result of the node must be Boolean
192  * @param const bool & booleanRequired
193  */
194  void setBooleanRequired(const bool & booleanRequired);
195 
196  /**
197  * Check whether the result must be Boolean
198  * @return const bool & isBooleanRequired
199  */
200  const bool & isBooleanRequired() const;
201 
202  /**
203  * Check whether the result is Boolean
204  * @return bool isBoolean
205  */
206  virtual bool isBoolean() const;
207 
208 private:
209  /**
210  * Build the list of call parameters which correspond to
211  * the list of call nodes.
212  */
214  buildParameters(const std::vector<CEvaluationNode *> & vector);
215 
216  /**
217  * Clear the list of call parameters.
218  */
219  static void
221  const std::vector<CEvaluationNode *> & vector);
222 
223  /**
224  * Verifies that the parameters match the function parameters.
225  * @param const std::vector<CEvaluationNode *> & vector
226  * @param const CFunctionParameters & functionParameters
227  * @return bool verified
228  */
229  static bool
230  verifyParameters(const std::vector<CEvaluationNode *> & vector,
231  const CFunctionParameters &functionParameters);
232 
233  // Attributes
234 private:
237  std::vector<CEvaluationNode *> mCallNodes;
239  mutable bool mQuotesRequired;
241 
242  /**
243  * The registered object name to track eventual renaming.
244  */
246 };
247 
248 #endif // COPASI_CEvaluationNodeCall
static void clearParameters(CCallParameters< C_FLOAT64 > *pCallParameters, const std::vector< CEvaluationNode * > &vector)
const CEvaluationTree * getCalledTree() const
virtual bool addChild(CCopasiNode< Data > *pChild, CCopasiNode< Data > *pAfter=NULL)
virtual std::string getDisplayString(const std::vector< std::string > &children) const
static bool verifyParameters(const std::vector< CEvaluationNode * > &vector, const CFunctionParameters &functionParameters)
virtual std::string getBerkeleyMadonnaString(const std::vector< std::string > &children) const
static CEvaluationNode * fromAST(const ASTNode *pASTNode, const std::vector< CEvaluationNode * > &children)
static CCallParameters< C_FLOAT64 > * buildParameters(const std::vector< CEvaluationNode * > &vector)
virtual bool compile(const CEvaluationTree *pTree)
bool calls(std::set< std::string > &list) const
const bool & isBooleanRequired() const
virtual std::string getCCodeString(const std::vector< std::string > &children) const
const std::vector< CEvaluationNode * > getListOfChildNodes() const
virtual ASTNode * toAST(const CCopasiDataModel *pDataModel) const
virtual std::string getInfix(const std::vector< std::string > &children) const
virtual const Data & getData() const
CCallParameters< C_FLOAT64 > * mpCallParameters
void setBooleanRequired(const bool &booleanRequired)
virtual bool removeChild(CCopasiNode< Data > *pChild)
virtual bool setData(const Data &data)
static Type subType(const Type &type)
virtual std::string getMMLString(const std::vector< std::string > &children, bool expand, const std::vector< std::vector< std::string > > &variables) const
The class for handling a chemical kinetic function.
Definition: CFunction.h:29
virtual bool isBoolean() const
virtual std::string getXPPString(const std::vector< std::string > &children) const
CRegisteredObjectName mRegisteredFunctionCN
std::vector< CEvaluationNode * > mCallNodes