COPASI API  4.40.278
CEvaluationTree Class Reference

#include <CEvaluationTree.h>

Inheritance diagram for CEvaluationTree:
[legend]

Public Types

enum  Type {
  Function = 0 , MassAction , PreDefined , UserDefined ,
  Expression , MathExpression
}
 
- Public Types inherited from CDataContainer
typedef CDataObjectMap objectMap
 
- Public Types inherited from CDataObject
typedef std::set< const CDataObject * > DataObjectSet
 
enum  Flag {
  Container , Vector , Matrix , NameVector ,
  Reference , ValueBool , ValueInt , ValueInt64 ,
  ValueDbl , NonUniqueName , StaticString , ValueString ,
  Separator , DisplayName , ModelEntity , Array ,
  DataModel , Root , Gui , __SIZE
}
 
- Public Types inherited from CObjectInterface
typedef std::vector< const CDataContainer * > ContainerList
 
typedef std::set< const CObjectInterface * > ObjectSet
 

Public Member Functions

virtual bool applyData (const CData &data, CUndoData::CChangeSet &changes)
 
bool calls (std::set< std::string > &list) const
 
 CEvaluationTree (const CEvaluationTree &src, const CDataContainer *pParent)
 
 CEvaluationTree (const std::string &name="NoName", const CDataContainer *pParent=NO_PARENT, const Type &type=Function)
 
virtual CIssue compile ()
 
bool containsCN (const DataObjectSet &elements) const
 
std::string::size_type getErrorPosition () const
 
const std::string & getInfix () const
 
const std::vector< CEvaluationNode * > & getNodeList () const
 
virtual const CObjectInterfacegetNodeObject (const CCommonName &CN) const
 
CEvaluationNodegetRoot ()
 
const CEvaluationNodegetRoot () const
 
const CEvaluationTree::TypegetType () const
 
virtual size_t getVariableIndex (const std::string &name) const
 
virtual const C_FLOAT64getVariableValue (const size_t &index) const
 
bool hasCircularDependency () const
 
bool hasDiscontinuity () const
 
bool isBoolean () const
 
bool mapObjectNodes (const CDataContainer *pSrc, const CDataContainer *pTarget)
 
bool operator== (const CEvaluationTree &rhs) const
 
virtual CIssue setInfix (const std::string &infix)
 
virtual bool setRoot (CEvaluationNode *pRootNode)
 
bool setTree (const ASTNode &pRootNode, bool isFunction)
 
size_t size () const
 
virtual ASTNode * toAST (const CDataModel *pDataModel) const
 
virtual CData toData () const
 
CIssue updateTree ()
 
virtual ~CEvaluationTree ()
 
- Public Member Functions inherited from CDataContainer
virtual bool add (CDataObject *pObject, const bool &adopt=true)
 
virtual bool appendDeletedDependentData (CUndoData &undoData) const
 
 CDataContainer (const CDataContainer &src, const CDataContainer *pParent)
 
 CDataContainer (const std::string &name, const CDataContainer *pParent=NO_PARENT, const std::string &type="CN", const CFlags< Flag > &flag=CFlags< Flag >::None)
 
virtual void createUndoData (CUndoData &undoData, const CUndoData::Type &type, const CData &oldData=CData(), const CCore::Framework &framework=CCore::Framework::ParticleNumbers) const override
 
virtual std::string getChildObjectUnits (const CDataObject *pObject) const
 
void getDescendants (CDataObject::DataObjectSet &descendants, const bool &recursive=false) const
 
virtual size_t getIndex (const CDataObject *pObject) const
 
virtual const CObjectInterfacegetObject (const CCommonName &cn) const override
 
virtual objectMapgetObjects ()
 
virtual const objectMapgetObjects () const
 
virtual const std::string getUnits () const override
 
virtual const CDataObjectgetValueObject () const override
 
virtual CUndoObjectInterfaceinsert (const CData &data) override
 
void objectRenamed (CDataObject *pObject, const std::string &oldName)
 
virtual bool remove (CDataObject *pObject)
 
virtual ~CDataContainer ()
 
- Public Member Functions inherited from CDataObject
void addIssue (const CIssue &issue)
 
void addReference (const CDataContainer *pReference)
 
virtual void calculateValue () override
 
 CDataObject (const CDataObject &src, const CDataContainer *pParent=NULL)
 
virtual void destruct () override
 
virtual CCommonName getCN () const override
 
virtual const CDataObjectgetDataObject () const override
 
virtual const std::string & getKey () const
 
CDataContainergetObjectAncestor (const std::string &type) const
 
CDataModelgetObjectDataModel () const
 
virtual std::string getObjectDisplayName () const override
 
const CObjectInterfacegetObjectFromCN (const CCommonName &cn) const
 
const std::string & getObjectName () const
 
CDataContainergetObjectParent () const
 
const std::string & getObjectType () const
 
virtual const CObjectInterface::ObjectSetgetPrerequisites () const override
 
virtual const CValiditygetValidity () const override
 
virtual void * getValuePointer () const override
 
bool hasFlag (const Flag &flag) const
 
virtual bool isPrerequisiteForContext (const CObjectInterface *pObject, const CCore::SimulationContextFlag &context, const CObjectInterface::ObjectSet &changedObjects) const override
 
bool prerequisitsContains (const DataObjectSet &objects) const
 
virtual void print (std::ostream *ostream) const override
 
void removeIssue (const CIssue &issue)
 
void removeReference (const CDataContainer *pReference)
 
bool setObjectName (const std::string &name)
 
virtual bool setObjectParent (const CDataContainer *pParent)
 
void validityChanged (const CValidity &changedValidity) override
 
void validityRemoved (const CValidity &changedValidity)
 
virtual ~CDataObject ()
 
- Public Member Functions inherited from CObjectInterface
 CObjectInterface ()
 
 CObjectInterface (const CObjectInterface &src)
 
virtual ~CObjectInterface ()
 
- Public Member Functions inherited from CUndoObjectInterface
 CUndoObjectInterface ()
 
 CUndoObjectInterface (const CUndoObjectInterface &src)
 
bool generateUuid ()
 
const xg::Guid & getUuid () const
 
bool setUuid (const std::string &uuid)
 
bool setUuid (const xg::Guid &uuid)
 
virtual void updateIndex (const size_t &index, const CUndoObjectInterface *pUndoObject)
 
virtual ~CUndoObjectInterface ()
 

Static Public Member Functions

static CEvaluationTreecopy (const CEvaluationTree &src)
 
static CEvaluationTreecreate (CEvaluationTree::Type type)
 
static CEvaluationNodefromAST (const ASTNode *pASTNode, bool isFunction)
 
static CEvaluationTreefromData (const CData &data, CUndoObjectInterface *pParent)
 
- Static Public Member Functions inherited from CDataContainer
static CDataContainerfromData (const CData &data, CUndoObjectInterface *pParent)
 
- Static Public Member Functions inherited from CDataObject
static CDataObjectfromData (const CData &data, CUndoObjectInterface *pParent)
 
static void sanitizeObjectName (std::string &name)
 
- Static Public Member Functions inherited from CObjectInterface
static const CDataObjectDataObject (const CObjectInterface *pInterface)
 
static CObjectInterfaceGetObjectFromCN (const ContainerList &listOfContainer, const CCommonName &objName)
 
- Static Public Member Functions inherited from CUndoObjectInterface
template<class CType >
static CType * fromData (const CData &, CUndoObjectInterface *)
 

Static Public Attributes

static const std::string TypeName []
 
static const char * XMLType []
 
- Static Public Attributes inherited from CDataContainer
static const CObjectInterface::ContainerList EmptyList
 

Protected Member Functions

void buildCalculationSequence ()
 
void calculate ()
 
 CEvaluationTree (const CEvaluationTree &src)
 
void clearNodes ()
 
CIssue compileNodes ()
 
CIssue parse ()
 
void setType (const CEvaluationTree::Type &type)
 
- Protected Member Functions inherited from CDataContainer
template<class CType >
CDataMatrixReference< CType > * addMatrixReference (const std::string &name, CType &reference, const CFlags< Flag > &flag=CFlags< Flag >::None)
 
template<class CType >
CDataObjectReference< CType > * addObjectReference (const std::string &name, CType &reference, const CFlags< Flag > &flag=CFlags< Flag >::None)
 
template<class CType >
CDataVectorReference< CType > * addVectorReference (const std::string &name, CType &reference, const CFlags< Flag > &flag=CFlags< Flag >::None)
 
 CDataContainer (const CDataContainer &src)
 
void initObjects ()
 
- Protected Member Functions inherited from CDataObject
 CDataObject ()
 
 CDataObject (const std::string &name, const CDataContainer *pParent=static_cast< CDataContainer * >((void *) 0), const std::string &type="CN", const CFlags< Flag > &flag=CFlags< Flag >::None)
 

Protected Attributes

CVector< CEvaluationNode * > mCalculationSequence
 
std::string mInfix
 
std::vector< CEvaluationNode * > * mpNodeList
 
const C_FLOAT64mpRootValue
 
CEvaluationTree::Type mType
 
C_FLOAT64 mValue
 
- Protected Attributes inherited from CDataContainer
objectMap mObjects
 
- Protected Attributes inherited from CDataObject
ObjectSet mPrerequisits
 
std::set< CDataContainer * > mReferences
 
- Protected Attributes inherited from CObjectInterface
CValidity mValidity
 

Private Member Functions

void initObjects ()
 

Private Attributes

std::string::size_type mErrorPosition
 
CEvaluationNodempRootNode
 

Member Enumeration Documentation

◆ Type

The valid types of a function

Enumerator
Function 
MassAction 
PreDefined 
UserDefined 
Expression 
MathExpression 

Constructor & Destructor Documentation

◆ CEvaluationTree() [1/3]

CEvaluationTree::CEvaluationTree ( const CEvaluationTree src)
protected

◆ CEvaluationTree() [2/3]

CEvaluationTree::CEvaluationTree ( const std::string &  name = "NoName",
const CDataContainer pParent = NO_PARENT,
const Type type = Function 
)

Default constructor

Parameters
conststd::string & name (default: "NoName")
constCDataContainer * pParent (default: NULL)
constCEvaluationTree::Type & type (default: Function)

References initObjects(), and setInfix().

◆ CEvaluationTree() [3/3]

CEvaluationTree::CEvaluationTree ( const CEvaluationTree src,
const CDataContainer pParent 
)

Copy constructor

Parameters
constCEvaluationTree & src
constCDataContainer * pParent (default: NULL)

References initObjects(), mInfix, and setInfix().

◆ ~CEvaluationTree()

CEvaluationTree::~CEvaluationTree ( )
virtual

Destructor

References clearNodes().

Member Function Documentation

◆ applyData()

bool CEvaluationTree::applyData ( const CData data,
CUndoData::CChangeSet changes 
)
virtual

Apply the provided data to the object

Parameters
constCData & data
Returns
bool success

Reimplemented from CDataContainer.

Reimplemented in CFunction.

References CDataContainer::applyData().

Referenced by CFunction::applyData().

◆ buildCalculationSequence()

◆ calculate()

◆ calls()

bool CEvaluationTree::calls ( std::set< std::string > &  list) const

Check whether the evaluation tree calls any tree in the list

Parameters
std::set<std::string > & list
Returns
bool calls

References CEvaluationNode::CALL, CEvaluationNodeCall::calls(), CDataObject::getObjectName(), and mpNodeList.

Referenced by CEvaluationNodeCall::calls(), and hasCircularDependency().

◆ clearNodes()

void CEvaluationTree::clearNodes ( )
protected

Convenient function to free the list of generated nodes.

References mpNodeList, mpRootNode, mpRootValue, mValue, and pdelete.

Referenced by CMathExpression::CMathExpression(), parse(), setRoot(), updateTree(), and ~CEvaluationTree().

◆ compile()

◆ compileNodes()

◆ containsCN()

bool CEvaluationTree::containsCN ( const DataObjectSet elements) const

◆ copy()

CEvaluationTree * CEvaluationTree::copy ( const CEvaluationTree src)
static

Copy an EvaluationTree of the specified type. Note: the returned object has to be released after use with delete.

Parameters
constEvaluationTree & src
Returns
EvaluationTree * pEvaluationTree

References Expression, fatalError, Function, getType(), MassAction, NO_PARENT, PreDefined, and UserDefined.

◆ create()

CEvaluationTree * CEvaluationTree::create ( CEvaluationTree::Type  type)
static

Create an EvaluationTree of the specified type. Note: the returned object has to be released after use with delete.

Parameters
CEvaluationTree::Typetype
Returns
EvaluationTree * pEvaluationTree

References Expression, fatalError, Function, MassAction, PreDefined, setType(), and UserDefined.

Referenced by SBMLImporter::createExpressionFromFunction(), fromData(), SBMLImporter::importEvent(), and FunctionHandler::processStart().

◆ fromAST()

◆ fromData()

CEvaluationTree * CEvaluationTree::fromData ( const CData data,
CUndoObjectInterface pParent 
)
static

Static method to create a CDataObject based on the provided data

Parameters
constCData & data
Returns
CEvaluationTree * pDataObject

References create(), CData::EVALUATION_TREE_TYPE, CData::getProperty(), CData::OBJECT_NAME, CDataObject::setObjectName(), CDataValue::toString(), and CDataValue::toUint().

Referenced by CFunction::fromData().

◆ getErrorPosition()

std::string::size_type CEvaluationTree::getErrorPosition ( ) const

Retrieve the position of the error in the string description. std::string::npos indicates no error.

Returns
std::string::size_type errorPosition

References mErrorPosition.

◆ getInfix()

◆ getNodeList()

◆ getNodeObject()

const CObjectInterface * CEvaluationTree::getNodeObject ( const CCommonName CN) const
virtual

Retrieve a pointer to the object defined by CN. This method may only be called during compile() since the list mpListOfContainer is only valid then.

Parameters
constCCommonName & CN
Returns
const CObjectInterface * value

Reimplemented in CExpression.

References CRootContainer::getFunctionList(), CDataContainer::getObject(), and CDataObject::getObjectFromCN().

Referenced by CEvaluationNodeObject::compile(), and CExpression::getNodeObject().

◆ getRoot() [1/2]

CEvaluationNode * CEvaluationTree::getRoot ( )

Returns the root node of the tree.

References mpRootNode.

Referenced by CMathContainer::addAnalysisObject(), CMathEvent::CTrigger::allocate(), SBMLImporter::applyStoichiometricExpressions(), SBMLImporter::areEqualFunctions(), CSBMLExporter::checkForPiecewiseFunctions(), CSBMLExporter::checkForUnsupportedFunctionCalls(), CFunctionAnalyzer::checkKineticFunction(), CMathExpression::CMathExpression(), CExpression::compile(), CMathEvent::CTrigger::compile(), CMathExpression::convertToInitialExpression(), CMathExpression::copy(), CMathContainer::copyBranch(), SBMLImporter::createCFunctionFromFunctionTree(), CFunction::createCopy(), SBMLImporter::createCReactionFromReaction(), CMathContainer::createDiscontinuityEvents(), CSBMLExporter::createEvent(), SBMLImporter::createExpressionFromFunction(), CSBMLExporter::createInitialAssignment(), CKinFunction::createParameters(), CSBMLExporter::createRule(), CDerive::deriveBranch(), CFunctionAnalyzer::evaluateNode(), CSBMLExporter::exportEventAssignments(), CODEExporter::exportKineticFunction(), CODEExporterC::exportKineticFunctionGroup(), CODEExporter::exportModelEntityExpression(), CODEExporter::exportModelValuesExpressions(), CODEExporter::exportSingleFunction(), CODEExporterC::exportSingleFunction(), SBMLImporter::findCorrespondingFunction(), SBMLImporter::findFunctionCalls(), CODEExporter::findFunctionsCalls(), CSBMLExporter::findUsedFunctions(), CExpression::getBerkeleyMadonnaString(), CExpression::getCCodeString(), CODEExporterBM::getDisplayExpressionString(), CODEExporterC::getDisplayExpressionString(), CODEExporterXPPAUT::getDisplayExpressionString(), CODEExporterBM::getDisplayFunctionString(), CODEExporterXPPAUT::getDisplayFunctionString(), CUnitValidator::getUnit(), CUnitValidator::getUnits(), CExpression::getXPPString(), SBMLImporter::importEvent(), SBMLImporter::importInitialAssignments(), SBMLImporter::importRuleForModelEntity(), CMathDerive::initOneVar(), SBMLImporter::isConstantFlux(), CSBMLExporter::isEventAssignmentSBMLCompatible(), CSBMLExporter::isEventSBMLCompatible(), CSBMLExporter::isExpressionSBMLCompatible(), SBMLImporter::isMassAction(), SBMLImporter::isMassActionFunction(), CSBMLExporter::isModelSBMLCompatible(), CMathObject::isPrerequisiteForContext(), CODEExporter::modifyTreeForMassAction(), CSBMLExporter::orderRules(), CModel::prepareElasticity(), CODEExporterC::preprocess(), CMathExpression::relocate(), SBMLImporter::removeUnusedFunctions(), CODEExporterC::setExportNameOfFunction(), CReaction::setFunctionFromExpressionTree(), CExpression::setInfix(), CUnitValidator::setUnits(), CFunction::splitFunction(), CExpression::updateInfix(), CModelParameter::updateModel(), CUnitValidator::validate(), CFunction::writeMathML(), and CExpression::writeMathML().

◆ getRoot() [2/2]

const CEvaluationNode * CEvaluationTree::getRoot ( ) const

Returns the root node of the tree.

References mpRootNode.

◆ getType()

◆ getVariableIndex()

size_t CEvaluationTree::getVariableIndex ( const std::string &  name) const
virtual

Retrieve the index to the value of the named variable.

Parameters
conststd::string & name
Returns
size_t

Reimplemented in CFunction.

References C_INVALID_INDEX.

Referenced by CEvaluationNodeVariable::compile().

◆ getVariableValue()

const C_FLOAT64 & CEvaluationTree::getVariableValue ( const size_t &  index) const
virtual

Retrieve the value of the indexed variable

Parameters
constsize_t & index
Returns
const C_FLOAT64 & variableValue

Reimplemented in CFunction.

References C_FLOAT64.

Referenced by CEvaluationNodeVariable::calculate().

◆ hasCircularDependency()

bool CEvaluationTree::hasCircularDependency ( ) const

Check whether the the tree has circular dependencies.

Returns
bool hasCircularDependency

References calls().

Referenced by parse().

◆ hasDiscontinuity()

◆ initObjects()

void CEvaluationTree::initObjects ( )
private

Initialize the contained CDataObjects

References CDataContainer::addObjectReference(), and mValue.

Referenced by CEvaluationTree().

◆ isBoolean()

bool CEvaluationTree::isBoolean ( ) const

Check whether this function evaluates to a boolean value.

Returns
bool isBoolean

References CEvaluationNode::isBoolean(), and mpRootNode.

Referenced by CEvaluationNodeCall::compile(), CEvaluationNodeCall::isBoolean(), CMathDelay::modifyMathObject(), CExpression::setInfix(), and CExpression::setIsBoolean().

◆ mapObjectNodes()

◆ operator==()

bool CEvaluationTree::operator== ( const CEvaluationTree rhs) const

Comparison operator

Parameters
constCEvaluationTree & rhs
Returns
bool equal

References mInfix, and mType.

◆ parse()

◆ setInfix()

◆ setRoot()

◆ setTree()

◆ setType()

void CEvaluationTree::setType ( const CEvaluationTree::Type type)
protected

Set the type of the function

Parameters
constCEvaluationTree::Type & type

References mType.

Referenced by create(), and CFunction::load().

◆ size()

size_t CEvaluationTree::size ( ) const

Retrieve the number of node evaluations required to computate the value of the tree.

Returns
size_t size

References mCalculationSequence, and CVectorCore< CType >::size().

Referenced by SBMLImporter::findCorrespondingFunction(), and CModelMerging::mergeMetabolites().

◆ toAST()

ASTNode * CEvaluationTree::toAST ( const CDataModel pDataModel) const
virtual

Converts a CEvaluationTree to an ASTNode based tree.

Returns
ASTNode* root node of the tree.

References mpRootNode, and CEvaluationNode::toAST().

◆ toData()

CData CEvaluationTree::toData ( ) const
virtual

Retrieve the data describing the object

Returns
CData data

Reimplemented from CDataContainer.

Reimplemented in CFunction.

References CDataContainer::toData().

Referenced by CFunction::toData().

◆ updateTree()

Member Data Documentation

◆ mCalculationSequence

CVector< CEvaluationNode * > CEvaluationTree::mCalculationSequence
protected

A vector of nodes which need to be calculated in sequence

Referenced by buildCalculationSequence(), calculate(), CMathExpression::compile(), compileNodes(), mapObjectNodes(), and size().

◆ mErrorPosition

std::string::size_type CEvaluationTree::mErrorPosition
private

The error position in case the compilation fails. std::string::npos indicates no error.

Referenced by compileNodes(), getErrorPosition(), and parse().

◆ mInfix

◆ mpNodeList

◆ mpRootNode

CEvaluationNode* CEvaluationTree::mpRootNode
private

◆ mpRootValue

◆ mType

CEvaluationTree::Type CEvaluationTree::mType
protected

The type of the function

Referenced by getType(), CFunction::isReadOnly(), operator==(), parse(), and setType().

◆ mValue

◆ TypeName

const std::string CEvaluationTree::TypeName
static
Initial value:
=
{
"userdefined",
"predefined",
"predefined",
"userdefined",
"userdefined",
"userdefined",
"internal",
""
}

The string representation of valid types of a function

◆ XMLType

const char * CEvaluationTree::XMLType
static
Initial value:
=
{
"Function",
"MassAction",
"PreDefined",
"UserDefined",
"Expression",
"Boolean",
"MathExpression",
NULL
}

The string representation of valid types of a function

Referenced by FunctionHandler::processStart(), and CCopasiXML::saveFunctionList().


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