15 #include <sbml/math/ASTNode.h>
33 mpCallParameters(NULL),
34 mQuotesRequired(false),
35 mBooleanRequired(false),
36 mRegisteredFunctionCN()
45 mpCallParameters(NULL),
46 mQuotesRequired(false),
47 mBooleanRequired(false),
48 mRegisteredFunctionCN()
80 mpFunction(src.mpFunction),
81 mpExpression(src.mpExpression),
82 mCallNodes(src.mCallNodes),
83 mpCallParameters(NULL),
84 mQuotesRequired(src.mQuotesRequired),
85 mBooleanRequired(src.mBooleanRequired),
86 mRegisteredFunctionCN(src.mRegisteredFunctionCN)
93 switch (
mType & 0x00FFFFFF)
104 mValue = std::numeric_limits<C_FLOAT64>::quiet_NaN();
121 switch (
mType & 0x00FFFFFF)
125 if (pObjectInterface != NULL)
148 if (pObjectInterface != NULL)
162 if (pObjectInterface != NULL)
183 success =
mpExpression->
compile(static_cast<const CExpression *>(pTree)->getListOfContainer());
198 if (list.count(
mData))
return true;
203 if (pTree)
return pTree->
calls(list);
271 Infix =
"\"" +
quote(Data,
"-+^*/%(){},\t\r\n\"") +
"\"(";
275 Infix =
quote(Data,
"-+^*/%(){},\t\r\n") +
"(";
278 switch (
mType & 0x00FFFFFF)
282 std::vector< std::string >::const_iterator it = children.begin();
283 std::vector< std::string>::const_iterator end = children.end();
285 if (it != end) Infix += *it++;
287 for (; it != end; ++it)
307 std::string DisplayString;
311 DisplayString =
"\"" +
quote(
mData,
"-+^*/%(){},\t\r\n\"") +
"\"(";
315 DisplayString =
quote(
mData,
"-+^*/%(){},\t\r\n") +
"(";
318 switch (
mType & 0x00FFFFFF)
322 std::vector< std::string >::const_iterator it = children.begin();
323 std::vector< std::string >::const_iterator end = children.end();
325 if (it != end) DisplayString += *it++;
327 for (; it != end; ++it)
328 DisplayString +=
"," + *it;
341 return DisplayString +
")";
347 std::string DisplayString;
358 DisplayString =
"\"" +
quote(Data,
"-+^*/%(){},\t\r\n\"") +
"\"(";
362 DisplayString =
quote(Data,
"-+^*/%(){},\t\r\n") +
"(";
365 switch (
mType & 0x00FFFFFF)
370 std::vector< std::string >::const_iterator it = children.begin();
371 std::vector< std::string >::const_iterator end = children.end();
373 if (it != end) DisplayString += *it++;
375 for (; it != end; ++it)
376 DisplayString +=
"," + *it;
389 return DisplayString +
")";
395 std::string DisplayString;
399 DisplayString =
"\"" +
quote(
mData,
"-+^*/%(){},\t\r\n\"") +
"\"(";
403 DisplayString =
quote(
mData,
"-+^*/%(){},\t\r\n") +
"(";
406 return DisplayString;
412 std::string DisplayString;
416 DisplayString =
"\"" +
quote(
mData,
"-+^*/%(){},\t\r\n\"") +
"\"(";
420 DisplayString =
quote(
mData,
"-+^*/%(){},\t\r\n") +
"(";
423 return DisplayString;
429 assert(pASTNode->getNumChildren() == children.size());
432 std::string data = pASTNode->getName();
443 ASTNode* pNode = NULL;
445 pNode =
new ASTNode(AST_FUNCTION);
446 const std::string funName = this->
getData();
448 assert(pFun != NULL);
452 pNode->setName(pFun->
getSBMLId().c_str());
472 mCallNodes.push_back(static_cast<CEvaluationNode *>(pChild));
476 std::vector<CEvaluationNode *>::iterator it =
mCallNodes.begin();
480 std::vector<CEvaluationNode *>::iterator end =
mCallNodes.end();
482 while (it != end && *it != pAfter) ++it;
485 mCallNodes.insert(it, static_cast<CEvaluationNode *>(pChild));
492 std::vector<CEvaluationNode *>::iterator it =
mCallNodes.begin();
493 std::vector<CEvaluationNode *>::iterator end =
mCallNodes.end();
495 while (it != end && *it != pChild) ++it;
505 std::vector<CEvaluationNode *>::const_iterator it = vector.begin();
506 std::vector<CEvaluationNode *>::const_iterator end = vector.end();
512 for (i = 0; it != end; ++it, i++)
515 (*pCallParameters)[i].vector =
buildParameters(static_cast<const CEvaluationNodeVector *>(*it)->getVector());
517 (*pCallParameters)[i].value = (*it)->getValuePointer();
520 return pCallParameters;
525 const std::vector<CEvaluationNode *> & vector)
527 if (!pCallParameters)
return;
529 std::vector<CEvaluationNode *>::const_iterator it = vector.begin();
530 std::vector<CEvaluationNode *>::const_iterator end = vector.end();
534 for (i = 0; it != end; ++it, i++)
538 static_cast<const CEvaluationNodeVector *>(*it)->getVector());
541 delete pCallParameters;
549 if (vector.size() != functionParameters.
size())
return false;
551 std::vector<CEvaluationNode *>::const_iterator it = vector.begin();
552 std::vector<CEvaluationNode *>::const_iterator end = vector.end();
556 for (i = 0; it != end; ++it, i++)
569 switch (
mType & 0x00FFFFFF)
585 const std::vector< std::vector< std::string > > & )
const
587 std::ostringstream out;
589 std::vector< std::string >::const_iterator it = children.begin();
590 std::vector< std::string >::const_iterator end = children.end();
592 switch (
mType & 0x00FFFFFF)
599 out <<
"<mrow>" << std::endl;
605 Data =
"\"" +
quote(Data,
"-+^*/%(){},\t\r\n\"") +
"\"";
609 out <<
"<mrow>" << std::endl;
610 out <<
"<mo>(</mo>" << std::endl;
611 out <<
"<mrow>" << std::endl;
618 for (; it != end; ++it)
620 out <<
"<mo> , </mo>" << std::endl;
624 out <<
"</mrow>" << std::endl;
625 out <<
"<mo>) </mo>" << std::endl;
627 out <<
"</mrow>" << std::endl;
628 out <<
"</mrow>" << std::endl;
632 std::vector< std::vector< std::string > > Variables;
634 for (; it != end; ++it)
636 std::vector< std::string > Variable;
637 Variable.push_back(*it);
638 Variables.push_back(Variable);
641 out <<
"<mfenced>" << std::endl;
643 out <<
"</mfenced>" << std::endl;
669 if (pEvaluationTree != NULL)
std::string unQuote(const std::string &name)
Header file of class CExpression.
virtual ASTNode * toAST(const CCopasiDataModel *pDataModel) const
static void clearParameters(CCallParameters< C_FLOAT64 > *pCallParameters, const std::vector< CEvaluationNode * > &vector)
const CEvaluationTree * getCalledTree() const
virtual bool addChild(CCopasiNode< Data > *pChild, CCopasiNode< Data > *pAfter=NULL)
virtual std::string getDisplayString(const std::vector< std::string > &children) const
static bool verifyParameters(const std::vector< CEvaluationNode * > &vector, const CFunctionParameters &functionParameters)
CCopasiNode< Data > * getSibling()
virtual std::string getBerkeleyMadonnaString(const std::vector< std::string > &children) const
virtual CCopasiObjectName getCN() const
const std::string & getObjectName() const
static CEvaluationNode * fromAST(const ASTNode *pASTNode, const std::vector< CEvaluationNode * > &children)
static CCallParameters< C_FLOAT64 > * buildParameters(const std::vector< CEvaluationNode * > &vector)
virtual bool compile(const CEvaluationTree *pTree)
bool calls(std::set< std::string > &list) const
static std::string fixName(const std::string &name)
const Type & getType() const
const bool & isBooleanRequired() const
virtual bool compile(std::vector< CCopasiContainer * > listOfContainer=CCopasiContainer::EmptyList)
virtual std::string getCCodeString(const std::vector< std::string > &children) const
virtual ASTNode * toAST(const CCopasiDataModel *pDataModel) const
static bool isKeyword(const std::string &str)
virtual std::string getInfix(const std::vector< std::string > &children) const
void addChildren(const std::vector< CEvaluationNode * > &children)
static Type type(const Type &type)
#define PRECEDENCE_FUNCTION
virtual const Data & getData() const
virtual ~CEvaluationNodeCall()
virtual const C_FLOAT64 & calcValue()
virtual bool addChild(CCopasiNode< Data > *pChild, CCopasiNode< Data > *pAfter=NULL)
CCallParameters< C_FLOAT64 > * mpCallParameters
virtual void writeMathML(std::ostream &out, size_t l=0) const
void setBooleanRequired(const bool &booleanRequired)
virtual bool removeChild(CCopasiNode< Data > *pChild)
static CFunctionDB * getFunctionList()
virtual const C_FLOAT64 & calcValue(const CCallParameters< C_FLOAT64 > &callParameters)
std::string quote(const std::string &name, const std::string &additionalEscapes)
virtual bool setData(const Data &data)
static Type subType(const Type &type)
virtual std::string getMMLString(const std::vector< std::string > &children, bool expand, const std::vector< std::vector< std::string > > &variables) const
class CEvaluationNode::CPrecedence mPrecedence
const std::string & getSBMLId() const
CExpression * mpExpression
The class for handling a chemical kinetic function.
virtual bool removeChild(CCopasiNode< Data > *pChild)
virtual bool isBoolean() const
#define PRECEDENCE_NUMBER
virtual const CObjectInterface * getObject(const CCopasiObjectName &cn) const
virtual std::string getXPPString(const std::vector< std::string > &children) const
CCopasiNode< Data > * getChild()
static const CCopasiContainer * getRoot()
bool calls(std::set< std::string > &list) const
CFunction * findFunction(const std::string &functionName)
CFunctionParameters & getVariables()
CRegisteredObjectName mRegisteredFunctionCN
std::vector< CEvaluationNode * > mCallNodes