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


C++ ObjRef::componentRef方法代码示例

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


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

示例1: componentHierarchy

QStringList CellmlFileRuntime::componentHierarchy(iface::cellml_api::CellMLElement *pElement)
{
    // Make sure that we have a given element

    if (!pElement)
        return QStringList();

    // Try to retrieve the component that owns the given element, unless the
    // given element is a component itself (which will be the case when we come
    // here through recursion)

    ObjRef<iface::cellml_api::CellMLComponent> component = QueryInterface(pElement);

    ObjRef<iface::cellml_api::CellMLElement> parent = pElement->parentElement();
    ObjRef<iface::cellml_api::CellMLComponent> parentComponent = QueryInterface(parent);

    if (!component && !parentComponent) {
        // The element isn't a component and neither is its parent, so it
        // doesn't have a hierarchy

        return QStringList();
    }

    // Check whether this is an imported component and, if so, retrieve its
    // imported name

    QString componentName = QString::fromStdWString(component?component->name():parentComponent->name());

    ObjRef<iface::cellml_api::CellMLElement> componentParent = component?component->parentElement():parentComponent->parentElement();
    ObjRef<iface::cellml_api::CellMLElement> componentParentParent = componentParent->parentElement();

    if (componentParentParent) {
        // The given element comes from or is an imported component, so go
        // through our different imported components and look for the one we are
        // after

        ObjRef<iface::cellml_api::CellMLImport> import = QueryInterface(componentParentParent);
        ObjRef<iface::cellml_api::ImportComponentSet> importComponents = import->components();
        ObjRef<iface::cellml_api::ImportComponentIterator> importComponentsIter = importComponents->iterateImportComponents();

        for (ObjRef<iface::cellml_api::ImportComponent> importComponent = importComponentsIter->nextImportComponent();
             importComponent; importComponent = importComponentsIter->nextImportComponent()) {
            if (!componentName.compare(QString::fromStdWString(importComponent->componentRef()))) {
                // This is the imported component we are after, so retrieve its
                // imported name

                componentName = QString::fromStdWString(importComponent->name());

                break;
            }
        }
    }

    // Recursively retrieve the component hierarchy of the given element's
    // encapsulation parent, if any

    ObjRef<iface::cellml_api::CellMLComponent> componentEncapsulationParent = component?component->encapsulationParent():parentComponent->encapsulationParent();

    return componentHierarchy(componentEncapsulationParent) << componentName;
}
开发者ID:knotman90,项目名称:opencor,代码行数:60,代码来源:cellmlfileruntime.cpp


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