当前位置: 首页>>代码示例>>C++>>正文


C++ CCopasiObject::getObjectParent方法代码示例

本文整理汇总了C++中CCopasiObject::getObjectParent方法的典型用法代码示例。如果您正苦于以下问题:C++ CCopasiObject::getObjectParent方法的具体用法?C++ CCopasiObject::getObjectParent怎么用?C++ CCopasiObject::getObjectParent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CCopasiObject的用法示例。


在下文中一共展示了CCopasiObject::getObjectParent方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: hasValidModelReference

/**
 * This method is used for the export of several layout elements.
 * Layout elements can reference model elements, but when a referenced model element
 * is deleted, the layout is not infomred about this yet, so we end up with dnagling
 * references.
 * In order to not write these dangling references to file, we check if the reference
 * belongs to a valid object in the same datamodel. If not, we issue a warning.
 * This warning is only issued once during a save process.
 *
 * If the key belongs to an object in the same datamodel, true is returned, else false is returned.
 */
bool CLGraphicalObject::hasValidModelReference() const
{
  bool result = false;
  // check if the object for this key actually exists
  // TODO This is only a workaround because it is theoretically
  // TODO possible that the key no longer belongs to the same object it
  // TODO originally did.
  CCopasiObject* pObj = CCopasiRootContainer::getKeyFactory()->get(this->mModelObjectKey);

  if (pObj != NULL)
    {
      // check if the object actually belongs to the same
      // model as the text glyph
      const CCopasiDataModel* pDM1 = NULL;
      const CCopasiDataModel* pDM2 = NULL;
      const CCopasiContainer* pParent = pObj->getObjectParent();

      while (pParent != NULL)
        {
          pDM1 = dynamic_cast<const CCopasiDataModel*>(pParent);

          if (pDM1 != NULL)
            {
              break;
            }

          pParent = pParent->getObjectParent();
        }

      pParent = this->getObjectParent();

      while (pParent != NULL)
        {
          pDM2 = dynamic_cast<const CCopasiDataModel*>(pParent);

          if (pDM2 != NULL)
            {
              break;
            }

          pParent = pParent->getObjectParent();
        }

      //assert(pDM2 != NULL);
      if (pDM1 != NULL && pDM2 == NULL)
        {
          // if we have been able to resolve the model reference, but
          // don't have a datamodel parent, that is good enough
          return true;
        }

      if (pDM1 != NULL && pDM1 == pDM2)
        {
          result = true;
        }
    }

  return result;
}
开发者ID:bmoreau,项目名称:COPASI,代码行数:70,代码来源:CLGraphicalObject.cpp

示例2: getObjectDataModel

/**
 * Returns a pointer to the CCopasiDataModel the element belongs to.
 * If there is no instance of CCopasiDataModel in the ancestor tree, NULL
 * is returned.
 */
CCopasiDataModel* CCopasiObject::getObjectDataModel()
{
  CCopasiObject * pObject = this;

  while (pObject != NULL)
    {
      if (pObject->isDataModel())
        return static_cast<CCopasiDataModel *>(pObject);

      pObject = pObject->getObjectParent();
    }

  return NULL;
}
开发者ID:cpanchal,项目名称:COPASI,代码行数:19,代码来源:CCopasiObject.cpp

示例3: 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;
}
开发者ID:PriKalra,项目名称:COPASI,代码行数:86,代码来源:CModelParameter.cpp


注:本文中的CCopasiObject::getObjectParent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。