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

#include <CEvaluationNodeVariable.h>

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

Public Types

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

virtual void calculate ()
 
 CEvaluationNodeVariable (const SubType &subType, const Data &data)
 
 CEvaluationNodeVariable (const CEvaluationNodeVariable &src)
 
virtual bool compile (const CEvaluationTree *pTree)
 
size_t getIndex () const
 
virtual std::string getMMLString (const std::vector< std::string > &children, bool expand, const std::vector< std::vector< std::string > > &variables) const
 
virtual ASTNode * toAST (const CCopasiDataModel *pDataModel) const
 
virtual ~CEvaluationNodeVariable ()
 
- 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
 
 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
 
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 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 std::string getXPPString (const std::vector< std::string > &children) 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
 
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 ()
 

Private Member Functions

 CEvaluationNodeVariable ()
 

Private Attributes

size_t mIndex
 
const CEvaluationTreempTree
 

Additional Inherited Members

- 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)
 
- 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 32 of file CEvaluationNodeVariable.h.

Member Enumeration Documentation

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

Enumerator
INVALID 
ANY 

Definition at line 39 of file CEvaluationNodeVariable.h.

Constructor & Destructor Documentation

CEvaluationNodeVariable::CEvaluationNodeVariable ( )
private

Default constructor

Definition at line 29 of file CEvaluationNodeVariable.cpp.

References CEvaluationNode::mPrecedence, and PRECEDENCE_NUMBER.

29  :
31  mpTree(NULL),
#define C_INVALID_INDEX
Definition: copasi.h:222
const CEvaluationTree * mpTree
class CEvaluationNode::CPrecedence mPrecedence
#define PRECEDENCE_NUMBER
CEvaluationNodeVariable::CEvaluationNodeVariable ( const SubType subType,
const Data data 
)

Default constructor

Parameters
constSubType & subType
constData & data

Definition at line 35 of file CEvaluationNodeVariable.cpp.

References CEvaluationNode::mPrecedence, and PRECEDENCE_NUMBER.

36  :
38  mpTree(NULL),
#define C_INVALID_INDEX
Definition: copasi.h:222
const CEvaluationTree * mpTree
static Type subType(const Type &type)
class CEvaluationNode::CPrecedence mPrecedence
#define PRECEDENCE_NUMBER
CEvaluationNodeVariable::CEvaluationNodeVariable ( const CEvaluationNodeVariable src)

Copy constructor

Parameters
constCEvaluationNodeVariable & src

Definition at line 42 of file CEvaluationNodeVariable.cpp.

42  :
43  CEvaluationNode(src),
44  mpTree(src.mpTree),
45  mIndex(src.mIndex)
46 {}
const CEvaluationTree * mpTree
CEvaluationNodeVariable::~CEvaluationNodeVariable ( )
virtual

Destructor

Definition at line 48 of file CEvaluationNodeVariable.cpp.

48 {}

Member Function Documentation

void CEvaluationNodeVariable::calculate ( void  )
virtual

Calculate the numerical result of the node. It is assumed that all child nodes are up to date.

Reimplemented from CEvaluationNode.

Definition at line 63 of file CEvaluationNodeVariable.cpp.

References CEvaluationTree::getVariableValue(), mIndex, mpTree, and CEvaluationNode::mValue.

64 {
66 }
virtual const C_FLOAT64 & getVariableValue(const size_t &index) const
const CEvaluationTree * mpTree
bool CEvaluationNodeVariable::compile ( const CEvaluationTree pTree)
virtual

Compile a node;

Parameters
constCEvaluationTree * pTree
Returns
bool success;

Reimplemented from CEvaluationNode.

Definition at line 50 of file CEvaluationNodeVariable.cpp.

References C_INVALID_INDEX, CCopasiNode< std::string >::getChild(), CEvaluationTree::getVariableIndex(), CCopasiNode< std::string >::mData, mIndex, and mpTree.

51 {
52  mpTree = pTree;
53 
54  if (!pTree) return false;
55 
56  mIndex = pTree->getVariableIndex(mData);
57 
58  if (mIndex == C_INVALID_INDEX) return false;
59 
60  return (getChild() == NULL); // We must not have any children.
61 }
virtual size_t getVariableIndex(const std::string &name) const
#define C_INVALID_INDEX
Definition: copasi.h:222
const CEvaluationTree * mpTree
CCopasiNode< Data > * getChild()
Definition: CCopasiNode.h:210
size_t CEvaluationNodeVariable::getIndex ( ) const

return the index of the variable in the function parameter list

Definition at line 68 of file CEvaluationNodeVariable.cpp.

References mIndex.

Referenced by CMathEventN::CTrigger::compile(), CMathContainer::copyBranch(), CDerive::deriveBranch(), CFunctionAnalyzer::evaluateNode(), and CFindDimensions::findDimension().

std::string CEvaluationNodeVariable::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 82 of file CEvaluationNodeVariable.cpp.

References CMathMl::fixName(), CCopasiNode< std::string >::mData, and mIndex.

85 {
86  std::ostringstream out;
87 
88  if (mIndex < variables.size())
89  {
90  out << variables[mIndex][0] << std::endl;
91  }
92  else
93  {
94  out << "<mi>" << CMathMl::fixName(mData) << "</mi>" << std::endl;
95  }
96 
97  return out.str();
98 }
static std::string fixName(const std::string &name)
Definition: copasimathml.h:33
ASTNode * CEvaluationNodeVariable::toAST ( const CCopasiDataModel pDataModel) const
virtual

Converts this node to an AST Node of type AST_NAME

Returns
ASTNode* the resulting ASTNode.

Reimplemented from CEvaluationNode.

Definition at line 71 of file CEvaluationNodeVariable.cpp.

References CCopasiNode< std::string >::getData().

72 {
73  ASTNode* node = new ASTNode();
74  node->setType(AST_NAME);
75  node->setName(this->getData().c_str());
76  return node;
77 }
virtual const Data & getData() const
Definition: CCopasiNode.h:118

Member Data Documentation

size_t CEvaluationNodeVariable::mIndex
private

Index of the variable used to retrieve its value from the tree.

Definition at line 117 of file CEvaluationNodeVariable.h.

Referenced by calculate(), compile(), getIndex(), and getMMLString().

const CEvaluationTree* CEvaluationNodeVariable::mpTree
private

Pointer to the evaluation tree.

Definition at line 112 of file CEvaluationNodeVariable.h.

Referenced by calculate(), and compile().


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