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


C++ CIMClient::associatorNames方法代码示例

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


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

示例1: testDMTFProfileInstances

void testDMTFProfileInstances(CIMClient &client)
{
    cout << "Testing DMTF Profiles instances...";

    // Get All Registered profile names
    Array<CIMObjectPath> regInstanceNames = client.enumerateInstanceNames(
        interopNamespace,
        CIMName("CIM_RegisteredProfile"));

    // Find out DMTF autonomous and component profiles.
    for(Uint32 i = 0, n = regInstanceNames.size() ; i < n ; ++i)
    {
        // Filter SNIA sub profile names.
        if (regInstanceNames[i].getClassName().equal("PG_RegisteredSubProfile"))
        {
            continue;
        }

        Array<CIMObjectPath> result = client.associatorNames(
            interopNamespace,
            regInstanceNames[i],
            CIMName("CIM_ReferencedProfile"));

        Uint32 dmtfProfiles = 0;
        for (Uint32 j = 0, k = result.size(); j < k ; ++j)
        {
            // Get only DMTF component profiles.
            if (result[j].getClassName().equal("PG_RegisteredProfile"))
            {
                Array<CIMKeyBinding> keys = result[j].getKeyBindings();
                String value = keys[0].getValue();
                Uint32 index = value.find("DMTF");
                if (index != PEG_NOT_FOUND)
                {
                    dmtfProfiles++;
                }
            }
        }
        if (dmtfProfiles && dmtfProfiles != result.size())
        {
            exitFailure(
                String("Invalid component profiles for ")
                    + regInstanceNames[i].toString());
        }
    }

    cout << "Test Complete" << endl;
}
开发者ID:brunolauze,项目名称:pegasus,代码行数:48,代码来源:ServerProfile.cpp

示例2: _testAssociatorNames

Uint32 _testAssociatorNames(CIMClient& client,
                            CIMName assocClass,
                            CIMObjectPath instancePath)
{
    if (verbose)
    {
        cout << "\nAssociation Class: " << assocClass.getString() << endl;
        cout << "\nObject Name: " << instancePath.toString() << endl;
    }

    // Get the names of the CIM instances that are associated to the
    // specified source instance via an instance of the AssocClass.
    //
    CIMName resultClass;
    String role;
    String resultRole;
    Array<CIMObjectPath> resultObjectPaths = client.associatorNames(
        NAMESPACE, instancePath, assocClass, resultClass, role, resultRole);
    return resultObjectPaths.size();
}
开发者ID:rdobson,项目名称:openpegasus,代码行数:20,代码来源:TestAggregationOutputClient.cpp

示例3: _testAssociators

void _testAssociators(
    CIMClient& client,
    CIMName assocClass,
    CIMObjectPath instancePath )
{
    try
    {
        CIMName resultClass;
        String role;
        String resultRole;

        // Get the CIM instances that are associated with the specified source
        // instance via an instance of the AssocClass

        Array<CIMObject> resultObjects =
            client.associators(
                providerNamespace,
                instancePath,
                assocClass,
                resultClass,
                role,
                resultRole);

        Array<CIMObjectPath> resultObjectPaths =
            client.associatorNames(
                providerNamespace,
                instancePath,
                assocClass,
                resultClass,
                role,
                resultRole);

    }
    catch (Exception& e)
    {
        _errorExit(e.getMessage());
    }
}
开发者ID:rdobson,项目名称:openpegasus,代码行数:38,代码来源:TestCMPI_Fail_5.cpp

示例4: main


//.........这里部分代码省略.........
                                    assocClass,
                                    resultClass,
                                    role,
                                    invalidResultRole);

        }
        catch (CIMException& e)
        {
            if (e.getCode() == CIM_ERR_INVALID_PARAMETER)
            {
                gotException = true;
                if (verbose)
                {
                    cout << "Test resultRole parameter syntax: " <<
                        e.getMessage() << endl;
                }
            }
            else
            {
                throw;
            }
        }
        PEGASUS_TEST_ASSERT(gotException);

        // ===================================================================
        // associatorNames
        //
        // Get the names of the CIM instances (Sample_Student instances) that
        // are associated to the source CIM instance (Sample_Teacher.Name =
        // "Teacher1") via an instance of the Sample_TeacherStudent association
        // class.
        // ===================================================================

        resultObjectPaths = client.associatorNames(
                                NAMESPACE,
                                instancePath,
                                assocClass,
                                resultClass,
                                role,
                                resultRole);

        // verify result
        numObjects = resultObjectPaths.size();
        if (_verifyResult(numObjects, 3) != 0)
            return -1;

        // display result
        // cout << "Number of associator name objects = " << numObjects << endl;
        _displayResult(resultObjectPaths, verbose);

        // ===================================================================
        // associatorNames
        //
        // Validate role and resultRole parameters syntax.
        // ===================================================================

        // invalid role parameter syntax
        gotException = false;
        try
        {
            resultObjectPaths = client.associatorNames(
                                    NAMESPACE,
                                    instancePath,
                                    assocClass,
                                    resultClass,
                                    invalidRole,
开发者ID:brunolauze,项目名称:pegasus,代码行数:67,代码来源:AssociationClient.cpp

示例5: testInstanceClass

void testInstanceClass(CIMClient & client, const CIMName & className)
{
    cout << "Testing Instance Class "
        << (const char *)className.getString().getCString()
        << "...";
    Array<CIMInstance> instances = testAnyClass(client, className);

    for(unsigned int i = 0, n = instances.size(); i < n; ++i)
    {
        CIMInstance currentInstance = instances[i];
        CIMObjectPath currentPath = currentInstance.getPath();
        if(currentPath.getNameSpace().isNull())
          currentPath.setNameSpace(interopNamespace);

        //
        // Now test association traversal
        // Note that the "TestAssociationClass" method does a very good job
        // of testing association traversal between references contained in
        // instances of the supplied association class. Therefore, all we
        // really have to do here is make sure that the results of the
        // associators, associatorNames, references, and referenceNames
        // operations are consistent.
        //
        Boolean failure = false;
        try
        {
            Array<CIMObject> associatorsResults = client.associators(
                currentPath.getNameSpace(), currentPath);
            Array<CIMObjectPath> associatorNamesResults =
                client.associatorNames(
                    currentPath.getNameSpace(), currentPath);
            Array<CIMObject> referencesResults = client.references(
                currentPath.getNameSpace(), currentPath);
            Array<CIMObjectPath> referenceNamesResults = client.referenceNames(
                currentPath.getNameSpace(), currentPath);

            Uint32 numResults = associatorsResults.size();
            if(numResults != associatorNamesResults.size() ||
                numResults != referencesResults.size() ||
                numResults != referenceNamesResults.size())
            {
                failure = true;
            }
            else
            {
                // Check that the results for the references and referenceNames
                // operations are consistent.
                unsigned int j = 0;
                for(j = 0; j < numResults; ++j)
                {
                    CIMObjectPath currentReferenceName =
                        referenceNamesResults[j];
                    Boolean found = false;
                    for(unsigned int k = 0; k < numResults; ++k)
                    {
                        if(currentReferenceName ==
                            referencesResults[k].getPath())
                        {
                            found = true;
                            break;
                        }
                    }

                    if(!found)
                    {
                        failure = true;
                        break;
                    }
                }

                // Check that that results for the associatorNames call is
                // consistent with the associators call and the references
                // call.
                for(j = 0; j < numResults; ++j)
                {
                    CIMObjectPath currentAssociatorName =
                        associatorNamesResults[j];
                    Boolean found = false;
                    unsigned int k = 0;
                    for(k = 0; k < numResults; ++k)
                    {
                        if(currentAssociatorName ==
                            associatorsResults[k].getPath())
                        {
                            found = true;
                            break;
                        }
                    }

                    if(!found)
                    {
                        failure = true;
                        break;
                    }

                    found = false;

                    for(k = 0; k < numResults; ++k)
                    {
                        CIMObject referenceInstance = referencesResults[k];
//.........这里部分代码省略.........
开发者ID:brunolauze,项目名称:pegasus,代码行数:101,代码来源:ServerProfile.cpp

示例6: testAssociationClass

void testAssociationClass(CIMClient & client, const CIMName & className)
{
    cout << "Testing Association Class "
        << (const char *)className.getString().getCString()
        << "...";
    Array<CIMInstance> instances = testAnyClass(client, className);

    for(unsigned int i = 0, n = instances.size(); i < n; ++i)
    {
        //
        // Now make sure that the references are valid and that association
        // traversal between them is working properly.
        //
        CIMObjectPath referenceA;
        CIMObjectPath referenceB;
        CIMInstance currentInstance = instances[i];
        CIMObjectPath currentInstanceName = currentInstance.getPath();
        if(currentInstanceName.getNameSpace().isNull())
            currentInstanceName.setNameSpace(interopNamespace);

        for(unsigned int j = 0, m = currentInstance.getPropertyCount();
            j < m; ++j)
        {
            CIMProperty currentProp = currentInstance.getProperty(j);
            if(currentProp.getValue().getType() == CIMTYPE_REFERENCE)
            {
                if(referenceA.getKeyBindings().size() == 0)
                {
                    currentProp.getValue().get(referenceA);
                }
                else
                {
                    currentProp.getValue().get(referenceB);
                    break;
                }
            }
        }

        if(referenceA.getKeyBindings().size() == 0 ||
            referenceB.getKeyBindings().size() == 0)
        {
            exitFailure(
                String("Could not find reference properties for ") +
                String("association: ") +
                currentInstanceName.toString());
        }

        try
        {
            client.getInstance(referenceA.getNameSpace(), referenceA);
            client.getInstance(referenceB.getNameSpace(), referenceB);
        }
        catch(CIMException &)
        {
            exitFailure(String("Could not get instances for association : ") +
                currentInstanceName.toString());
        }

        Boolean associationFailure = false;
        try
        {
            Array<CIMObjectPath> results = client.associatorNames(
                referenceA.getNameSpace(), referenceA, className);
            Boolean found = false;
            for(unsigned int j = 0, m = results.size(); j < m; ++j)
            {
                CIMObjectPath result = results[j];
                result.setHost(referenceB.getHost());
                result.setNameSpace(referenceB.getNameSpace());
                if(result == referenceB)
                {
                    found = true;
                    break;
                }
            }

            if(found)
            {
                results = client.associatorNames(referenceB.getNameSpace(),
                    referenceB, className);
                for(unsigned int j = 0, m = results.size(); j < m; ++j)
                {
                    CIMObjectPath result = results[j];
                    result.setHost(referenceA.getHost());
                    result.setNameSpace(referenceA.getNameSpace());
                    if(result == referenceA)
                    {
                        found = true;
                        break;
                    }
                }
            }

            if(!found)
            {
                associationFailure = true;
            }
        }
        catch(CIMException & e)
        {
//.........这里部分代码省略.........
开发者ID:brunolauze,项目名称:pegasus,代码行数:101,代码来源:ServerProfile.cpp

示例7: _testCMPIAssociationClassOperations

void _testCMPIAssociationClassOperations(CIMClient& client, CIMName className)
{
    Array<CIMObjectPath> resultObjectPaths;
    Array<CIMObject> resultObjects;
    CIMObjectPath op(className.getString());

    CIMName assocClass;
    CIMName resultClass;
    String role;
    String resultRole;

    // =======================================================================
    // associators
    //
    // Get the CIM classes that are associated with the specified CIM Class
    // =======================================================================

    if (verbose)
    {
        cout << "+++++ Test associators for (" << className.getString();
        cout << ")" << endl;
    }

    try
    {
        // get the association classes
        resultObjects = client.associators(providerNamespace, op, assocClass,
            resultClass, role, resultRole);

        // display result
        _displayResult(resultObjects);
    }
    catch (Exception& e)
    {
        // Do nothing.
         _errorExit(e.getMessage());
    }

    // =======================================================================
    // associatorNames
    //
    // Get the name of the CIM classes that are associated with the specified
    // CIM class.
    // =======================================================================

    if (verbose)
    {
        cout << "+++++ Test associatorNames for (" << className.getString();
        cout << ")" << endl;
    }

    try
    {
        resultObjectPaths = client.associatorNames(
            providerNamespace,
            op,
            assocClass,
            resultClass,
            role,
            resultRole);

        // display result
        _displayResult(resultObjectPaths);
    }
    catch (Exception& e)
    {
        // Do nothing.
         _errorExit(e.getMessage());
    }

    // =======================================================================
    // references
    //
    // Get the association classes that refer to the specified CIM class.
    // =======================================================================

    if (verbose)
    {
        cout << "+++++ Test references for (" << className.getString()
             << ")" << endl;
    }

    try
    {
        resultObjects = client.references(
            providerNamespace,
            op,
            resultClass,
            role);

        // display result
        _displayResult(resultObjects);
    }
    catch (Exception& e)
    {
        // Do nothing.
         _errorExit(e.getMessage());
    }

    // =======================================================================
//.........这里部分代码省略.........
开发者ID:brunolauze,项目名称:pegasus,代码行数:101,代码来源:cmpiAssociationTestClient.cpp


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