本文整理汇总了C++中ASTNode::renameSIdRefs方法的典型用法代码示例。如果您正苦于以下问题:C++ ASTNode::renameSIdRefs方法的具体用法?C++ ASTNode::renameSIdRefs怎么用?C++ ASTNode::renameSIdRefs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ASTNode
的用法示例。
在下文中一共展示了ASTNode::renameSIdRefs方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
void
Rule::renameSIdRefs(const std::string& oldid, const std::string& newid)
{
SBase::renameSIdRefs(oldid, newid);
if (isSetMath()) {
mMath->renameSIdRefs(oldid, newid);
}
else if (isSetFormula()) {
ASTNode* math = SBML_parseFormula(mFormula.c_str());
if (math==NULL) return;
math->renameSIdRefs(oldid, newid);
char* formula = SBML_formulaToString(math);
setFormula(formula);
delete math;
delete formula;
}
}
示例2: ASTNode
pair<string, list<string> >
MMOMath::_generateAlgebraic (pair<list<string>, ASTNode*> function,
list<string> args, ASTNode *node)
{
ASTNode *repNode = new ASTNode (*function.second);
_processNode (repNode);
list<string>::iterator defArgs = function.first.begin ();
list<string> variables;
for (list<string>::iterator it = args.begin (); it != args.end (); it++)
{
repNode->renameSIdRefs (*defArgs, *it);
defArgs++;
}
string ret = MMOUtils::getInstance ()->getExp (repNode);
_getVariables (repNode, &variables);
int childs = node->getNumChildren (), i;
for (i = 0; i < childs; i++)
{
node->removeChild (0);
}
if (_type == MATH_ZERO_CROSSING)
{
node->setType (repNode->getType ());
childs = repNode->getNumChildren ();
for (i = 0; i < childs; i++)
{
node->addChild (new ASTNode (*repNode->getChild (i)));
}
}
else
{
node->setType (AST_NAME);
node->setName (ret.c_str ());
node->setId ("REPLACED_FUNCTION");
}
delete repNode;
return (pair<string, list<string> > (ret, variables));
}
示例3: getSBMLDocument
/** @cond doxygenLibsbmlInternal */
int
Replacing::updateIDs(SBase* oldnames, SBase* newnames)
{
int ret = LIBSBML_OPERATION_SUCCESS;
SBMLDocument* doc = getSBMLDocument();
if (oldnames->isSetId() && !newnames->isSetId()) {
if (doc) {
string error = "Unable to transform IDs in Replacing::updateIDs during replacement: the '" + oldnames->getId() + "' element's replacement does not have an ID set.";
doc->getErrorLog()->logPackageError("comp", CompMustReplaceIDs, getPackageVersion(), getLevel(), getVersion(), error, getLine(), getColumn());
}
return LIBSBML_INVALID_OBJECT;
}
if (oldnames->isSetMetaId() && !newnames->isSetMetaId()) {
if (doc) {
string error = "Unable to transform IDs in Replacing::updateIDs during replacement: the replacement of the element with metaid '" + oldnames->getMetaId() + "' does not have a metaid.";
doc->getErrorLog()->logPackageError("comp", CompMustReplaceMetaIDs, getPackageVersion(), getLevel(), getVersion(), error, getLine(), getColumn());
}
return LIBSBML_INVALID_OBJECT;
}
//LS DEBUG Somehow we need to check identifiers from other packages here (like spatial id's). How, exactly, is anyone's guess.
Model* replacedmod = const_cast<Model*>(CompBase::getParentModel(oldnames));
KineticLaw* replacedkl;
ASTNode newkl;
if (replacedmod==NULL) {
if (doc) {
string error = "Unable to transform IDs in Replacing::updateIDs during replacement: the replacement of '" + oldnames->getId() + "' does not have a valid model.";
doc->getErrorLog()->logPackageError("comp", CompModelFlatteningFailed, getPackageVersion(), getLevel(), getVersion(), error, getLine(), getColumn());
}
return LIBSBML_INVALID_OBJECT;
}
List* allElements = replacedmod->getAllElements();
string oldid = oldnames->getId();
string newid = newnames->getId();
if (!oldid.empty()) {
switch(oldnames->getTypeCode()) {
case SBML_UNIT_DEFINITION:
replacedmod->renameUnitSIdRefs(oldid, newid);
for (unsigned int e=0; e<allElements->getSize(); e++) {
SBase* element = static_cast<SBase*>(allElements->get(e));
element->renameUnitSIdRefs(oldid, newid);
}
break;
case SBML_LOCAL_PARAMETER:
replacedkl = static_cast<KineticLaw*>(oldnames->getAncestorOfType(SBML_KINETIC_LAW));
if (replacedkl->isSetMath()) {
newkl = *replacedkl->getMath();
newkl.renameSIdRefs(oldid, newid);
replacedkl->setMath(&newkl);
}
break;
case SBML_COMP_PORT:
break;
//LS DEBUG And here is where we would need some sort of way to check if the id wasn't an SId for some objects.
default:
replacedmod->renameSIdRefs(oldnames->getId(), newnames->getId());
for (unsigned int e=0; e<allElements->getSize(); e++) {
SBase* element = static_cast<SBase*>(allElements->get(e));
element->renameSIdRefs(oldid, newid);
}
}
}
string oldmetaid = oldnames->getMetaId();
string newmetaid = newnames->getMetaId();
if (oldnames->isSetMetaId()) {
replacedmod->renameMetaIdRefs(oldmetaid, newmetaid);
for (unsigned int e=0; e<allElements->getSize(); e++) {
SBase* element = static_cast<SBase*>(allElements->get(e));
element->renameMetaIdRefs(oldmetaid, newmetaid);
}
}
//LS DEBUG And here is where we would need some sort of way to check for ids that were not 'id' or 'metaid'.
delete allElements;
return ret;
}