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

#include <CEvaluationNodeObject.h>

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

Public Types

enum  SubType { INVALID = 0x00FFFFFF, CN = 0x00000000, POINTER = 0x00000001 }
 
- 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

 CEvaluationNodeObject (const SubType &subType, const Data &data)
 
 CEvaluationNodeObject (const C_FLOAT64 *pValue)
 
 CEvaluationNodeObject (const CEvaluationNodeObject &src)
 
virtual bool compile (const CEvaluationTree *pTree)
 
virtual std::string getBerkeleyMadonnaString (const std::vector< std::string > &children) const
 
virtual std::string getCCodeString (const std::vector< std::string > &children) const
 
virtual const DatagetData () const
 
virtual std::string getDisplayString (const std::vector< std::string > &children) const
 
virtual std::string getInfix (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
 
const CRegisteredObjectNamegetObjectCN () const
 
const CObjectInterfacegetObjectInterfacePtr () const
 
const C_FLOAT64getObjectValuePtr () const
 
virtual std::string getXPPString (const std::vector< std::string > &children) const
 
virtual bool setData (const Data &data)
 
void setObjectValuePtr (C_FLOAT64 *pObjectValue)
 
virtual ASTNode * toAST (const CCopasiDataModel *pDataModel) const
 
virtual ~CEvaluationNodeObject ()
 
- 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)
 
CEvaluationNodecopyBranch () const
 
CEvaluationNodecopyNode (CEvaluationNode *child1, CEvaluationNode *child2) const
 
CEvaluationNodecopyNode (const std::vector< CEvaluationNode * > &children) const
 
const CEvaluationNodefindTopMinus (const std::vector< CFunctionAnalyzer::CValue > &callParameters) const
 
const TypegetType () const
 
const C_FLOAT64getValue () const
 
const C_FLOAT64getValuePointer () const
 
virtual bool isBoolean () 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
 
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 ~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

 CEvaluationNodeObject ()
 

Private Attributes

const CObjectInterfacempObject
 
CRegisteredObjectName mRegisteredObjectCN
 

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 numbers used in an evaluation trees

Definition at line 34 of file CEvaluationNodeObject.h.

Member Enumeration Documentation

Enumeration of possible node types. The typing of variables must be handled by the tree.

Enumerator
INVALID 
CN 
POINTER 

Definition at line 41 of file CEvaluationNodeObject.h.

Constructor & Destructor Documentation

CEvaluationNodeObject::CEvaluationNodeObject ( )
private

Default constructor

Definition at line 34 of file CEvaluationNodeObject.cpp.

References CEvaluationNode::mPrecedence, and PRECEDENCE_NUMBER.

Referenced by fromAST().

34  :
36  mpObject(NULL),
const CObjectInterface * mpObject
CRegisteredObjectName mRegisteredObjectCN
class CEvaluationNode::CPrecedence mPrecedence
#define PRECEDENCE_NUMBER
CEvaluationNodeObject::CEvaluationNodeObject ( const SubType subType,
const Data data 
)

Default constructor

Parameters
constSubType & subType
constData & data

Definition at line 40 of file CEvaluationNodeObject.cpp.

References CEvaluationNode::mPrecedence, and PRECEDENCE_NUMBER.

41  :
43  mpObject(NULL),
44  mRegisteredObjectCN(data.substr(1, data.length() - 2))
45 {
47 }
const CObjectInterface * mpObject
CRegisteredObjectName mRegisteredObjectCN
static Type subType(const Type &type)
class CEvaluationNode::CPrecedence mPrecedence
#define PRECEDENCE_NUMBER
CEvaluationNodeObject::CEvaluationNodeObject ( const C_FLOAT64 pValue)

Specific constructor

Parameters
constData & data

Definition at line 49 of file CEvaluationNodeObject.cpp.

References CCopasiNode< std::string >::mData, CEvaluationNode::mPrecedence, CEvaluationNode::mpValue, pointerToString(), and PRECEDENCE_NUMBER.

49  :
51  mpObject(NULL),
53 {
55  mpValue = pValue;
56  mData = pointerToString(pValue);
57 }
std::string pointerToString(const void *pVoid)
Definition: utility.cpp:423
const CObjectInterface * mpObject
CRegisteredObjectName mRegisteredObjectCN
class CEvaluationNode::CPrecedence mPrecedence
#define PRECEDENCE_NUMBER
const C_FLOAT64 * mpValue
CEvaluationNodeObject::CEvaluationNodeObject ( const CEvaluationNodeObject src)

Copy constructor

Parameters
constCEvaluationNodeObject & src

Definition at line 59 of file CEvaluationNodeObject.cpp.

References CEvaluationNode::mpValue.

59  :
60  CEvaluationNode(src),
61  mpObject(src.mpObject),
63 {
64  mpValue = src.mpValue;
65 }
const CObjectInterface * mpObject
CRegisteredObjectName mRegisteredObjectCN
const C_FLOAT64 * mpValue
CEvaluationNodeObject::~CEvaluationNodeObject ( )
virtual

Destructor

Definition at line 67 of file CEvaluationNodeObject.cpp.

67 {}

Member Function Documentation

bool CEvaluationNodeObject::compile ( const CEvaluationTree pTree)
virtual

Compile a node;

Parameters
constCEvaluationTree * pTree
Returns
bool success;

Reimplemented from CEvaluationNode.

Definition at line 69 of file CEvaluationNodeObject.cpp.

References C_FLOAT64, CN, CCopasiNode< std::string >::getChild(), CObjectInterface::getCN(), getData(), CExpression::getNodeObject(), CCopasiObject::getValueObject(), CObjectInterface::getValuePointer(), INVALID, CCopasiObject::isValueDbl(), CCopasiNode< std::string >::mData, mpObject, CEvaluationNode::mpValue, mRegisteredObjectCN, CEvaluationNode::mType, CEvaluationNode::mValue, POINTER, stringToPointer(), and CEvaluationNode::subType().

70 {
71  mpObject = NULL;
72  mpValue = NULL;
73 
74  switch ((int) subType(mType))
75  {
76  case CN:
77  {
78  const CExpression * pExpression = dynamic_cast< const CExpression * >(pTree);
79 
80  if (!pExpression) return false;
81 
82  mpObject =
83  pExpression->getNodeObject(mRegisteredObjectCN);
84 
85  const CCopasiObject * pDataObject = dynamic_cast< const CCopasiObject * >(mpObject);
86 
87  if (pDataObject != NULL)
88  {
89  // We may have some container objects for which the value is an included
90  // reference. For the math model to work this needs to be corrected.
91  const CObjectInterface * pObject = pDataObject->getValueObject();
92 
93  if (mpObject != pObject && pObject != NULL)
94  {
95  mpObject = pObject;
97  mData = getData();
98  }
99 
100  if (pDataObject->isValueDbl())
101  {
103  }
104  }
105  else if (mpObject != NULL)
106  {
108  }
109 
110  if (mpValue == NULL)
111  {
112  mValue = std::numeric_limits<C_FLOAT64>::quiet_NaN();
113  mpValue = &mValue;
114  return false;
115  }
116 
117  mData = "<" + mRegisteredObjectCN + ">";
118  }
119  break;
120 
121  case POINTER:
122  // We need to convert the data into a pointer
123  {
124  mpValue = (const C_FLOAT64 *) stringToPointer(mData);
125  }
126  break;
127 
128  case INVALID:
129  break;
130  }
131 
132  return (getChild() == NULL); // We must not have any children.
133 }
const CObjectInterface * getNodeObject(const CCopasiObjectName &CN) const
virtual CCopasiObjectName getCN() const =0
const CObjectInterface * mpObject
CRegisteredObjectName mRegisteredObjectCN
static Type subType(const Type &type)
#define C_FLOAT64
Definition: copasi.h:92
void * stringToPointer(const std::string str)
Definition: utility.cpp:414
bool isValueDbl() const
virtual void * getValuePointer() const =0
const C_FLOAT64 * mpValue
virtual const Data & getData() const
virtual const CCopasiObject * getValueObject() const
CCopasiNode< Data > * getChild()
Definition: CCopasiNode.h:210
CEvaluationNode * CEvaluationNodeObject::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 226 of file CEvaluationNodeObject.cpp.

References CEvaluationNodeObject(), and CN.

Referenced by CEvaluationTree::fromAST().

227 {
228  assert(pASTNode->getNumChildren() == children.size());
229 
230  CEvaluationNodeObject* pNode = NULL;
231 
232  switch (pASTNode->getType())
233  {
234  case AST_NAME_AVOGADRO:
235  case AST_NAME_TIME:
236  case AST_NAME:
237  pNode = new CEvaluationNodeObject(CN, CCopasiObjectName(std::string("<") + pASTNode->getName() + std::string(">")));
238  break;
239 
240  default:
241  break;
242  }
243 
244  return pNode;
245 }
std::string CEvaluationNodeObject::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 214 of file CEvaluationNodeObject.cpp.

References CCopasiNode< std::string >::mData.

215 {
216  return mData;
217 }
std::string CEvaluationNodeObject::getCCodeString ( const std::vector< std::string > &  children) const
virtual

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

Returns
const Data & value

Reimplemented from CEvaluationNode.

Definition at line 208 of file CEvaluationNodeObject.cpp.

References CCopasiNode< std::string >::mData.

209 {
210  return mData;
211 }
const CEvaluationNode::Data & CEvaluationNodeObject::getData ( ) const
virtual

Retrieve the value of the node.

Returns
const Data & value

Reimplemented from CCopasiNode< std::string >.

Definition at line 135 of file CEvaluationNodeObject.cpp.

References CN, CCopasiNode< std::string >::mData, mRegisteredObjectCN, CEvaluationNode::mType, POINTER, and CEvaluationNode::subType().

Referenced by compile(), SBMLImporter::doMapping(), CReaction::object2variable(), SBMLImporter::renameMassActionParameters(), and SBMLImporter::setCorrectUsage().

136 {
137  static std::string data;
138 
139  switch ((int) subType(mType))
140  {
141  case CN:
142  return data = "<" + mRegisteredObjectCN + ">";
143  break;
144 
145  case POINTER:
146  return mData;
147  break;
148  }
149 
150  return mData;
151 }
CRegisteredObjectName mRegisteredObjectCN
static Type subType(const Type &type)
std::string CEvaluationNodeObject::getDisplayString ( const std::vector< std::string > &  children) const
virtual

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

Returns
const Data & value

Reimplemented from CEvaluationNode.

Definition at line 197 of file CEvaluationNodeObject.cpp.

References CCopasiObject::getObjectDisplayName(), mpObject, and mRegisteredObjectCN.

198 {
199  const CCopasiObject* object = dynamic_cast<const CCopasiObject*>(mpObject);
200 
201  if (object != NULL)
202  return object->getObjectDisplayName();
203 
204  return "<" + mRegisteredObjectCN + ">";
205 }
virtual std::string getObjectDisplayName(bool regular=true, bool richtext=false) const
const CObjectInterface * mpObject
CRegisteredObjectName mRegisteredObjectCN
std::string CEvaluationNodeObject::getInfix ( const std::vector< std::string > &  children) const
virtual

Retrieve the infix value of the node and its eventual child nodes.

Returns
const Data & value

Reimplemented from CEvaluationNode.

Definition at line 164 of file CEvaluationNodeObject.cpp.

References CN, CCopasiNode< std::string >::mData, mRegisteredObjectCN, CEvaluationNode::mType, POINTER, and CEvaluationNode::subType().

165 {
166  switch ((int) subType(mType))
167  {
168  case CN:
169  return "<" + mRegisteredObjectCN + ">";
170  break;
171 
172  case POINTER:
173  return mData;
174  break;
175  }
176 
177  return mData;
178 }
CRegisteredObjectName mRegisteredObjectCN
static Type subType(const Type &type)
std::string CEvaluationNodeObject::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 390 of file CEvaluationNodeObject.cpp.

References CMathObject::getDataObject(), CMathMl::getMMLName(), and mpObject.

393 {
394  std::ostringstream out;
395 
396  const CCopasiObject * pDataObject = dynamic_cast< const CCopasiObject * >(mpObject);
397 
398  if (pDataObject == NULL)
399  {
400  const CMathObject * pMathObject = dynamic_cast< const CMathObject * >(mpObject);
401 
402  if (pMathObject != NULL)
403  {
404  pDataObject = pMathObject->getDataObject();
405  }
406  }
407 
408  out << CMathMl::getMMLName(pDataObject) << std::endl;
409 
410  return out.str();
411 }
static std::string getMMLName(const CCopasiObject *obj)
Definition: copasimathml.h:45
const CObjectInterface * mpObject
const CCopasiObject * getDataObject() const
const CRegisteredObjectName & CEvaluationNodeObject::getObjectCN ( ) const

Retrieve the CN of the referred object.

Returns
const CRegisteredObjectName & objectCN

Definition at line 351 of file CEvaluationNodeObject.cpp.

References mRegisteredObjectCN.

Referenced by CSBMLExporter::checkForUnsupportedObjectReferences(), CModelAdd::copyDelayExpression(), CModelAdd::copyEventAssignmentExpression(), CModelAdd::copyExpression(), CModelAdd::copyInitialExpression(), CModelAdd::copyTriggerExpression(), CExpression::createInitialExpression(), CODEExporter::exportExpression(), CSBMLExporter::findModelEntityDependencies(), CODEExporter::isModelEntityExpressionODEExporterCompatible(), CModelMerging::mergeInExpression(), test000093::test_bug1503_1(), test000093::test_bug1503_2(), test000047::test_delay(), test000024::test_hasOnlySubstanceUnits(), test000027::test_hasOnlySubstanceUnits(), test000028::test_hasOnlySubstanceUnits(), test000029::test_hasOnlySubstanceUnits(), test000041::test_hasOnlySubstanceUnits(), test000042::test_hasOnlySubstanceUnits(), test000030::test_hasOnlySubstanceUnits(), test000031::test_hasOnlySubstanceUnits(), test000032::test_hasOnlySubstanceUnits(), test000034::test_hasOnlySubstanceUnits(), test000035::test_hasOnlySubstanceUnits(), test000036::test_hasOnlySubstanceUnits(), test000037::test_hasOnlySubstanceUnits(), test000038::test_hasOnlySubstanceUnits(), test000039::test_hasOnlySubstanceUnits(), test000021::test_hasOnlySubstanceUnits(), test000022::test_hasOnlySubstanceUnits(), test000043::test_hasOnlySubstanceUnits(), test000082::test_import_delayAssignment_1(), test000082::test_import_delayAssignment_2(), test000082::test_import_delayAssignment_3(), test000082::test_import_delayAssignment_4(), test000082::test_import_delayAssignment_5(), test000082::test_import_delayAssignment_6(), test000082::test_import_delayAssignment_7(), test000082::test_import_delayAssignment_8(), test000064::test_import_event_assignment_expression_and_hasOnlySubstanceUnits_1(), test000064::test_import_event_assignment_expression_and_hasOnlySubstanceUnits_2(), test000064::test_import_event_assignment_expression_and_hasOnlySubstanceUnits_3(), test000064::test_import_event_assignment_expression_and_hasOnlySubstanceUnits_4(), test000064::test_import_event_assignment_expression_and_hasOnlySubstanceUnits_5(), test000064::test_import_event_assignment_expression_and_hasOnlySubstanceUnits_6(), test000064::test_import_event_assignment_expression_and_hasOnlySubstanceUnits_7(), test000064::test_import_event_assignment_expression_and_hasOnlySubstanceUnits_8(), test000095::test_import_l3_event_1(), test000095::test_import_l3_event_2(), test000095::test_import_l3_event_3(), test000095::test_import_l3_event_4(), test000095::test_import_l3_event_5(), test000087::test_import_reaction_flux_reference_2(), test000064::test_import_rule_expression_and_hasOnlySubstanceUnits_1(), test000064::test_import_rule_expression_and_hasOnlySubstanceUnits_2(), test000064::test_import_rule_expression_and_hasOnlySubstanceUnits_3(), test000064::test_import_rule_expression_and_hasOnlySubstanceUnits_4(), test000064::test_import_rule_expression_and_hasOnlySubstanceUnits_5(), test000064::test_import_rule_expression_and_hasOnlySubstanceUnits_6(), test000064::test_import_rule_expression_and_hasOnlySubstanceUnits_7(), test000064::test_import_rule_expression_and_hasOnlySubstanceUnits_8(), test000087::test_simulate_reaction_flux_reference_1(), toAST(), and CModelExpansion::updateExpression().

352 {return mRegisteredObjectCN;}
CRegisteredObjectName mRegisteredObjectCN
const CObjectInterface * CEvaluationNodeObject::getObjectInterfacePtr ( ) const

Retrieve the pointer to the referred object interface

Returns
const CObjectInterface * pObjectInterface

Definition at line 354 of file CEvaluationNodeObject.cpp.

References mpObject.

Referenced by CModelExpansion::expressionContainsObject(), CModelExpansion::replaceInExpression(), and CModelExpansion::updateExpression().

355 {
356  return mpObject;
357 }
const CObjectInterface * mpObject
const C_FLOAT64 * CEvaluationNodeObject::getObjectValuePtr ( ) const

Retrieve the pointer to the value of the referred object

Returns
const C_FLOAT64 * pObjectValue

Definition at line 359 of file CEvaluationNodeObject.cpp.

References CEvaluationNode::mpValue.

Referenced by CMathExpression::convertToInitialExpression().

360 {
361  return mpValue;
362 }
const C_FLOAT64 * mpValue
std::string CEvaluationNodeObject::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 220 of file CEvaluationNodeObject.cpp.

References CCopasiNode< std::string >::mData.

221 {
222  return mData;
223 }
bool CEvaluationNodeObject::setData ( const Data data)
virtual
void CEvaluationNodeObject::setObjectValuePtr ( C_FLOAT64 pObjectValue)

Set the pointer to the value of the referred object

Parameters
C_FLOAT64* pObjectValue

Definition at line 364 of file CEvaluationNodeObject.cpp.

References CN, CCopasiNode< std::string >::mData, CEvaluationNode::mpValue, CEvaluationNode::mType, POINTER, pointerToString(), and CEvaluationNode::subType().

Referenced by CMathExpression::convertToInitialExpression().

365 {
366  assert(pObjectValue);
367 
368  switch ((int) subType(mType))
369  {
370  case CN:
371  break;
372 
373  case POINTER:
374 
375  if (mpValue != pObjectValue)
376  {
377  mpValue = pObjectValue;
379  }
380 
381  break;
382  }
383 
384  return;
385 }
std::string pointerToString(const void *pVoid)
Definition: utility.cpp:423
static Type subType(const Type &type)
const C_FLOAT64 * mpValue
ASTNode * CEvaluationNodeObject::toAST ( const CCopasiDataModel pDataModel) const
virtual

Converts this node to an ASTNode.

Returns
ASTNode the resulting ASTNode.

Reimplemented from CEvaluationNode.

Definition at line 247 of file CEvaluationNodeObject.cpp.

References fatalError, CCopasiNode< std::string >::getChild(), CCopasiParameter::getCN(), CCopasiDataModel::getDataObject(), CModel::getInitialTime(), getObjectCN(), CCopasiObject::getObjectName(), CCopasiObject::getObjectParent(), CModelEntity::getSBMLId(), CReaction::getSBMLId(), CCopasiObject::isReference(), MCSBML, mRegisteredObjectCN, CEvaluationNode::toAST(), and CCopasiMessage::WARNING.

248 {
249  ASTNode* node = new ASTNode();
250  node->setType(AST_NAME);
251 
252  if (mRegisteredObjectCN == "rateOf")
253  {
254  node->setType(AST_FUNCTION);
255  const CEvaluationNode* child = dynamic_cast<const CEvaluationNode*>(this->getChild());
256 
257  if (child == NULL) fatalError();
258 
259  const CEvaluationNodeObject* sibling = dynamic_cast<const CEvaluationNodeObject*>(this->getChild()->getSibling());
260 
261  if (sibling == NULL) fatalError();
262 
263  node->setName(sibling->getObjectCN().c_str());
264  node->addChild(child->toAST(pDataModel));
265  return node;
266  }
267 
268  // since I can not get the model in which this node is located, I just
269  // assume that it will always be the current global model.
270  const CCopasiObject* pOrigObject = pDataModel->getDataObject(mRegisteredObjectCN);
271 
272  if (pOrigObject == NULL)
273  {
274  node->setName(mRegisteredObjectCN.c_str());
275  return node;
276  }
277 
278  const CCopasiObject* pObject = pOrigObject;
279 
280  // if it is a reference, we get the parent of the reference
281  if (pObject->isReference())
282  {
283  pObject = pObject->getObjectParent();
284  }
285 
286  const CModelEntity* pME = dynamic_cast<const CModelEntity*>(pObject);
287 
288  if (pME != NULL)
289  {
290  const CModel* pModel = dynamic_cast<const CModel*>(pME);
291 
292  if (pModel != NULL)
293  {
294 #if LIBSBML_VERSION >= 40100
295 
296  if (pOrigObject->getObjectName() == "Avogadro Constant")
297  {
298  node->setType(AST_NAME_AVOGADRO);
299  node->setName("avogadro");
300  }
301  else
302  {
303 #endif // LIBSBML_VERSION >= 40100
304  node->setType(AST_NAME_TIME);
305  node->setName("time");
306 
307  if (pModel->getInitialTime() != 0.0)
308  {
310  }
311 
312 #if LIBSBML_VERSION >= 40100
313  }
314 
315 #endif // LIBSBML_VERSION >= 40100
316  }
317  else
318  {
319  node->setName(pME->getSBMLId().c_str());
320  }
321  }
322  else
323  {
324  const CCopasiParameter* pPara = dynamic_cast<const CCopasiParameter*>(pObject);
325 
326  if (pPara != NULL)
327  {
328  // now we have to use the common name as the name for the
329  // node since we need to be able to identify local parameters
330  // in arbitrary expressions for the export
331  node->setName(pPara->getCN().c_str());
332  }
333  else
334  {
335  const CReaction* pReaction = dynamic_cast<const CReaction*>(pObject);
336 
337  if (pReaction)
338  {
339  node->setName(pReaction->getSBMLId().c_str());
340  }
341  else
342  {
343  fatalError();
344  }
345  }
346  }
347 
348  return node;
349 }
CCopasiObject * getDataObject(const CCopasiObjectName &CN) const
virtual ASTNode * toAST(const CCopasiDataModel *pDataModel) const
const std::string & getSBMLId() const
const std::string & getObjectName() const
const CRegisteredObjectName & getObjectCN() const
#define fatalError()
const std::string & getSBMLId() const
Definition: CReaction.cpp:1654
#define MCSBML
bool isReference() const
CRegisteredObjectName mRegisteredObjectCN
const C_FLOAT64 & getInitialTime() const
Definition: CModel.cpp:1184
virtual CCopasiObjectName getCN() const
Definition: CModel.h:50
CCopasiNode< Data > * getChild()
Definition: CCopasiNode.h:210
CCopasiContainer * getObjectParent() const

Member Data Documentation

const CObjectInterface* CEvaluationNodeObject::mpObject
private

Pointer to the object

Definition at line 187 of file CEvaluationNodeObject.h.

Referenced by compile(), getDisplayString(), getMMLString(), and getObjectInterfacePtr().

CRegisteredObjectName CEvaluationNodeObject::mRegisteredObjectCN
private

The registered object name to track eventual renaming.

Definition at line 192 of file CEvaluationNodeObject.h.

Referenced by compile(), getData(), getDisplayString(), getInfix(), getObjectCN(), setData(), and toAST().


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