本文整理汇总了C++中ASTNode::setName方法的典型用法代码示例。如果您正苦于以下问题:C++ ASTNode::setName方法的具体用法?C++ ASTNode::setName怎么用?C++ ASTNode::setName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ASTNode
的用法示例。
在下文中一共展示了ASTNode::setName方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ASTNode
END_TEST
START_TEST (test_MathMLFromAST_scalarproduct)
{
const char* expected = wrapMathML
(
" <apply>\n"
" <scalarproduct/>\n"
" <ci> y </ci>\n"
" <ci> z </ci>\n"
" </apply>\n"
);
ASTNode * y = new ASTNode(AST_NAME);
fail_unless(y->setName("y") == LIBSBML_OPERATION_SUCCESS);
ASTNode * z = new ASTNode(AST_NAME);
fail_unless(z->setName("z") == LIBSBML_OPERATION_SUCCESS);
N = new ASTNode(AST_LINEAR_ALGEBRA_SCALAR_PRODUCT);
fail_unless( N->getPackageName() == "arrays");
fail_unless(N->addChild(y) == LIBSBML_OPERATION_SUCCESS);
fail_unless(N->addChild(z) == LIBSBML_OPERATION_SUCCESS);
S = writeMathMLToString(N);
fail_unless( equals(expected, S) );
}
示例2: ASTNode
END_TEST
START_TEST (test_MathMLFromAST_plus_nary_4)
{
const char* expected = wrapMathML
(
" <apply>\n"
" <plus/>\n"
" <cn type=\"integer\"> 1 </cn>\n"
" <cn type=\"integer\"> 2 </cn>\n"
" <apply>\n"
" <times/>\n"
" <ci> x </ci>\n"
" <ci> y </ci>\n"
" <ci> z </ci>\n"
" </apply>\n"
" <cn type=\"integer\"> 3 </cn>\n"
" </apply>\n"
);
// N = SBML_parseFormula("1 + 2 + x * y * z + 3");
N = new ASTNode(AST_PLUS);
ASTNode *c1 = new ASTNode(AST_INTEGER);
c1->setValue(1);
ASTNode *c2 = new ASTNode(AST_INTEGER);
c2->setValue(2);
ASTNode *c3 = new ASTNode(AST_INTEGER);
c3->setValue(3);
ASTNode *cx = new ASTNode(AST_NAME);
cx->setName("x");
ASTNode *cy = new ASTNode(AST_NAME);
cy->setName("y");
ASTNode *cz = new ASTNode(AST_NAME);
cz->setName("z");
ASTNode *times = new ASTNode(AST_TIMES);
times->addChild(cx);
times->addChild(cy);
times->addChild(cz);
N->addChild(c1);
N->addChild(c2);
N->addChild(times);
N->addChild(c3);
S = writeMathMLToString(N);
fail_unless( equals(expected, S) );
}
示例3: toAST
ASTNode* CEvaluationNodeVariable::toAST(const CCopasiDataModel* /*pDataModel*/) const
{
ASTNode* node = new ASTNode();
node->setType(AST_NAME);
node->setName(this->getData().c_str());
return node;
}
示例4: ASTNode
END_TEST
START_TEST (test_getUnitDefinition_power_one_child)
{
ASTNode * node = new ASTNode(AST_POWER);
ASTNode * c = new ASTNode(AST_NAME);
c->setName("k");
node->addChild(c);
UnitDefinition * ud = NULL;
ud = uff->getUnitDefinition(node);
fail_unless(uff->getContainsUndeclaredUnits() == true);
fail_unless(uff->canIgnoreUndeclaredUnits() == false);
fail_unless(ud != NULL);
fail_unless(ud->getNumUnits() == 1);
fail_unless(ud->getUnit(0)->getKind() == UNIT_KIND_METRE);
fail_unless(util_isEqual(ud->getUnit(0)->getExponent(), 1));
delete node;
delete ud;
}
示例5: if
/**
* Sets the type of an ASTNode based on the given MathML <ci> element.
* Errors will be logged in the stream's SBMLErrorLog object.
*/
static void
setTypeCI (ASTNode& node, const XMLToken& element, XMLInputStream& stream)
{
if (element.getName() == "csymbol")
{
string url;
element.getAttributes().readInto("definitionURL", url);
if ( url == URL_DELAY ) node.setType(AST_FUNCTION_DELAY);
else if ( url == URL_TIME ) node.setType(AST_NAME_TIME);
else if ( url == URL_AVOGADRO ) node.setType(AST_NAME_AVOGADRO);
else
{
static_cast <SBMLErrorLog*>
(stream.getErrorLog())->logError(BadCsymbolDefinitionURLValue,
stream.getSBMLNamespaces()->getLevel(),
stream.getSBMLNamespaces()->getVersion());
}
}
else if (element.getName() == "ci")
{
node.setDefinitionURL(element.getAttributes());
}
const string name = trim( stream.next().getCharacters() );
node.setName( name.c_str() );
}
示例6: ASTNode
END_TEST
START_TEST (test_MathMLFromAST_function_2)
{
const char* expected = wrapMathML
(
" <apply>\n"
" <ci> foo </ci>\n"
" <cn type=\"integer\"> 1 </cn>\n"
" <cn type=\"integer\"> 2 </cn>\n"
" <apply>\n"
" <ci> bar </ci>\n"
" <ci> z </ci>\n"
" </apply>\n"
" </apply>\n"
);
// N = SBML_parseFormula("foo(1, 2, bar(z))");
N = new ASTNode(AST_FUNCTION);
fail_unless( N->setName("foo") == LIBSBML_OPERATION_SUCCESS);
ASTNode *c1 = new ASTNode(AST_INTEGER);
c1->setValue(long(1));
ASTNode *c2 = new ASTNode(AST_INTEGER);
c2->setValue(long(2));
ASTNode *bar = new ASTNode(AST_FUNCTION);
bar->setName("bar");
ASTNode *cz = new ASTNode(AST_NAME);
cz->setName("z");
fail_unless (bar->addChild(cz) == LIBSBML_OPERATION_SUCCESS);
fail_unless (N->addChild(c1) == LIBSBML_OPERATION_SUCCESS);
fail_unless (N->addChild(c2) == LIBSBML_OPERATION_SUCCESS);
fail_unless (N->addChild(bar) == LIBSBML_OPERATION_SUCCESS);
S = writeMathMLToString(N);
fail_unless( equals(expected, S) );
}
示例7: toAST
ASTNode* CEvaluationNodeCall::toAST(const CCopasiDataModel* pDataModel) const
{
ASTNode* pNode = NULL;
pNode = new ASTNode(AST_FUNCTION);
const std::string funName = this->getData();
CFunction * pFun = CCopasiRootContainer::getFunctionList()->findFunction(funName);
assert(pFun != NULL);
if (pFun == NULL || pFun->getSBMLId().empty()) fatalError();
pNode->setName(pFun->getSBMLId().c_str());
const CEvaluationNode* child = static_cast<const CEvaluationNode*>(this->getChild());
while (child)
{
pNode->addChild(child->toAST(pDataModel));
child = static_cast<const CEvaluationNode*>(child->getSibling());
}
return pNode;
}
示例8: createExampleEnzymaticReaction
//.........这里部分代码省略.........
// Creates a Compartment object ("cytosol")
comp = model->createCompartment();
comp->setId(compName);
// Sets the "size" attribute of the Compartment object.
//
// We are not setting the units on the compartment size explicitly, so
// the units of this Compartment object will be the default SBML units of
// volume, which are liters.
//
comp->setSize(1e-14);
//---------------------------------------------------------------------------
//
// Creates Species objects inside the Model object.
//
//---------------------------------------------------------------------------
// Temporary pointer (reused more than once below).
Species *sp;
//---------------------------------------------------------------------------
// (Species1) Creates a Species object ("ES")
//---------------------------------------------------------------------------
// Create the Species objects inside the Model object.
sp = model->createSpecies();
sp->setId("ES");
sp->setName("ES");
// Sets the "compartment" attribute of the Species object to identify the
// compartment in which the Species object is located.
sp->setCompartment(compName);
// Sets the "initialAmount" attribute of the Species object.
//
// In SBML, the units of a Species object's initial quantity are
// determined by two attributes, "substanceUnits" and
// "hasOnlySubstanceUnits", and the "spatialDimensions" attribute
// of the Compartment object ("cytosol") in which the species
// object is located. Here, we are using the default values for
// "substanceUnits" (which is "mole") and "hasOnlySubstanceUnits"
// (which is "false"). The compartment in which the species is
// located uses volume units of liters, so the units of these
// species (when the species appear in numerical formulas in the
// model) will be moles/liters.
//
sp->setInitialAmount(0);
//---------------------------------------------------------------------------
// (Species2) Creates a Species object ("P")
//---------------------------------------------------------------------------
sp = model->createSpecies();
sp->setCompartment(compName);
sp->setId("P");
sp->setName("P");
sp->setInitialAmount(0);
//---------------------------------------------------------------------------
示例9: toAST
ASTNode* CEvaluationNodeObject::toAST(const CCopasiDataModel* pDataModel) const
{
ASTNode* node = new ASTNode();
node->setType(AST_NAME);
// since I can not get the model in which this node is located, I just
// assume that it will always be the current global model.
const CCopasiObject* object = pDataModel->getObject(mRegisteredObjectCN);
assert(object);
// if it is a reference, we get the parent of the reference
if (object->isReference())
{
object = object->getObjectParent();
}
const CModelEntity* pME = dynamic_cast<const CModelEntity*>(object);
if (pME != NULL)
{
const CModel* pModel = dynamic_cast<const CModel*>(pME);
if (pModel != NULL)
{
node->setType(AST_NAME_TIME);
node->setName("time");
if (pModel->getInitialTime() != 0.0)
{
CCopasiMessage(CCopasiMessage::WARNING, MCSBML + 1);
}
}
else
{
node->setName(pME->getSBMLId().c_str());
}
}
else
{
const CCopasiParameter* pPara = dynamic_cast<const CCopasiParameter*>(object);
if (pPara != NULL)
{
// now we have to use the common name as the name for the
// node since we need to be able to identify local parameters
// in arbitrary expressions for the export
node->setName(pPara->getCN().c_str());
}
else
{
const CReaction* pReaction = dynamic_cast<const CReaction*>(object);
if (pReaction)
{
node->setName(pReaction->getSBMLId().c_str());
}
else
{
fatalError();
}
}
}
return node;
}
示例10: toAST
//.........这里部分代码省略.........
break;
case S_CEIL:
node->setType(AST_FUNCTION_CEILING);
break;
case S_FLOOR:
node->setType(AST_FUNCTION_FLOOR);
break;
case S_FACTORIAL:
node->setType(AST_FUNCTION_FACTORIAL);
break;
case S_MINUS:
node->setType(AST_MINUS);
break;
case S_PLUS:
// if this is the unary plus as I suspect,
// the node will be replaced by its only child
delete node;
node = dynamic_cast<const CEvaluationNode*>(this->getChild())->toAST(pDataModel);
break;
case S_NOT:
node->setType(AST_LOGICAL_NOT);
break;
case S_RUNIFORM:
{
needFirstArg = false;
node->setType(AST_FUNCTION);
node->setName("RUNIFORM");
const CEvaluationNode* child = dynamic_cast<const CEvaluationNode*>(this->getChild());
const CEvaluationNode* sibling = dynamic_cast<const CEvaluationNode*>(child->getSibling());
node->addChild(child->toAST(pDataModel));
node->addChild(sibling->toAST(pDataModel));
}
break;
case S_RNORMAL:
{
needFirstArg = false;
node->setType(AST_FUNCTION);
node->setName("RNORMAL");
const CEvaluationNode* child = dynamic_cast<const CEvaluationNode*>(this->getChild());
const CEvaluationNode* sibling = dynamic_cast<const CEvaluationNode*>(child->getSibling());
node->addChild(child->toAST(pDataModel));
node->addChild(sibling->toAST(pDataModel));
}
break;
case S_RGAMMA:
{
needFirstArg = false;
node->setType(AST_FUNCTION);
node->setName("RGAMMA");
const CEvaluationNode* child = dynamic_cast<const CEvaluationNode*>(this->getChild());
const CEvaluationNode* sibling = dynamic_cast<const CEvaluationNode*>(child->getSibling());
node->addChild(child->toAST(pDataModel));
node->addChild(sibling->toAST(pDataModel));
}
break;
case S_RPOISSON: