本文整理汇总了C++中CCopasiParameter::getCN方法的典型用法代码示例。如果您正苦于以下问题:C++ CCopasiParameter::getCN方法的具体用法?C++ CCopasiParameter::getCN怎么用?C++ CCopasiParameter::getCN使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCopasiParameter
的用法示例。
在下文中一共展示了CCopasiParameter::getCN方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: changeModel
void CFixLocalReactionParameters::changeModel()
{
CCopasiParameter * pParameter = NULL;
CModelValue * pModelValue = NULL;
CReaction * pReaction = NULL;
std::stringstream NameStream;
std::stringstream Message;
std::string OldCN;
std::string NewCNBase;
std::string NewCN;
std::string Infix;
std::string::size_type Start;
// Loop through all changes.
std::multimap< CCopasiParameter *, const CExpression * >::const_iterator itChanges = mChanges.begin();
std::multimap< CCopasiParameter *, const CExpression * >::const_iterator endChanges = mChanges.end();
for (; itChanges != endChanges; ++itChanges)
{
if (pParameter != itChanges->first)
{
// We have a new parameter
pParameter = itChanges->first;
OldCN = "<" + pParameter->getCN() + ",Reference=";
// Create a global quantity of type FIXED.
std::string Name = pParameter->getObjectName();
pReaction = static_cast< CReaction * >(pParameter->getObjectAncestor("Reaction"));
Name += "{" + pReaction->getObjectName() + "}";
pModelValue = mpModel->createModelValue(Name, pParameter->getValue< C_FLOAT64 >());
// In case the created name is not unique we append _n with increasing n
// until we succeed;
C_INT32 index = 0;
while (pModelValue == NULL)
{
NameStream.str("");
NameStream << Name << "_" << index++;
pModelValue = mpModel->createModelValue(NameStream.str(), pParameter->getValue< C_FLOAT64 >());
}
NewCNBase = "<" + pModelValue->getCN() + ",Reference=";
// If the parameter is actually used in the reaction
// it is changed to the global quantity.
if (pReaction->isLocalParameter(pParameter->getObjectName()))
pReaction->setParameterMapping(pParameter->getObjectName(), pModelValue->getKey());
Message << " " << pParameter->getObjectName() << " in " << pReaction->getObjectName()
<< " is replaced by " << pModelValue->getObjectName() << std::endl;
}
// We need to distinguish between initial and other expressions.
if (itChanges->second->getObjectName().compare(0, 7, "Initial") == 0)
NewCN = NewCNBase + "Initial";
else
NewCN = NewCNBase;
// Replace the OldCN of the parameter with the NewCN of global quantity in all expressions.
Infix = itChanges->second->getInfix();
// There may be more than one occurrence.
Start = 0;
while ((Start = Infix.find(OldCN), Start) != std::string::npos)
Infix.replace(Start, OldCN.length(), NewCN);
const_cast< CExpression * >(itChanges->second)->setInfix(Infix);
}
CCopasiMessage(CCopasiMessage::WARNING, MCXML + 14, Message.str().c_str());
}