COPASI API  4.16.103
Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | List of all members
CEvaluationNodeConstant Class Reference

#include <CEvaluationNodeConstant.h>

Inheritance diagram for CEvaluationNodeConstant:
Inheritance graph
[legend]
Collaboration diagram for CEvaluationNodeConstant:
Collaboration graph
[legend]

Public Types

enum  SubType {
  INVALID = 0x00FFFFFF, PI = 0x00000000, EXPONENTIALE = 0x00000001, TRUE = 0x00000002,
  FALSE = 0x00000003, _INFINITY = 0x00000004, _NaN = 0x00000005
}
 
- Public Types inherited from CEvaluationNode
enum  Type {
  INVALID = 0xFF000000, NUMBER = 0x01000000, CONSTANT = 0x02000000, OPERATOR = 0x03000000,
  OBJECT = 0x04000000, FUNCTION = 0x05000000, CALL = 0x06000000, STRUCTURE = 0x07000000,
  CHOICE = 0x08000000, VARIABLE = 0x09000000, WHITESPACE = 0x0a000000, LOGICAL = 0x0b000000,
  MV_FUNCTION = 0x0c000000, VECTOR = 0x0d000000, DELAY = 0x0e000000
}
 
- Public Types inherited from CCopasiNode< std::string >
typedef std::string Data
 

Public Member Functions

 CEvaluationNodeConstant (const SubType &subType, const Data &data)
 
 CEvaluationNodeConstant (const CEvaluationNodeConstant &src)
 
virtual std::string getBerkeleyMadonnaString (const std::vector< std::string > &children) const
 
virtual std::string getCCodeString (const std::vector< std::string > &children) const
 
virtual std::string getMMLString (const std::vector< std::string > &children, bool expand, const std::vector< std::vector< std::string > > &variables) const
 
virtual std::string getXPPString (const std::vector< std::string > &children) const
 
virtual bool isBoolean () const
 
virtual ASTNode * toAST (const CCopasiDataModel *pDataModel) const
 
virtual ~CEvaluationNodeConstant ()
 
- Public Member Functions inherited from CEvaluationNode
void addChildren (const std::vector< CEvaluationNode * > &children)
 
std::string buildBerkeleyMadonnaString () const
 
std::string buildCCodeString () const
 
std::string buildDisplayString () const
 
std::string buildInfix () const
 
std::string buildMMLString (bool expand, const std::vector< std::vector< std::string > > &variables) const
 
std::string buildXPPString () const
 
virtual void calculate ()
 
 CEvaluationNode ()
 
 CEvaluationNode (const CEvaluationNode &src)
 
virtual bool compile (const CEvaluationTree *pTree)
 
CEvaluationNodecopyBranch () const
 
CEvaluationNodecopyNode (CEvaluationNode *child1, CEvaluationNode *child2) const
 
CEvaluationNodecopyNode (const std::vector< CEvaluationNode * > &children) const
 
const CEvaluationNodefindTopMinus (const std::vector< CFunctionAnalyzer::CValue > &callParameters) const
 
virtual std::string getDisplayString (const std::vector< std::string > &children) const
 
virtual std::string getInfix (const std::vector< std::string > &children) const
 
const TypegetType () const
 
const C_FLOAT64getValue () const
 
const C_FLOAT64getValuePointer () const
 
virtual bool operator!= (const CEvaluationNode &right) const
 
bool operator< (const CEvaluationNode &right) const
 
bool operator< (const CEvaluationNode &rhs)
 
bool operator== (const CEvaluationNode &right) const
 
void printRecursively (std::ostream &os, int indent=0) const
 
void printRecursively () const
 
virtual CEvaluationNodesimplifyNode (const std::vector< CEvaluationNode * > &children) const
 
CEvaluationNodesplitBranch (const CEvaluationNode *splitnode, bool left) const
 
virtual ~CEvaluationNode ()
 
- Public Member Functions inherited from CCopasiNode< std::string >
virtual bool addChild (CCopasiNode< Data > *pChild, CCopasiNode< Data > *pAfter=NULL)
 
bool addSibling (CCopasiNode< Data > *pSibling, CCopasiNode< Data > *pAfter=NULL)
 
 CCopasiNode (CCopasiNode< Data > *pParent=NULL)
 
 CCopasiNode (const CCopasiNode< Data > &src)
 
 CCopasiNode (const Data &data, CCopasiNode< Data > *pParent=NULL)
 
bool deleteChildren ()
 
CCopasiNode< Data > * getChild ()
 
const CCopasiNode< Data > * getChild () const
 
CCopasiNode< Data > * getChild (const size_t &index)
 
const CCopasiNode< Data > * getChild (const size_t &index) const
 
virtual const DatagetData () const
 
CCopasiNode< Data > * getNext ()
 
const CCopasiNode< Data > * getNext () const
 
CCopasiNode< Data > * getNextNonChild ()
 
const CCopasiNode< Data > * getNextNonChild () const
 
size_t getNumChildren () const
 
CCopasiNode< Data > * getParent ()
 
const CCopasiNode< Data > * getParent () const
 
CCopasiNode< Data > * getSibling ()
 
const CCopasiNode< Data > * getSibling () const
 
virtual bool removeChild (CCopasiNode< Data > *pChild)
 
virtual bool setData (const Data &data)
 
virtual ~CCopasiNode ()
 

Static Public Member Functions

static CEvaluationNodefromAST (const ASTNode *pASTNode, const std::vector< CEvaluationNode * > &children)
 
- Static Public Member Functions inherited from CEvaluationNode
static CEvaluationNodecreate (const Type &type, const Data &data)
 
static bool isKeyword (const std::string &str)
 
static Type subType (const Type &type)
 
static Type type (const Type &type)
 

Private Member Functions

 CEvaluationNodeConstant ()
 

Additional Inherited Members

- Protected Member Functions inherited from CEvaluationNode
 CEvaluationNode (const Type &type, const Data &data)
 
- Protected Member Functions inherited from CCopasiNode< std::string >
bool setChild (CCopasiNode< Data > *pChild)
 
bool setParent (CCopasiNode< Data > *pParent)
 
bool setSibling (CCopasiNode< Data > *pSibling)
 
- Protected Attributes inherited from CEvaluationNode
class CEvaluationNode::CPrecedence mPrecedence
 
const C_FLOAT64mpValue
 
Type mType
 
C_FLOAT64 mValue
 
- Protected Attributes inherited from CCopasiNode< std::string >
Data mData
 

Detailed Description

This is class for nodes presenting Constants used in an evaluation trees

Definition at line 32 of file CEvaluationNodeConstant.h.

Member Enumeration Documentation

Enumeration of possible node types.

Enumerator
INVALID 
PI 
EXPONENTIALE 
TRUE 
FALSE 
_INFINITY 
_NaN 

Definition at line 38 of file CEvaluationNodeConstant.h.

39  {
40  INVALID = 0x00FFFFFF,
41  PI = 0x00000000,
42  EXPONENTIALE = 0x00000001,
43 
44 #ifdef TRUE
45 # undef TRUE
46 #endif
47  TRUE = 0x00000002,
48 
49 #ifdef FALSE
50 # undef FALSE
51 #endif
52  FALSE = 0x00000003,
53 
54  _INFINITY = 0x00000004,
55  _NaN = 0x00000005
56  };

Constructor & Destructor Documentation

CEvaluationNodeConstant::CEvaluationNodeConstant ( )
private

Default constructor

Definition at line 28 of file CEvaluationNodeConstant.cpp.

References CEvaluationNode::mPrecedence, and PRECEDENCE_NUMBER.

Referenced by fromAST().

28  :
class CEvaluationNode::CPrecedence mPrecedence
#define PRECEDENCE_NUMBER
CEvaluationNodeConstant::CEvaluationNodeConstant ( const SubType subType,
const Data data 
)

Default constructor

Parameters
constSubType & subType
constData & data

Definition at line 32 of file CEvaluationNodeConstant.cpp.

References _INFINITY, _NaN, EXPONENTIALE, FALSE, CEvaluationNode::mPrecedence, CEvaluationNode::mValue, PI, PRECEDENCE_NUMBER, and TRUE.

33  :
35 {
36  switch ((SubType) subType)
37  {
38  case PI:
39  mValue = M_PI;
40  break;
41 
42  case EXPONENTIALE:
43  mValue = M_E;
44  break;
45 
46  case TRUE:
47  mValue = 1.0;
48  break;
49 
50  case FALSE:
51  mValue = 0.0;
52  break;
53 
54  case _INFINITY:
55  mValue = std::numeric_limits<C_FLOAT64>::infinity();
56  break;
57 
58  case _NaN:
59  mValue = std::numeric_limits<C_FLOAT64>::quiet_NaN();
60  break;
61 
62  default:
63  mValue = std::numeric_limits<C_FLOAT64>::quiet_NaN();
64  break;
65  }
66 
68 }
static Type subType(const Type &type)
class CEvaluationNode::CPrecedence mPrecedence
#define PRECEDENCE_NUMBER
CEvaluationNodeConstant::CEvaluationNodeConstant ( const CEvaluationNodeConstant src)

Copy constructor

Parameters
constCEvaluationNodeConstant & src

Definition at line 70 of file CEvaluationNodeConstant.cpp.

70  :
71  CEvaluationNode(src)
72 {}
CEvaluationNodeConstant::~CEvaluationNodeConstant ( )
virtual

Destructor

Definition at line 74 of file CEvaluationNodeConstant.cpp.

74 {}

Member Function Documentation

CEvaluationNode * CEvaluationNodeConstant::fromAST ( const ASTNode *  pASTNode,
const std::vector< CEvaluationNode * > &  children 
)
static

Creates a new CEvaluationNodeCall from an ASTNode and the given children

Parameters
constASTNode* pNode
conststd::vector< CEvaluationNode * > & children
Returns
CEvaluationNode * pCretedNode

Definition at line 180 of file CEvaluationNodeConstant.cpp.

References CEvaluationNodeConstant(), EXPONENTIALE, FALSE, INVALID, PI, CEvaluationNode::subType(), and TRUE.

Referenced by CEvaluationTree::fromAST().

181 {
182  assert(pASTNode->getNumChildren() == children.size());
183  assert(children.size() == 0);
184 
186  std::string data = "";
187 
188  switch (pASTNode->getType())
189  {
190  case AST_CONSTANT_E:
191  subType = EXPONENTIALE;
192  data = "EXPONENTIALE";
193  break;
194 
195  case AST_CONSTANT_PI:
196  subType = PI;
197  data = "PI";
198  break;
199 
200  case AST_CONSTANT_TRUE:
201  subType = TRUE;
202  data = "TRUE";
203  break;
204 
205  case AST_CONSTANT_FALSE:
206  subType = FALSE;
207  data = "FALSE";
208  break;
209 
210  default:
211  subType = INVALID;
212  break;
213  }
214 
215  return new CEvaluationNodeConstant(subType, data);
216 }
static Type subType(const Type &type)
std::string CEvaluationNodeConstant::getBerkeleyMadonnaString ( const std::vector< std::string > &  children) const
virtual

Retrieve the display string of the node and its eventual child nodes. in Berkeley Madonna format.

Returns
const Data & value

Reimplemented from CEvaluationNode.

Definition at line 118 of file CEvaluationNodeConstant.cpp.

References _INFINITY, _NaN, EXPONENTIALE, FALSE, CEvaluationNode::getType(), CEvaluationNode::mValue, PI, CEvaluationNode::subType(), and TRUE.

119 {
120  std::ostringstream DisplayString;
121  std::string data = "";
122 
124 
125  switch (subType)
126  {
127  case PI:
128  data = "PI";
129  break;
130 
131  case EXPONENTIALE:
132  case TRUE:
133  case FALSE:
134  case _INFINITY:
135  case _NaN:
136  DisplayString << mValue;
137  data = DisplayString.str();
138  break;
139 
140  default:
141  data = "@";
142  break;
143  }
144 
145  return data;
146 }
const Type & getType() const
static Type subType(const Type &type)
std::string CEvaluationNodeConstant::getCCodeString ( const std::vector< std::string > &  children) const
virtual

Retrieve the display string of the node and its eventual child nodes. in C format.

Returns
const Data & value

Reimplemented from CEvaluationNode.

Definition at line 77 of file CEvaluationNodeConstant.cpp.

References _INFINITY, _NaN, EXPONENTIALE, FALSE, CEvaluationNode::getType(), PI, CEvaluationNode::subType(), and TRUE.

78 {
79  std::string data = "";
80 
82 
83  switch (subType)
84  {
85  case PI:
86  data = "PI";
87  break;
88 
89  case EXPONENTIALE:
90  data = "EXPONENTIALE";
91  break;
92 
93  case TRUE:
94  data = "TRUE";
95  break;
96 
97  case FALSE:
98  data = "FALSE";
99  break;
100 
101  case _INFINITY:
102  data = "INFINITY";
103  break;
104 
105  case _NaN:
106  data = "NaN";
107  break;
108 
109  default:
110  data = "@";
111  break;
112  }
113 
114  return data;
115 }
const Type & getType() const
static Type subType(const Type &type)
std::string CEvaluationNodeConstant::getMMLString ( const std::vector< std::string > &  children,
bool  expand,
const std::vector< std::vector< std::string > > &  variables 
) const
virtual

Build the MathML string

Parameters
conststd::vector< std::string > & children
boolexpand = true
conststd::vector< std::vector< std::string > > & variables
Returns
std::string MMLString

Reimplemented from CEvaluationNode.

Definition at line 273 of file CEvaluationNodeConstant.cpp.

References _INFINITY, _NaN, EXPONENTIALE, FALSE, CEvaluationNode::getType(), PI, CEvaluationNode::subType(), and TRUE.

276 {
277  std::ostringstream out;
278 
279  std::string data = "";
280 
281  switch ((SubType)CEvaluationNode::subType(this->getType()))
282  {
283  case PI:
284  data = "&pi;";
285  break;
286 
287  case EXPONENTIALE:
288  data = "e";
289  break;
290 
291  case TRUE:
292  data = "true";
293  break;
294 
295  case FALSE:
296  data = "false";
297  break;
298 
299  case _INFINITY:
300  data = "&infin;";
301  break;
302 
303  case _NaN:
304  data = "NaN";
305  break;
306 
307  default:
308  data = "@";
309  break;
310  }
311 
312  out << "<mi>" << data << "</mi>" << std::endl;
313 
314  return out.str();
315 }
const Type & getType() const
static Type subType(const Type &type)
std::string CEvaluationNodeConstant::getXPPString ( const std::vector< std::string > &  children) const
virtual

Retrieve the display string of the node and its eventual child nodes. in XPPAUT format.

Returns
const Data & value

Reimplemented from CEvaluationNode.

Definition at line 149 of file CEvaluationNodeConstant.cpp.

References _INFINITY, _NaN, EXPONENTIALE, FALSE, CEvaluationNode::getType(), CEvaluationNode::mValue, PI, CEvaluationNode::subType(), and TRUE.

150 {
151  std::ostringstream DisplayString;
152  std::string data = "";
153 
155 
156  switch (subType)
157  {
158  case PI:
159  data = "pi";
160  break;
161 
162  case EXPONENTIALE:
163  case TRUE:
164  case FALSE:
165  case _INFINITY:
166  case _NaN:
167  DisplayString << mValue;
168  data = DisplayString.str();
169  break;
170 
171  default:
172  data = "@"; //TODO
173  break;
174  }
175 
176  return data;
177 }
const Type & getType() const
static Type subType(const Type &type)
bool CEvaluationNodeConstant::isBoolean ( ) const
virtual

Check whether the result is Boolean

Returns
bool isBoolean

Reimplemented from CEvaluationNode.

Definition at line 219 of file CEvaluationNodeConstant.cpp.

References FALSE, CEvaluationNode::mType, CEvaluationNode::subType(), and TRUE.

220 {
222  {
223  case TRUE:
224  case FALSE:
225  return true;
226 
227  default:
228  return false;
229  }
230 }
static Type subType(const Type &type)
ASTNode * CEvaluationNodeConstant::toAST ( const CCopasiDataModel pDataModel) const
virtual

Create a new ASTNode corresponding to this ConstantNode.

Returns
ASTNode* return a pointer to the newly created node;

Reimplemented from CEvaluationNode.

Definition at line 232 of file CEvaluationNodeConstant.cpp.

References _INFINITY, _NaN, EXPONENTIALE, FALSE, CEvaluationNode::getType(), INVALID, PI, CEvaluationNode::subType(), and TRUE.

233 {
235  ASTNode* node = new ASTNode();
236 
237  switch (subType)
238  {
239  case PI:
240  node->setType(AST_CONSTANT_PI);
241  break;
242 
243  case EXPONENTIALE:
244  node->setType(AST_CONSTANT_E);
245  break;
246 
247  case TRUE:
248  node->setType(AST_CONSTANT_TRUE);
249  break;
250 
251  case FALSE:
252  node->setType(AST_CONSTANT_FALSE);
253  break;
254 
255  case _INFINITY:
256  node->setType(AST_REAL);
257  node->setValue(std::numeric_limits<C_FLOAT64>::infinity());
258  break;
259 
260  case _NaN:
261  case INVALID:
262  node->setType(AST_REAL);
263  node->setValue(std::numeric_limits<C_FLOAT64>::quiet_NaN());
264  break;
265  }
266 
267  return node;
268 }
const Type & getType() const
static Type subType(const Type &type)

The documentation for this class was generated from the following files: