本文整理汇总了C++中CEvaluationNode::subType方法的典型用法代码示例。如果您正苦于以下问题:C++ CEvaluationNode::subType方法的具体用法?C++ CEvaluationNode::subType怎么用?C++ CEvaluationNode::subType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CEvaluationNode
的用法示例。
在下文中一共展示了CEvaluationNode::subType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mainType
bool CEvaluationNode::operator<(const CEvaluationNode& right) const
{
if (mainType() != right.mainType())
{
return mainType() < right.mainType();
}
if (subType() != right.subType())
{
return subType() < right.subType();
}
switch (mainType())
{
case T_CONSTANT:
case T_NUMBER:
case T_OBJECT:
case T_CALL:
case T_STRUCTURE:
case T_VARIABLE:
case T_WHITESPACE:
return getData() < right.getData();
break;
case T_OPERATOR:
case T_FUNCTION:
case T_CHOICE:
case T_LOGICAL:
case T_MV_FUNCTION:
case T_VECTOR:
case T_DELAY:
case T_INVALID:
break;
}
const CEvaluationNode* pChild1 = dynamic_cast<const CEvaluationNode*>(this->getChild());
const CEvaluationNode* pChild2 = dynamic_cast<const CEvaluationNode*>(right.getChild());
while (true)
{
if (pChild1 == NULL || pChild2 == NULL)
{
return pChild1 < pChild2;
}
if (*pChild1 < *pChild2) return true;
pChild1 = dynamic_cast<const CEvaluationNode*>(pChild1->getSibling());
pChild2 = dynamic_cast<const CEvaluationNode*>(pChild2->getSibling());
}
return false;
}
示例2: test_copasi_function_expansion
void test_compare_utilities::test_copasi_function_expansion()
{
CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;;
std::istringstream iss(test_compare_utilities::MODEL_STRING1);
CPPUNIT_ASSERT(load_cps_model_from_stream(iss, *pDataModel) == true);
CFunctionDB* pFunctionDB = CCopasiRootContainer::getFunctionList();
// function_5
CEvaluationTree* pTree = pFunctionDB->findFunction("function_4");
CPPUNIT_ASSERT(pTree != NULL);
// generate a call node
CFunction* pFunction = dynamic_cast<CFunction*>(pTree);
CPPUNIT_ASSERT(pFunction != NULL);
CEvaluationNodeCall* pCallNode = new CEvaluationNodeCall(CEvaluationNode::S_FUNCTION, pFunction->getObjectName());
CPPUNIT_ASSERT(pCallNode != NULL);
CFunctionParameters* pFunctionParameters = &pFunction->getVariables();
unsigned int i = 0, iMax = pFunctionParameters->size();
while (i < iMax)
{
CFunctionParameter* pParameter = (*pFunctionParameters)[i];
CPPUNIT_ASSERT(pParameter != NULL);
CEvaluationNodeVariable* pVariableNode = new CEvaluationNodeVariable(CEvaluationNode::S_DEFAULT, pParameter->getObjectName());
pCallNode->addChild(pVariableNode);
++i;
}
CEvaluationNode* pExpanded = expand_function_calls(pCallNode, pFunctionDB);
delete pCallNode;
CPPUNIT_ASSERT(pExpanded != NULL);
CPPUNIT_ASSERT(pExpanded->mainType() == CEvaluationNode::T_OPERATOR);
CPPUNIT_ASSERT(pExpanded->subType() == CEvaluationNode::S_DIVIDE);
CEvaluationNode* pChild = dynamic_cast<CEvaluationNode*>(pExpanded->getChild());
CPPUNIT_ASSERT(pChild != NULL);
CPPUNIT_ASSERT(pChild->mainType() == CEvaluationNode::T_OPERATOR);
CPPUNIT_ASSERT(pChild->subType() == CEvaluationNode::S_PLUS);
pChild = dynamic_cast<CEvaluationNode*>(pChild->getChild());
CPPUNIT_ASSERT(pChild != NULL);
CPPUNIT_ASSERT(pChild->mainType() == CEvaluationNode::T_VARIABLE);
CPPUNIT_ASSERT(pChild->getData() == std::string("y"));
pChild = dynamic_cast<CEvaluationNode*>(pChild->getSibling());
CPPUNIT_ASSERT(pChild != NULL);
CPPUNIT_ASSERT(pChild->mainType() == CEvaluationNode::T_VARIABLE);
CPPUNIT_ASSERT(pChild->getData() == std::string("x"));
CPPUNIT_ASSERT(pChild->getSibling() == NULL);
pChild = dynamic_cast<CEvaluationNode*>(pExpanded->getChild()->getSibling());
CPPUNIT_ASSERT(pChild != NULL);
CPPUNIT_ASSERT(pChild->mainType() == CEvaluationNode::T_NUMBER);
CPPUNIT_ASSERT(pChild->subType() == CEvaluationNode::S_DOUBLE);
CPPUNIT_ASSERT((fabs(pChild->getValue() - 2.0) / 2.0) < 1e-6);
CPPUNIT_ASSERT(pChild->getSibling() == NULL);
delete pExpanded;
// function_5
pTree = pFunctionDB->findFunction("function_5");
CPPUNIT_ASSERT(pTree != NULL);
// generate a call node
pFunction = dynamic_cast<CFunction*>(pTree);
CPPUNIT_ASSERT(pFunction != NULL);
pCallNode = new CEvaluationNodeCall(CEvaluationNode::S_FUNCTION, pFunction->getObjectName());
CPPUNIT_ASSERT(pCallNode != NULL);
pFunctionParameters = &pFunction->getVariables();
i = 0, iMax = pFunctionParameters->size();
while (i < iMax)
{
CFunctionParameter* pParameter = (*pFunctionParameters)[i];
CPPUNIT_ASSERT(pParameter != NULL);
CEvaluationNodeVariable* pVariableNode = new CEvaluationNodeVariable(CEvaluationNode::S_DEFAULT, pParameter->getObjectName());
pCallNode->addChild(pVariableNode);
++i;
}
pExpanded = expand_function_calls(pCallNode, pFunctionDB);
delete pCallNode;
CPPUNIT_ASSERT(pExpanded != NULL);
CPPUNIT_ASSERT(pExpanded->mainType() == CEvaluationNode::T_OPERATOR);
CPPUNIT_ASSERT(pExpanded->subType() == CEvaluationNode::S_PLUS);
pChild = dynamic_cast<CEvaluationNode*>(pExpanded->getChild());
CPPUNIT_ASSERT(pChild != NULL);
CPPUNIT_ASSERT(pChild->mainType() == CEvaluationNode::T_OPERATOR);
CPPUNIT_ASSERT(pChild->subType() == CEvaluationNode::S_MINUS);
pChild = dynamic_cast<CEvaluationNode*>(pChild->getChild());
CPPUNIT_ASSERT(pChild != NULL);
CPPUNIT_ASSERT(pChild->mainType() == CEvaluationNode::T_VARIABLE);
CPPUNIT_ASSERT(pChild->getData() == std::string("a"));
pChild = dynamic_cast<CEvaluationNode*>(pChild->getSibling());
CPPUNIT_ASSERT(pChild != NULL);
CPPUNIT_ASSERT(pChild->mainType() == CEvaluationNode::T_OPERATOR);
CPPUNIT_ASSERT(pChild->subType() == CEvaluationNode::S_MULTIPLY);
CPPUNIT_ASSERT(pChild->getSibling() == NULL);
pChild = dynamic_cast<CEvaluationNode*>(pChild->getChild());
CPPUNIT_ASSERT(pChild != NULL);
CPPUNIT_ASSERT(pChild->mainType() == CEvaluationNode::T_VARIABLE);
CPPUNIT_ASSERT(pChild->getData() == std::string("c"));
pChild = dynamic_cast<CEvaluationNode*>(pChild->getSibling());
CPPUNIT_ASSERT(pChild != NULL);
CPPUNIT_ASSERT(pChild->mainType() == CEvaluationNode::T_NUMBER);
CPPUNIT_ASSERT(pChild->subType() == CEvaluationNode::S_DOUBLE);
CPPUNIT_ASSERT((fabs(pChild->getValue() - 1.3) / 1.3) < 1e-6);
CPPUNIT_ASSERT(pChild->getSibling() == NULL);
//.........这里部分代码省略.........