本文整理汇总了C++中CCopasiParameter::getObjectName方法的典型用法代码示例。如果您正苦于以下问题:C++ CCopasiParameter::getObjectName方法的具体用法?C++ CCopasiParameter::getObjectName怎么用?C++ CCopasiParameter::getObjectName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCopasiParameter
的用法示例。
在下文中一共展示了CCopasiParameter::getObjectName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateModel
// virtual
bool CModelParameter::updateModel()
{
bool success = true;
if (mpObject != NULL)
{
switch (mType)
{
case Model:
{
CModel * pModel = static_cast< CModel * >(mpObject);
if (!pModel->isAutonomous())
{
pModel->setInitialValue(mValue);
}
else
{
pModel->setInitialValue(0.0);
}
}
break;
case Compartment:
case Species:
case ModelValue:
{
CModelEntity * pEntity = static_cast< CModelEntity * >(mpObject);
if (pEntity->getStatus() != CModelEntity::ASSIGNMENT)
{
pEntity->setInitialValue(mValue);
if (mIsInitialExpressionValid)
{
pEntity->setInitialExpression(getInitialExpression());
}
}
}
break;
case ReactionParameter:
{
CCopasiParameter * pParameter = static_cast< CCopasiParameter * >(mpObject);
CReaction * pReaction = static_cast< CReaction * >(mpObject->getObjectAncestor("Reaction"));
if (mIsInitialExpressionValid &&
getInitialExpression() != "")
{
CModel * pModel = mpParent->getModel();
assert(pModel != NULL);
std::vector< CCopasiContainer * > ListOfContainer;
ListOfContainer.push_back(pModel);
CCopasiObjectName CN = static_cast< CEvaluationNodeObject * >(mpInitialExpression->getRoot())->getObjectCN();
CCopasiObject * pObject = pModel->getObjectDataModel()->ObjectFromName(ListOfContainer, CN);
assert(pObject != NULL);
// We assign the object value
pParameter->setValue(* (C_FLOAT64 *) pObject->getValuePointer());
// We map the parameter to the global quantity
pReaction->setParameterMapping(pParameter->getObjectName(), pObject->getObjectParent()->getKey());
}
else
{
pParameter->setValue(mValue);
// We need to remove the existing mapping to a global quantity1.
pReaction->setParameterMapping(pParameter->getObjectName(), pParameter->getKey());
}
}
break;
default:
success = false;
break;
}
}
return success;
}
示例2: 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());
}