本文整理汇总了C++中ASTNode::getName方法的典型用法代码示例。如果您正苦于以下问题:C++ ASTNode::getName方法的具体用法?C++ ASTNode::getName怎么用?C++ ASTNode::getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ASTNode
的用法示例。
在下文中一共展示了ASTNode::getName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
void
AssignmentCycles::addRuleDependencies(const Model& m, const Rule& object)
{
unsigned int ns;
std::string thisId = object.getVariable();
/* loop thru the list of names in the Math
* if they refer to a Reaction, an Assignment Rule
* or an Initial Assignment add to the map
* with the variable as key
*/
List* variables = object.getMath()->getListOfNodes( ASTNode_isName );
for (ns = 0; ns < variables->getSize(); ns++)
{
ASTNode* node = static_cast<ASTNode*>( variables->get(ns) );
string name = node->getName() ? node->getName() : "";
if (m.getReaction(name))
{
mIdMap.insert(pair<const std::string, std::string>(thisId, name));
}
else if (m.getRule(name) && m.getRule(name)->isAssignment())
{
mIdMap.insert(pair<const std::string, std::string>(thisId, name));
}
else if (m.getInitialAssignment(name))
{
mIdMap.insert(pair<const std::string, std::string>(thisId, name));
}
}
delete variables;
}
示例2: if
/*
* @return the error message to use when logging constraint violations.
* This method is called by logFailure.
*
* Returns a message that the given @p id and its corresponding object are
* in conflict with an object previously defined.
*/
const string
CiElementMathCheck::getMessage (const ASTNode& node, const SBase& object)
{
ostringstream msg;
//msg << getPreamble();
char * formula = SBML_formulaToString(&node);
msg << "The formula '" << formula;
msg << "' in the " << getFieldname() << " element of the <" << object.getElementName();
msg << "> ";
switch(object.getTypeCode()) {
case SBML_INITIAL_ASSIGNMENT:
case SBML_EVENT_ASSIGNMENT:
case SBML_ASSIGNMENT_RULE:
case SBML_RATE_RULE:
//LS DEBUG: could use other attribute values, or 'isSetActualId'.
break;
default:
if (object.isSetId()) {
msg << "with id '" << object.getId() << "' ";
}
break;
}
if (object.getLevel() == 2 && object.getVersion() == 1)
msg << "uses '" << node.getName() << "' that is not the id of a species/compartment/parameter.";
else if (object.getLevel() < 3)
msg << "uses '" << node.getName() << "' that is not the id of a species/compartment/parameter/reaction.";
else
msg << "uses '" << node.getName() << "' that is not the id of a species/compartment/parameter/reaction/speciesReference.";
safe_free(formula);
return msg.str();
}
示例3: logMathConflict
/**
* Checks that the functionDefinition referred to by a <ci> element
* has the appropriate number of arguments.
*
* If not, an error message is logged.
*/
void
FunctionNoArgsMathCheck::checkNumArgs (const Model& m, const ASTNode& node,
const SBase & sb)
{
/* this rule was only introduced level 2 version 4 */
if (m.getLevel() > 2 || (m.getLevel() == 2 && m.getVersion() > 3))
{
if (m.getFunctionDefinition(node.getName()) != NULL)
{
/* functiondefinition math */
const ASTNode * fdMath = m.getFunctionDefinition(node.getName())->getMath();
if (fdMath != NULL)
{
/* We have a definition for this function. Does the defined number
of arguments equal the number used here? */
if (node.getNumChildren() != m.getFunctionDefinition(node.getName())->getNumArguments())
{
logMathConflict(node, sb);
}
}
}
}
}
示例4:
void
FunctionDefinitionRecursion::addDependencies(const Model& m,
const FunctionDefinition& object)
{
unsigned int ns;
std::string thisId = object.getId();
/* loop thru the list of names in the Math
* if they refer to a FunctionDefinition add to the map
* with the variable as key
*/
List* variables = object.getMath()->getListOfNodes( ASTNode_isFunction );
for (ns = 0; ns < variables->getSize(); ns++)
{
ASTNode* node = static_cast<ASTNode*>( variables->get(ns) );
string name = node->getName() ? node->getName() : "";
if (m.getFunctionDefinition(name))
{
mIdMap.insert(pair<const std::string, std::string>(thisId, name));
}
}
delete variables;
}
示例5: readMathMLFromStringWithNamespaces
END_TEST
START_TEST (test_element_selector)
{
const char* s = wrapMathML
(
" <apply>"
" <selector/>"
" <ci> A </ci>"
" <ci> i </ci>"
" </apply>"
);
N = readMathMLFromStringWithNamespaces(s, NS);
fail_unless( N != NULL );
fail_unless( N->getType() == AST_ORIGINATES_IN_PACKAGE);
fail_unless( N->getExtendedType() == AST_LINEAR_ALGEBRA_SELECTOR);
fail_unless( N->getNumChildren() == 2);
fail_unless( N->getPackageName() == "arrays");
ASTNode * child = N->getChild(0);
fail_unless( child != NULL );
fail_unless( child->getType() == AST_NAME);
fail_unless( child->getExtendedType() == AST_NAME);
fail_unless( strcmp(child->getName(), "A") == 0);
fail_unless( child->getNumChildren() == 0);
fail_unless( child->getPackageName() == "core");
child = N->getChild(1);
fail_unless( child != NULL );
fail_unless( child->getType() == AST_NAME);
fail_unless( child->getExtendedType() == AST_NAME);
fail_unless( strcmp(child->getName(), "i") == 0);
fail_unless( child->getNumChildren() == 0);
ArraysASTPlugin* plugin = static_cast<ArraysASTPlugin*>(N->getPlugin("arrays"));
fail_unless(plugin != NULL);
fail_unless(plugin->getASTType() == AST_LINEAR_ALGEBRA_SELECTOR);
}
示例6: if
/**
* Constructor that makes a ConverterASTNode from an ASTNode.
*/
ConverterASTNode::ConverterASTNode(const ASTNode &templ): ASTNode(templ.getType())
{
if (this->getType() == AST_RATIONAL)
{
this->mDenominator = templ.getDenominator();
this->mInteger = templ.getNumerator();
}
else if (this->getType() == AST_REAL || this->getType() == AST_REAL_E)
{
this->mExponent = templ.getExponent();
this->mReal = templ.getMantissa();
}
if (this->getType() == AST_PLUS || this->getType() == AST_MINUS || this->getType() == AST_TIMES || this->getType() == AST_DIVIDE || this->getType() == AST_POWER)
{
this->mChar = templ.getCharacter();
}
else if (this->getType() == AST_INTEGER)
{
this->mInteger = templ.getInteger();
}
if ((!this->isOperator()) && (!this->isNumber()))
{
this->setName(templ.getName());
}
unsigned int counter;
for (counter = 0; counter < templ.getNumChildren(); counter++)
{
this->addChild(new ConverterASTNode(*templ.getChild(counter)));
}
};
示例7: getFieldname
/*
* @return the error message to use when logging constraint violations.
* This method is called by logFailure.
*
* Returns a message that the given @p id and its corresponding object are
* in conflict with an object previously defined.
*/
const string
FunctionApplyMathCheck::getMessage (const ASTNode& node, const SBase& object)
{
ostringstream msg;
//msg << getPreamble();
char * formula = SBML_formulaToString(&node);
msg << "The formula '" << formula;
msg << "' in the " << getFieldname() << " element of the <" << object.getElementName();
msg << "> ";
switch(object.getTypeCode()) {
case SBML_INITIAL_ASSIGNMENT:
case SBML_EVENT_ASSIGNMENT:
case SBML_ASSIGNMENT_RULE:
case SBML_RATE_RULE:
//LS DEBUG: could use other attribute values, or 'isSetActualId'.
break;
default:
if (object.isSetId()) {
msg << "with id '" << object.getId() << "' ";
}
break;
}
msg << "uses '" << node.getName() << "' which is not a function definition id.";
safe_free(formula);
return msg.str();
}
示例8: if
/**
* Checks any <ci> elements in the MathML of the ASTnode
* contain the id of an appropriate component of the model
*
* If an inconsistency is found, an error message is logged.
*/
void
LocalParameterMathCheck::checkCiElement (const Model& m,
const ASTNode& node,
const SBase & sb)
{
std::string name = node.getName();
const KineticLaw * kl;
if (m.getCompartment(name) == NULL &&
m.getSpecies(name) == NULL &&
m.getParameter(name) == NULL &&
m.getReaction(name) == NULL)
{
/* check whether we are in a kinetic law since there
* may be local parameters to this law that are allowed
*/
if (sb.getTypeCode() == SBML_KINETIC_LAW)
{
kl = m.getReaction(mKLCount)->getKineticLaw();
if (kl->getParameter(name) == NULL && mLocalParameters.contains(name))
{
logMathConflict(node, sb);
}
}
else if (mLocalParameters.contains(name))
{
logMathConflict(node, sb);
}
}
}
示例9: testConstructor
void TestASTNode::testConstructor()
{
ASTNode* node = new ASTNode("value", PROGRAM, 1);
CPPUNIT_ASSERT("value" == node->getName());
CPPUNIT_ASSERT_EQUAL(PROGRAM, node->getType());
CPPUNIT_ASSERT_EQUAL(1, node->getStatementNumber());
}
示例10: logMathConflict
/*
* Checks that the functionDefinition referred to by a <ci> element exists
*
* If <ci> does not refer to functionDefinition id, an error message is logged.
*/
void
FunctionApplyMathCheck::checkExists (const Model& m, const ASTNode& node,
const SBase & sb)
{
std::string name = node.getName();
if (!m.getFunctionDefinition(name))
logMathConflict(node, sb);
}
示例11: getFieldname
/**
* @return the error message to use when logging constraint violations.
* This method is called by logFailure.
*
* Returns a message that the given id and its corresponding object are
* in conflict with an object previously defined.
*/
const string
CiElementMathCheck::getMessage (const ASTNode& node, const SBase& object)
{
ostringstream msg;
//msg << getPreamble();
char * formula = SBML_formulaToString(&node);
msg << "\nThe formula '" << formula;
msg << "' in the " << getFieldname() << " element of the " << getTypename(object);
if (object.getLevel() == 2 && object.getVersion() == 1)
msg << " uses '" << node.getName() << "' that is not the id of a species/compartment/parameter.";
else
msg << " uses '" << node.getName() << "' that is not the id of a species/compartment/parameter/reaction.";
safe_free(formula);
return msg.str();
}
示例12: getCalledProcedure
std::string AST::getCalledProcedure(int stmtNum)
{
ASTNode* node = getStatementNode(stmtNum);
if (node->getType() == CALL) {
return node->getName();
} else {
return "";
}
}
示例13:
bool
containsId(const ASTNode* ast, std::string id)
{
bool present = false;
List* variables = ast->getListOfNodes(ASTNode_isName);
IdList vars;
for (unsigned int i = 0; i < variables->getSize(); i++)
{
ASTNode* node = static_cast<ASTNode*>(variables->get(i));
string name = node->getName() ? node->getName() : "";
vars.append(name);
}
if (vars.contains(id))
{
present = true;
}
delete variables;
return present;
}
示例14: logRuleRefersToSelf
void
AssignmentRuleOrdering::checkRuleForVariable(const Model& m, const Rule& object)
{
/* list the <ci> elements */
List* variables = object.getMath()->getListOfNodes( ASTNode_isName );
std::string variable = object.getVariable();
if (variables)
{
for (unsigned int i = 0; i < variables->getSize(); i++)
{
ASTNode* node = static_cast<ASTNode*>( variables->get(i) );
const char * name = node->getName() ? node->getName() : "";
if (!(strcmp(variable.c_str(), name)))
logRuleRefersToSelf(*(object.getMath()), object);
}
// return value of ASTNode::getListOfNodes() needs to be
// deleted by caller.
delete variables;
}
}
示例15: logUndefined
/**
* Checks that all variables referenced in FunctionDefinition bodies are
* bound variables (function arguments).
*/
void
FunctionDefinitionVars::check_ (const Model& m, const FunctionDefinition& fd)
{
if ( fd.getLevel() == 1 ) return;
if ( !fd.isSetMath() ) return;
if ( fd.getBody() == NULL ) return;
if ( fd.getNumArguments() == 0 ) return;
List* variables = fd.getBody()->getListOfNodes( ASTNode_isName );
for (unsigned int n = 0; n < variables->getSize(); ++n)
{
ASTNode* node = static_cast<ASTNode*>( variables->get(n) );
string name = node->getName() ? node->getName() : "";
if ( fd.getArgument(name) == NULL )
{
/* if this is the csymbol time - technically it is allowed
* in L2v1 and L2v2
*/
if (node->getType() == AST_NAME_TIME)
{
if (fd.getLevel() > 2
|| (fd.getLevel() == 2 && fd.getVersion() > 2))
{
logUndefined(fd, name);
}
}
else
{
logUndefined(fd, name);
}
}
}
delete variables;
}