COPASI API  4.16.103
CExpression.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 /*!
16  \file CExpression.h
17  \brief Header file of class CExpression
18  */
19 
20 #ifndef COPASI_CExpression
21 #define COPASI_CExpression
22 
25 
26 class CCopasiDataModel;
27 
29 {
30  // Operations
31 public:
32  /**
33  * Default constructor
34  * @param const std::string & name (default: "Expression")
35  * @param const CCopasiContainer * pParent (default: NULL)
36  */
37  CExpression(const std::string & name = "Expression",
38  const CCopasiContainer * pParent = NULL);
39 
40  /**
41  * Copy constructor
42  * @param "const CExpression &" src
43  * @param const CCopasiContainer * pParent (default: NULL)
44  */
45  CExpression(const CExpression & src,
46  const CCopasiContainer * pParent = NULL);
47 
48  /**
49  * Destructor
50  */
51  virtual ~CExpression();
52 
53  /**
54  * Creates the corresponding initial expression for the given expression by converting
55  * each transient value to the corresponding initial value.
56  * @param const CExpression & expression
57  * @return CExpression * pInitialExpression
58  */
59  static CExpression * createInitialExpression(const CExpression & expression, const CCopasiDataModel* pDataModel);
60 
61 private:
62  /**
63  * Initialize the contained CCopasiObjects
64  */
65  void initObjects();
66 
67 public:
68  /**
69  * Set whether this a boolean expression or not
70  * @param const bool & isBoolean
71  */
72  void setIsBoolean(const bool & booleanRequired);
73 
74  /**
75  * Set the infix description of the tree and compile it.
76  * @param const std::string & infix
77  * @return bool success
78  */
79  virtual bool setInfix(const std::string & infix);
80 
81  /**
82  * Compile the evaluation tree.
83  * @param std::vector< CCopasiContainer * > listOfContainer (Default: CCopasiContainer::EmptyList)
84  * @return bool success
85  */
86  virtual bool compile(std::vector< CCopasiContainer * > listOfContainer =
88 
89  /**
90  * Calculates the value of the function
91  * @return const C_FLOAT64 & result
92  */
93  virtual const C_FLOAT64 & calcValue();
94 
95  /**
96  * Refresh the value of the expression
97  */
98  void refresh();
99 
100  /**
101  * Write display mathml of the expression into the ostream "out"
102  * level specifies indentation
103  * fullExpand==true means function calls are expanded
104  */
105  void writeMathML(std::ostream & out, bool fullExpand, size_t l) const;
106 
107  /**
108  * Retrieve a pointer to the object defined by CN. This method may only be called
109  * during compile() since the list mpListOfContainer is only valid then.
110  * @param const CCopasiObjectName & CN
111  * @return const CObjectInterface * value
112  */
113  const CObjectInterface * getNodeObject(const CCopasiObjectName & CN) const;
114 
115 public:
116  /**
117  * Retrieve the list of container used for compile
118  * @return const std::vector< CCopasiContainer * > & listOfContainer
119  */
120  const std::vector< CCopasiContainer * > & getListOfContainer() const;
121 
122  /**
123  * This method performs an infix update if a referenced object has been renamed
124  * @return bool success
125  */
126  bool updateInfix();
127 
128  /**
129  * Retrieve the human readable display string.
130  * Note, the expression must be compiled for this return a displayable
131  * string.
132  * @return const std::string & displayString
133  */
134  const std::string & getDisplayString() const;
135 
136  /**
137  * Retrieve the display string in C syntax.
138  */
139  std::string getCCodeString() const;
140 
141  /**
142  * Retrieve the display string in Berkeley Madonna syntax.
143  */
144  std::string getBerkeleyMadonnaString() const;
145 
146  /**
147  * Retrieve the display string in XPPAUT syntax.
148  */
149  std::string getXPPString() const;
150 
151  // Attribute
152 protected:
153  /**
154  * Pointer to the list of containers used for compilation.
155  */
156  const std::vector< CCopasiContainer * > * mpListOfContainer;
157 
158  /**
159  * Human readable display string.
160  */
161  std::string mDisplayString;
162 
163  /**
164  * Indicates whether the expression is boolean or not.
165  */
167 };
168 
169 #endif // COPASI_CExpression
virtual ~CExpression()
Definition: CExpression.cpp:47
virtual bool setInfix(const std::string &infix)
Definition: CExpression.cpp:63
void initObjects()
Definition: CExpression.cpp:49
const CObjectInterface * getNodeObject(const CCopasiObjectName &CN) const
const std::string & getDisplayString() const
bool updateInfix()
void setIsBoolean(const bool &booleanRequired)
Definition: CExpression.cpp:58
std::string mDisplayString
Definition: CExpression.h:161
static CExpression * createInitialExpression(const CExpression &expression, const CCopasiDataModel *pDataModel)
std::string getBerkeleyMadonnaString() const
const std::vector< CCopasiContainer * > & getListOfContainer() const
static const std::vector< CCopasiContainer * > EmptyList
virtual const C_FLOAT64 & calcValue()
CExpression(const std::string &name="Expression", const CCopasiContainer *pParent=NULL)
Definition: CExpression.cpp:26
std::string getCCodeString() const
Header file of class CCopasiContainer.
bool mIsBoolean
Definition: CExpression.h:166
std::string getXPPString() const
#define C_FLOAT64
Definition: copasi.h:92
const std::vector< CCopasiContainer * > * mpListOfContainer
Definition: CExpression.h:156
virtual bool compile()
void writeMathML(std::ostream &out, bool fullExpand, size_t l) const
void refresh()