COPASI API  4.16.103
Public Member Functions | Static Public Member Functions | List of all members
ConverterASTNode Class Reference

#include <ConverterASTNode.h>

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

Public Member Functions

 ConverterASTNode ()
 
 ConverterASTNode (const ASTNode &templ)
 
ASTNode * removeChild (unsigned int index)
 
void setChildren (List *children)
 

Static Public Member Functions

static ASTNode * shallowCopy (const ASTNode *pOrig)
 

Detailed Description

Definition at line 23 of file ConverterASTNode.h.

Constructor & Destructor Documentation

ConverterASTNode::ConverterASTNode ( )

Standard constructor.

Standard constructor

Definition at line 27 of file ConverterASTNode.cpp.

Referenced by ConverterASTNode(), and shallowCopy().

27  : ASTNode()
28 {};
ConverterASTNode::ConverterASTNode ( const ASTNode &  templ)

Constructor that makes a ConverterASTNode from an ASTNode.

Definition at line 64 of file ConverterASTNode.cpp.

References ConverterASTNode(), and isNumber().

64  : ASTNode(templ.getType())
65 {
66  if (this->getType() == AST_RATIONAL)
67  {
68  setValue(templ.getNumerator(), templ.getDenominator());
69  }
70  else if (this->getType() == AST_REAL)
71  {
72  setValue(templ.getReal());
73  }
74  else if (this->getType() == AST_REAL_E)
75  {
76  setValue(templ.getMantissa(), templ.getExponent());
77  }
78 
79  if (this->getType() == AST_PLUS ||
80  this->getType() == AST_MINUS ||
81  this->getType() == AST_TIMES ||
82  this->getType() == AST_DIVIDE ||
83  this->getType() == AST_POWER)
84  {
85  this->mChar = templ.getCharacter();
86  }
87  else if (this->getType() == AST_INTEGER)
88  {
89  setValue(templ.getInteger());
90  }
91 
92  if ((!this->isOperator()) && (!this->isNumber()) && !isConstant())
93  {
94  this->setName(templ.getName());
95  }
96 
97  unsigned int counter;
98 
99  for (counter = 0; counter < templ.getNumChildren(); counter++)
100  {
101  this->addChild(new ConverterASTNode(*templ.getChild(counter)));
102  }
103 };
bool isNumber(const std::string &str)
Definition: utility.cpp:75

Member Function Documentation

ASTNode * ConverterASTNode::removeChild ( unsigned int  index)

Removes a child from the list of children.

This function returns true if the node represents a user defined function.

Definition at line 165 of file ConverterASTNode.cpp.

Referenced by SBMLImporter::multiplySubstanceOnlySpeciesByVolume(), SBMLImporter::replace_delay_nodes(), SBMLImporter::replaceAmountReferences(), and shallowCopy().

166 {
167  ASTNode * removedChild = getChild(index);
168 
169  this->ASTNode::removeChild(index);
170 
171  return removedChild;
172 };
void ConverterASTNode::setChildren ( List *  children)

Sets the list of children to the one given as argument. The list is not copied.

Extension of the ASTNode class from libsbml. This class extends the original ASTNode by some functions to manipulate the children of a node. Sets the list of children to the one given as argument. The list is not copied.

Definition at line 39 of file ConverterASTNode.cpp.

References CCopasiVector< T >::size().

40 {
41  if (mNumber != NULL)
42  {
43  return; // cannot add children to a number type astnode
44  }
45  else if (mFunction != NULL)
46  {
47  unsigned int size = mFunction->getNumChildren();
48 
49  for (unsigned int i = mFunction->getNumChildren(); i > 0; i--)
50  {
51  mFunction->removeChild(i - 1);
52  }
53 
54  for (unsigned int i = 0; i < children->getSize(); i++)
55  {
56  mFunction->addChild(static_cast<ASTNode*>(children->get(i)));
57  }
58  }
59 };
ASTNode * ConverterASTNode::shallowCopy ( const ASTNode *  pOrig)
static

This function returns true if the node represents a user defined function.

Constructor that makes a ConverterASTNode from an ASTNode.

Definition at line 177 of file ConverterASTNode.cpp.

References ConverterASTNode(), and removeChild().

Referenced by expand_function_calls(), replace_variable_names(), and CSBMLExporter::replaceL1IncompatibleNodes().

178 {
179  ConverterASTNode* pTmp = new ConverterASTNode(*pOrig);
180 
181  while (pTmp->getNumChildren() > 0)
182  {
183  delete pTmp->removeChild(0);
184  }
185 
186  ASTNode* pCopy = pTmp->deepCopy();
187  delete pTmp;
188  return pCopy;
189 };
ASTNode * removeChild(unsigned int index)

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