30 #include "sbml/math/ASTNode.h"
105 pNew =
new CFunction(*static_cast<const CFunction *>(&src));
109 pNew =
new CMassAction(*static_cast<const CMassAction *>(&src));
114 pNew =
new CKinFunction(*static_cast<const CKinFunction *>(&src));
118 pNew =
new CExpression(*static_cast<const CExpression *>(&src));
136 mErrorPosition(std::string::npos),
139 mValue(std::numeric_limits<
C_FLOAT64>::quiet_NaN()),
140 mCalculationSequence()
152 mErrorPosition(std::string::npos),
156 mCalculationSequence()
178 infix !=
"")
return true;
212 static C_FLOAT64 Value = std::numeric_limits<C_FLOAT64>::quiet_NaN();
229 mpNodeList =
new std::vector< CEvaluationNode * >;
236 std::istringstream buffer(
mInfix);
239 success = (Parser.
yyparse() == 0);
281 while (itNode.
next() != itNode.
end())
313 while (itNode.
next() != itNode.
end())
322 pErrorNode = *itNode;
328 std::vector< CEvaluationNode * >::iterator it;
329 std::vector< CEvaluationNode * >::iterator end =
mpNodeList->end();
334 for (it =
mpNodeList->begin(); it != end; ++it)
336 if (*it == pErrorNode)
345 for (it =
mpNodeList->begin(); it != end; ++it)
355 for (it =
mpNodeList->begin(); it != end; ++it)
356 switch ((*it)->getType() & 0xFF000000)
361 (pObject = static_cast< CEvaluationNodeObject *>(*it)->getObjectInterfacePtr()) != NULL)
365 if (pDataObject == NULL)
369 if (pMathObject != NULL)
403 for (; it != end; ++it)
412 mValue = std::numeric_limits< C_FLOAT64 >::quiet_NaN();
418 mValue = std::numeric_limits<C_FLOAT64>::quiet_NaN();
424 if (pRootNode == NULL)
return false;
433 mpNodeList =
new std::vector< CEvaluationNode * >();
450 mpNodeList =
new std::vector< CEvaluationNode * >;
459 for (; it != end; ++it)
474 if (pASTNode == NULL)
return NULL;
479 while (itNode.
next() != itNode.
end())
485 switch (itNode->getType())
496 case AST_FUNCTION_POWER:
511 #if LIBSBML_VERSION >= 40100
512 case AST_NAME_AVOGADRO:
513 #endif // LIBSBML_VERSION >= 40100
519 case AST_CONSTANT_PI:
520 case AST_CONSTANT_FALSE:
521 case AST_CONSTANT_TRUE:
531 case AST_FUNCTION_DELAY:
536 case AST_FUNCTION_ABS:
537 case AST_FUNCTION_ARCCOS:
538 case AST_FUNCTION_ARCCOSH:
539 case AST_FUNCTION_ARCCOT:
540 case AST_FUNCTION_ARCCOTH:
541 case AST_FUNCTION_ARCCSC:
542 case AST_FUNCTION_ARCCSCH:
543 case AST_FUNCTION_ARCSEC:
544 case AST_FUNCTION_ARCSECH:
545 case AST_FUNCTION_ARCSIN:
546 case AST_FUNCTION_ARCSINH:
547 case AST_FUNCTION_ARCTAN:
548 case AST_FUNCTION_ARCTANH:
549 case AST_FUNCTION_CEILING:
550 case AST_FUNCTION_COS:
551 case AST_FUNCTION_COSH:
552 case AST_FUNCTION_COT:
553 case AST_FUNCTION_COTH:
554 case AST_FUNCTION_CSC:
555 case AST_FUNCTION_CSCH:
556 case AST_FUNCTION_EXP:
557 case AST_FUNCTION_FACTORIAL:
558 case AST_FUNCTION_FLOOR:
559 case AST_FUNCTION_LN:
560 case AST_FUNCTION_LOG:
561 case AST_FUNCTION_ROOT:
562 case AST_FUNCTION_SEC:
563 case AST_FUNCTION_SECH:
564 case AST_FUNCTION_SIN:
565 case AST_FUNCTION_SINH:
566 case AST_FUNCTION_TAN:
567 case AST_FUNCTION_TANH:
568 case AST_LOGICAL_NOT:
572 case AST_LOGICAL_AND:
574 case AST_LOGICAL_XOR:
575 case AST_RELATIONAL_EQ:
576 case AST_RELATIONAL_GEQ:
577 case AST_RELATIONAL_GT:
578 case AST_RELATIONAL_LEQ:
579 case AST_RELATIONAL_LT:
580 case AST_RELATIONAL_NEQ:
584 case AST_FUNCTION_PIECEWISE:
617 std::set< const CCopasiObject * > Self;
630 Deleted.insert(
this);
643 std::set< std::string > List;
652 std::vector< CEvaluationNode * >::const_iterator it =
mpNodeList->begin();
653 std::vector< CEvaluationNode * >::const_iterator end =
mpNodeList->end();
655 for (; it != end; ++it)
657 (*it)->getData() == name)
667 std::pair<std::set< std::string >::iterator,
bool> Result = list.insert(
getObjectName());
669 if (!Result.second)
return true;
672 std::vector< CEvaluationNode * >::iterator it;
673 std::vector< CEvaluationNode * >::iterator end =
mpNodeList->end();
675 for (it =
mpNodeList->begin(); it != end; ++it)
677 dynamic_cast<CEvaluationNodeCall *>(*it)->calls(list))
683 list.erase(Result.first);
693 std::vector< CEvaluationNode * >::iterator it =
mpNodeList->begin();
694 std::vector< CEvaluationNode * >::iterator end =
mpNodeList->end();
696 for (; it != end; ++it)
698 switch ((
int)(*it)->getType())
712 if (static_cast< CEvaluationNodeCall * >(*it)->getCalledTree()->hasDiscontinuity())
Header file of class CExpression.
void setType(const CEvaluationTree::Type &type)
size_t getErrorPosition()
virtual bool setRoot(CEvaluationNode *pRootNode)
virtual ASTNode * toAST(const CCopasiDataModel *pDataModel) const
static CEvaluationNode * fromAST(const ASTNode *pASTNode, const std::vector< CEvaluationNode * > &children)
void clearDirectDependencies()
virtual ~CEvaluationTree()
static CEvaluationNode * fromAST(const ASTNode *pASTNode, const std::vector< CEvaluationNode * > &children)
std::vector< CEvaluationNode * > * mpNodeList
const std::string & getObjectName() const
static CEvaluationNode * fromAST(const ASTNode *pASTNode, const std::vector< CEvaluationNode * > &children)
static CEvaluationNode * fromAST(const ASTNode *pASTNode, const std::vector< CEvaluationNode * > &children)
virtual size_t getVariableIndex(const std::string &name) const
const C_FLOAT64 & getValue() const
bool hasDiscontinuity() const
const Type & getType() const
void setDirectDependencies(const DataObjectSet &directDependencies)
static CEvaluationNode * fromAST(const ASTNode *pASTNode, const std::vector< CEvaluationNode * > &children)
std::string buildInfix() const
const CEvaluationTree::Type & getType() const
virtual ASTNode * toAST(const CCopasiDataModel *pDataModel) const
static CEvaluationNode * fromAST(const ASTNode *pASTNode, const std::vector< CEvaluationNode * > &children)
const CNodeIteratorMode::State & next()
static const std::string TypeName[]
std::vector< CEvaluationNode * > mCalculationSequence
static CEvaluationNode * fromAST(const ASTNode *pASTNode)
static CEvaluationNode * fromAST(const ASTNode *pASTNode, const std::vector< CEvaluationNode * > &children)
virtual const C_FLOAT64 & getVariableValue(const size_t &index) const
void buildCalculationSequence()
static CEvaluationNode * fromAST(const ASTNode *pASTNode, const std::vector< CEvaluationNode * > &children)
static Type type(const Type &type)
void addDirectDependency(const CCopasiObject *pObject)
std::string::size_type getErrorPosition() const
bool dependsOnTree(const std::string &name) const
static CEvaluationTree * copy(const CEvaluationTree &src)
bool operator==(const CEvaluationTree &rhs) const
Context * parentContextPtr()
CCopasiObject::DataObjectSet getDeletedObjects() const
bool setTree(const ASTNode &pRootNode)
CEvaluationNode * getRootNode()
virtual bool isBoolean() const
CCopasiNode< Data > * getParent()
virtual bool compile(const CEvaluationTree *pTree)
The class for handling a chemical kinetic function.
std::string::size_type mErrorPosition
static const char * XMLType[]
static void freeNodeList(std::vector< CEvaluationNode * > *pNodeList)
virtual const CObjectInterface * getObject(const CCopasiObjectName &cn) const
CNodeIteratorMode::State end() const
bool calls(std::set< std::string > &list) const
static CEvaluationNode * fromAST(const ASTNode *pASTNode, const std::vector< CEvaluationNode * > &children)
std::set< const CCopasiObject * > DataObjectSet
const std::vector< CEvaluationNode * > & getNodeList() const
CEvaluationTree(const std::string &name="NoName", const CCopasiContainer *pParent=NULL, const Type &type=Function)
CCopasiObject * addObjectReference(const std::string &name, CType &reference, const unsigned C_INT32 &flag=0)
bool hasCircularDependency() const
CEvaluationNode * getRoot()
const std::string & getInfix() const
virtual bool setInfix(const std::string &infix)
const CCopasiObject * getDataObject() const
std::vector< CEvaluationNode * > * getNodeList()
CEvaluationTree::Type mType
static CEvaluationTree * create(CEvaluationTree::Type type)