COPASI API  4.16.103
CMathExpression.h
Go to the documentation of this file.
1 // Copyright (C) 2011 - 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 #ifndef COPASI_CMathExpression
7 #define COPASI_CMathExpression
8 
9 #include <stack>
10 #include <vector>
11 
14 
15 class CExpression;
16 class CEvaluationNode;
17 class CMathContainer;
18 template < typename Type > class CCallParameters;
19 
21 {
22 private:
23  /**
24  * Hidden default constructor
25  */
27 
28 public:
29  /**
30  * Specific constructor.
31  * @param const std::string & name
32  * @param CMathContainer & container
33  */
34  CMathExpression(const std::string & name,
35  CMathContainer & container);
36 
37  /**
38  * Specific constructor. The src expression must have been successfully compiled
39  * in the context of the current model
40  * @param const CExpression & src
41  * @param CMathContainer & container
42  * @param const bool & replaceDiscontinuousNodes
43  */
44  CMathExpression(const CExpression & src,
45  CMathContainer & container,
46  const bool & replaceDiscontinuousNodes);
47 
48  /**
49  * Specific constructor. The src function must have been successfully compiled
50  * in the context of the current model
51  * @param const CFunction & src
52  * @param const CCallParameters< C_FLOAT64 > & callParameters
53  * @param CMathContainer & container
54  * @param const bool & replaceDiscontinuousNodes
55  */
56  CMathExpression(const CFunction & src,
57  const CCallParameters< C_FLOAT64 > & callParameters,
58  CMathContainer & container,
59  const bool & replaceDiscontinuousNodes);
60 
61  /**
62  * Destructor
63  */
64  virtual ~CMathExpression();
65 
66  /**
67  * Copy an expression with the given offsets
68  * @param const CMathExpression & src
69  * @param CMathContainer & container
70  * @param const size_t & valueOffset
71  * @param const size_t & objectOffset
72  */
73  static CMathExpression * copy(const CMathExpression & src,
74  CMathContainer & container,
75  const size_t & valueOffset,
76  const size_t & objectOffset);
77 
78  /**
79  * Evaluate the expression
80  * @return const C_FLOAT64 & value
81  */
82  const C_FLOAT64 & value();
83 
84  /**
85  * Retrieve the prerequisites, i.e., the objects which need to be evaluated
86  * before this.
87  * @return const CObjectInterface::ObjectSet & prerequisites
88  */
89  virtual const CObjectInterface::ObjectSet & getPrerequisites() const;
90 
91  /**
92  * Compile the evaluation tree.
93  */
94  virtual bool compile();
95 
96  /**
97  * Convert to a corresponding initial expression.
98  * @return bool success
99  */
101 
102 private:
103  /**
104  * Sets the root node of the tree.
105  * Note: This is private to assure that only valid root node representing
106  * mathematical expressions are set.
107  * @param CEvaluationNode* root node of the tree
108  * @return bool success
109  */
110  virtual bool setRoot(CEvaluationNode* pRootNode);
111 
112  /**
113  * Create a node based on the given pointer to a data value
114  * @param const C_FLOAT64 * pDataValue
115  * @return CEvaluationNode * pNode
116  */
117  CEvaluationNode * createNodeFromValue(const C_FLOAT64 * pDataValue);
118 
119  /**
120  * Create a part of Mass Action kinetics
121  * @param const C_FLOAT64 * pK
122  * @param const CCallParameters< C_FLOAT64 > * pSpecies
123  * @return CEvaluationNode * massActionPart
124  */
126  const CCallParameters< C_FLOAT64 > * pSpecies);
127 
128  // Attributes
129  /**
130  * The prerequisites for calculating the expression.
131  */
133 };
134 
135 #endif // COPASI_CMathExpression
CEvaluationNode * createNodeFromValue(const C_FLOAT64 *pDataValue)
virtual const CObjectInterface::ObjectSet & getPrerequisites() const
const C_FLOAT64 & value()
bool convertToInitialExpression()
virtual bool compile()
std::set< const CObjectInterface * > ObjectSet
static CMathExpression * copy(const CMathExpression &src, CMathContainer &container, const size_t &valueOffset, const size_t &objectOffset)
#define C_FLOAT64
Definition: copasi.h:92
CObjectInterface::ObjectSet mPrerequisites
The class for handling a chemical kinetic function.
Definition: CFunction.h:29
CEvaluationNode * createMassActionPart(const C_FLOAT64 *pK, const CCallParameters< C_FLOAT64 > *pSpecies)
virtual ~CMathExpression()
virtual bool setRoot(CEvaluationNode *pRootNode)