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


C++ CIMInstance::getPath方法代码示例

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


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

示例1: Run

void UNIX_ApplicationSystemDirectoryFixture::Run()
{
	CIMName className("UNIX_ApplicationSystemDirectory");
	CIMNamespaceName nameSpace("root/cimv2");
	UNIX_ApplicationSystemDirectory _p;
	UNIX_ApplicationSystemDirectoryProvider _provider;
	Uint32 propertyCount;
	CIMOMHandle omHandle;
	_provider.initialize(omHandle);
	_p.initialize();

	for(int pIndex = 0; _p.load(pIndex); pIndex++)
	{
		CIMInstance instance = _provider.constructInstance(className,
					nameSpace,
					_p);
		CIMObjectPath path = instance.getPath();
		cout << path.toString() << endl;
		propertyCount = instance.getPropertyCount();
		for(Uint32 i = 0; i < propertyCount; i++)
		{

			CIMProperty propertyItem = instance.getProperty(i);
			if (propertyItem.getType() == CIMTYPE_REFERENCE) {
				CIMValue subValue = propertyItem.getValue();
				CIMInstance subInstance;
				subValue.get(subInstance);
				CIMObjectPath subPath = subInstance.getPath();
				cout << "	Name: " << propertyItem.getName().getString() << ": " << subPath.toString() << endl;
				Uint32 subPropertyCount = subInstance.getPropertyCount();
				for(Uint32 j = 0; j < subPropertyCount; j++)
				{
					CIMProperty subPropertyItem = subInstance.getProperty(j);
					cout << "		Name: " << subPropertyItem.getName().getString() << " - Value: " << subPropertyItem.getValue().toString() << endl;
				}
			}
			else {
				cout << "	Name: " << propertyItem.getName().getString() << " - Value: " << propertyItem.getValue().toString() << endl;
			}

		}
		cout << "------------------------------------" << endl;
		cout << endl;
	}

	_p.finalize();
	
}
开发者ID:brunolauze,项目名称:openpegasus-providers,代码行数:48,代码来源:UNIX_ApplicationSystemDirectoryFixture.cpp

示例2: getInstance

CIMInstance CIMClient::getInstance(
    const CIMNamespaceName& nameSpace,
    const CIMObjectPath& instanceName,
    Boolean localOnly,
    Boolean includeQualifiers,
    Boolean includeClassOrigin,
    const CIMPropertyList& propertyList)
{
    CIMInstance inst = _rep->getInstance(
        nameSpace,
        instanceName,
        localOnly,
        includeQualifiers,
        includeClassOrigin,
        propertyList).getInstance();

    if (!inst.isUninitialized())
    {
        // remove key bindings, name space and host name form object path.
        CIMObjectPath& p =
            const_cast<CIMObjectPath&>(inst.getPath());

        CIMName cls = p.getClassName();
        p.clear();
        p.setClassName(cls);

    }

    return inst;
}
开发者ID:kaixuanlive,项目名称:openpegasus,代码行数:30,代码来源:CIMClient.cpp

示例3: GetKeyBindingsFromCIMInstance

//////////////////////////////////////////////////////////////////////
// TERRY: ADDED: helper function, maybe should go in a utilities or base class?
//////////////////////////////////////////////////////////////////////
bool WMIInstanceProvider::GetKeyBindingsFromCIMInstance(
    const CIMInstance& newInstance,
    BSTR* pbsKeyBindings)
{
    // might check for any NULL keys, just returning success always for now:
    bool bSuccess = true;

    String relPath = getObjectName(newInstance.getPath());
    *pbsKeyBindings = SysAllocString((const OLECHAR*)relPath.getChar16Data());

    return bSuccess;
}
开发者ID:rdobson,项目名称:openpegasus,代码行数:15,代码来源:WMIInstanceProvider.cpp

示例4: getProviderKeys

void ProviderIndicationCountTable::getProviderKeys(
    const CIMInstance& providerInstance,
    String& providerModuleName,
    String& providerName)
{
    Array<CIMKeyBinding> keys = providerInstance.getPath().getKeyBindings();

    for (Uint32 i = 0; i < keys.size(); i++)
    {
        if (keys[i].getName() == PEGASUS_PROPERTYNAME_NAME)
        {
            providerName = keys[i].getValue();
        }
        else if (keys[i].getName() == _PROPERTY_PROVIDERMODULENAME)
        {
            providerModuleName = keys[i].getValue();
        }
    }
}
开发者ID:brunolauze,项目名称:pegasus,代码行数:19,代码来源:ProviderIndicationCountTable.cpp

示例5: setObjectManagerStatistics

Boolean setObjectManagerStatistics(CIMClient & client, Boolean newState)
{

    CIMName gathStatName ("GatherStatisticalData");
    Array<CIMInstance> instancesObjectManager;
    CIMInstance instObjectManager;
    Uint32 prop_num;
    Array<CIMName> plA;
    plA.append(gathStatName);
    CIMPropertyList statPropertyList(plA);
    // Create property list that represents correct request
    // get instance.  Get only the gatherstatitistics property
    instancesObjectManager  = 
        client.enumerateInstances(PEGASUS_NAMESPACENAME_INTEROP,
            "CIM_ObjectManager",
            true, false, false, false, statPropertyList);
    PEGASUS_TEST_ASSERT(instancesObjectManager.size() == 1);
    instObjectManager = instancesObjectManager[0];
    // set correct path into instance
    instObjectManager.setPath(instancesObjectManager[0].getPath());
    
    prop_num = instObjectManager.findProperty(gathStatName);
    PEGASUS_TEST_ASSERT(prop_num != PEG_NOT_FOUND);
    
    instObjectManager.getProperty(prop_num).setValue(CIMValue(newState));
    
    client.modifyInstance(PEGASUS_NAMESPACENAME_INTEROP, instObjectManager,
         false, statPropertyList);
    CIMInstance updatedInstance = 
        client.getInstance(PEGASUS_NAMESPACENAME_INTEROP,
        instObjectManager.getPath(),
        false, false, false, statPropertyList);
    prop_num = updatedInstance.findProperty(gathStatName);
    PEGASUS_TEST_ASSERT(prop_num != PEG_NOT_FOUND);
    CIMProperty p = updatedInstance.getProperty(prop_num);
    CIMValue v = p.getValue();
    Boolean rtn;
    v.get(rtn);
    //// Need to get it again
    cout << "Updated Status= " << ((rtn)? "true" : "false") << endl;
    return(rtn);
}
开发者ID:host1812,项目名称:scx_plugin_public,代码行数:42,代码来源:CIMCLICommand.cpp

示例6: createInstance

CIMObjectPath CIMClientRep::createInstance(
    const CIMNamespaceName& nameSpace,
    const CIMInstance& newInstance
)
{
    compareObjectPathtoCurrentConnection(newInstance.getPath());
    AutoPtr<CIMRequestMessage> request(new CIMCreateInstanceRequestMessage(
                                           String::EMPTY,
                                           nameSpace,
                                           newInstance,
                                           QueueIdStack()));

    Message* message = _doRequest(request, CIM_CREATE_INSTANCE_RESPONSE_MESSAGE);

    CIMCreateInstanceResponseMessage* response =
        (CIMCreateInstanceResponseMessage*)message;

    AutoPtr<CIMCreateInstanceResponseMessage> destroyer(response);

    return(response->instanceName);
}
开发者ID:ncultra,项目名称:Pegasus-2.5,代码行数:21,代码来源:CIMClientRep.cpp

示例7: modifyInstance

void CIMClientRep::modifyInstance(
    const CIMNamespaceName& nameSpace,
    const CIMInstance& modifiedInstance,
    Boolean includeQualifiers,
    const CIMPropertyList& propertyList
)
{
    compareObjectPathtoCurrentConnection(modifiedInstance.getPath());
    AutoPtr<CIMRequestMessage> request(new CIMModifyInstanceRequestMessage(
                                           String::EMPTY,
                                           nameSpace,
                                           modifiedInstance,
                                           includeQualifiers,
                                           propertyList,
                                           QueueIdStack()));

    Message* message = _doRequest(request, CIM_MODIFY_INSTANCE_RESPONSE_MESSAGE);

    CIMModifyInstanceResponseMessage* response =
        (CIMModifyInstanceResponseMessage*)message;

    AutoPtr<CIMModifyInstanceResponseMessage> destroyer(response);
}
开发者ID:ncultra,项目名称:Pegasus-2.5,代码行数:23,代码来源:CIMClientRep.cpp

示例8: holder


//.........这里部分代码省略.........
                        currentNamespace, subclassName, true, false, false,
                        true, CIMPropertyList());

                    // Retrieve the Conforming Element
                    for (Uint32 k = 0, x = elementConformsInstances.size();
                        k < x; ++k)
                    {
                        CIMInstance & currentInstance =
                            elementConformsInstances[k];

                        // NOCHKSRC
                        // Make sure that the current instance points to the
                        // current profile ID.
                        CIMObjectPath profilePath =
                            getRequiredValue<CIMObjectPath>(
                                elementConformsInstances[k],
                                ELEMENTCONFORMSTOPROFILE_PROPERTY_CONFORMANTSTANDARD);
                        // DOCHKSRC
                        const Array<CIMKeyBinding> & keys =
                            profilePath.getKeyBindings();
                        if (keys.size() != 1)
                            continue;
                        if (keys.size() == 1 && keys[0].getValue() == profileId)
                        {
                            // NOCHKSRC
                            conformingElementPaths.append(
                                getRequiredValue<CIMObjectPath>(
                                currentInstance,
                                ELEMENTCONFORMSTOPROFILE_PROPERTY_MANAGEDELEMENT));
                            // DOCHKSRC
                        }
                    }
                }
                else
                {
                    // All of the instances of the current element in the
                    // corresponding namespace conform to the current profile.
                    Array<CIMObjectPath> paths =
                        cimomHandle.enumerateInstanceNames(opContext,
                            currentNamespace, currentElement);
                    // Set the namespace in the paths just in case
                    for (Uint32 k = 0, x = paths.size();
                        k < x; ++k)
                    {
                        CIMObjectPath & curPath = paths[k];
                        curPath.setNameSpace(currentNamespace);
                        curPath.setHost(hostName);
                    }
                    conformingElementPaths.appendArray(paths);
                }
            }
        }

        // Create the object path for the RegisteredProfile using the given
        // profileId.
        CIMObjectPath profilePath = buildDependencyReference(
            hostName, profileIds[i], PEGASUS_CLASSNAME_PG_REGISTEREDPROFILE);

        // Build all of the ElementConformsToProfile instances for the current
        // profile.
        for (Uint32 k = 0, x = conformingElementPaths.size(); k < x; ++k)
        {
            instances.append(buildElementConformsToProfile(profilePath,
                conformingElementPaths[k], elementConformsClass));
        }
    }

    // Now add the default instance: the association between the Server Profile
    // and the ObjectManager (if we're in the Interop namespace)
    if (opNamespace == PEGASUS_NAMESPACENAME_INTEROP)
    {
        // Build up the Object Path for the server profile version 1.1.0
        CIMObjectPath serverProfile = buildDependencyReference(
            hostName,
            buildProfileInstanceId(SNIA_NAME, "Server", SNIA_VER_110),
            PEGASUS_CLASSNAME_PG_REGISTEREDPROFILE);
        // Retrieve the Object Manager instance
        CIMInstance objManager = getObjectManagerInstance();

        instances.append(
            buildElementConformsToProfile(
                serverProfile,
                objManager.getPath(), 
                elementConformsClass));

        // Build up the Object Path for the server profile ver 1.2.0
        // and add the elementconformstoprofile association instance
        serverProfile = buildDependencyReference(
            hostName,
            buildProfileInstanceId(SNIA_NAME, "Server", SNIA_VER_120),
            PEGASUS_CLASSNAME_PG_REGISTEREDPROFILE);
        instances.append(
            buildElementConformsToProfile(
                serverProfile,
                objManager.getPath(), 
                elementConformsClass));
        
    }
    return instances;
}
开发者ID:host1812,项目名称:scx_plugin_public,代码行数:101,代码来源:ElementConformsToProfile.cpp

示例9: processInstance

CIMInstance ObjectNormalizer::processInstance(
    const CIMInstance& cimInstance) const
{
    // pre-checks
    if (!_enableNormalization || _cimClass.isUninitialized())
    {
        // do nothing
        return cimInstance;
    }

    /*
    // ATTN: moving similar logic to the response handlers because this
    // type of error should be checked regardless with or without
    // normalization enabled.
    if (cimInstance.isUninitialized())
    {
        throw CIMException(CIM_ERR_FAILED, "unintialized instance object.");
    }
    */

    CIMInstance normalizedInstance(_cimClass.getClassName());

    // proces object path
    normalizedInstance.setPath(
        processInstanceObjectPath(cimInstance.getPath()));

    // process instance qualifiers
    if (_includeQualifiers)
    {
        // propagate class qualifiers
        for (Uint32 i = 0, n = _cimClass.getQualifierCount(); i < n; i++)
        {
            CIMConstQualifier referenceQualifier = _cimClass.getQualifier(i);

            Uint32 pos =
                cimInstance.findQualifier(referenceQualifier.getName());

            // update value if qualifier is present in the specified property
            if (pos != PEG_NOT_FOUND)
            {
                CIMConstQualifier cimQualifier = cimInstance.getQualifier(pos);

                CIMQualifier normalizedQualifier =
                    _processQualifier(
                        referenceQualifier,
                        cimQualifier);

                normalizedInstance.addQualifier(normalizedQualifier);
            }
            else
            {
                normalizedInstance.addQualifier(referenceQualifier.clone());
            }
        }
    }

    // check property names and types. any properties in the class but not
    // in the instance are implicitly dropped.
    for (Uint32 i = 0, n = cimInstance.getPropertyCount(); i < n; i++)
    {
        CIMConstProperty instProperty = cimInstance.getProperty(i);

        Uint32 pos = _cimClass.findProperty(instProperty.getName());

        if (pos != PEG_NOT_FOUND)
        {
            CIMConstProperty cimProperty = _cimClass.getProperty(pos);

            CIMProperty normalizedProperty =
                processProperty(
                    cimProperty,
                    instProperty,
                    _includeQualifiers,
                    _includeClassOrigin,
                    _context.get(),
                    _nameSpace);

            normalizedInstance.addProperty(normalizedProperty);
        }
    }

    return normalizedInstance;
}
开发者ID:brunolauze,项目名称:pegasus,代码行数:83,代码来源:ObjectNormalizer.cpp

示例10: 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

示例11: 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

示例12: invokeMethod

/**
    When the "PropagateError" method is invoked, this function
    will read a CIM_Error embedded instance from the inParameters and use
    that instance to create an InstMethodIndication populating the Error[]
    property with the CIM_Error parameter and errorInstance stored in this
    class (if it's been created already). The output parameter of this method
    will contain the embedded instance received as input, and the newly
    created InstMethodIndication will be sent by the provider to any
    registered listeners.
*/
void EmbeddedInstanceProvider::invokeMethod(
        const OperationContext& context,
        const CIMObjectPath& objectReference,
        const CIMName& methodName,
        const Array<CIMParamValue>& inParameters,
        MethodResultResponseHandler& handler)
{
    // This should start sending indications with the stored Job instance
    // embedded in the InstMethodIndication
    handler.processing();
    if (!methodName.equal(CIMName("PropagateError")))
        throw CIMException(CIM_ERR_METHOD_NOT_AVAILABLE);

    if (inParameters.size() != 1)
    {
        throw CIMException(
            CIM_ERR_INVALID_PARAMETER, "Did not receive exactly 1 parameter");
    }

    CIMParamValue errorParam = inParameters[0];
    if (!String::equal(errorParam.getParameterName(), String("error")))
    {
        throw CIMException(
            CIM_ERR_INVALID_PARAMETER, "Did not find \"error\" parameter");
    }

    CIMInstance errorParamInst;
    errorParam.getValue().get(errorParamInst);
    if (errorParamInst.getPath().getClassName() != "PG_EmbeddedError")
    {
        throw CIMException(CIM_ERR_INVALID_PARAMETER);
    }
    errorParamInst.setPath(errorInstance->getPath());
    Array<CIMName> propList;
    for (unsigned int i = 0, n = errorParamInst.getPropertyCount(); i < n; i++)
    {
        propList.append(errorParamInst.getProperty(i).getName());
    }
    CIMInstance tmpErrorInstance(errorInstance->clone());
    if (!tmpErrorInstance.identical(errorParamInst))
    {
        throw Exception("Did not receive expected ErrorInstance");
    }

    // Build new indication instance
    CIMObjectPath indicationPath(System::getHostName(),
        CIMNamespaceName("test/EmbeddedInstance/Dynamic"),
        CIMName("PG_InstMethodIndication"));
    indicationInstance.reset(new CIMInstance("PG_InstMethodIndication"));
    indicationInstance->setPath(indicationPath);
    indicationInstance->addProperty(CIMProperty("MethodName",
        CIMValue(String("PropagateError"))));
    indicationInstance->addProperty(CIMProperty("PreCall",
        CIMValue(Boolean(false))));
    indicationInstance->addProperty(CIMProperty("SourceInstance",
        CIMValue(CIMObject(*errorInstance))));
    Array<CIMInstance> errorInstances;
    errorInstances.append(*errorInstance);
    errorInstances.append(*errorInstance);
    indicationInstance->addProperty(CIMProperty("Error",
        CIMValue(errorInstances)));

    handler.deliverParamValue(CIMParamValue(String("sameError"),
        CIMValue(errorParamInst)));
    handler.deliver(CIMValue(Uint32(1)));
    handler.complete();

    indicationHandler->deliver(*indicationInstance);
}
开发者ID:brunolauze,项目名称:pegasus,代码行数:79,代码来源:EmbeddedInstanceProvider.cpp

示例13: retrieveErrorInstance

int retrieveErrorInstance(CIMClient& client)
{
    try
    {
        PEGASUS_STD(cout) << "Getting error instance: " << errorPath.toString()
            << PEGASUS_STD(endl);
        CIMInstance ret = client.getInstance(
            TEST_NAMESPACE, errorPath, true, false, false, errorPropList);
        ret.setPath(errorPath);
        if (!errorInstance->identical(ret))
        {
            if (!ret.getPath().identical(errorInstance->getPath()))
            {
                PEGASUS_STD(cout) << "Object Paths not identical"
                    << PEGASUS_STD(endl);
            }
            PEGASUS_STD(cout) << "Error Instance and instance retrieved "
                << "through GetInstance operation not the same\n"
                << PEGASUS_STD(endl);
            PEGASUS_STD(cout) << "Local Error Instance: "
                << errorInstance->getPath().toString() << PEGASUS_STD(endl);
            for (unsigned int i = 0, n = errorInstance->getPropertyCount();
                 i < n; i++)
            {
                CIMProperty prop = errorInstance->getProperty(i);
                PEGASUS_STD(cout) << i << ". " << prop.getName().getString()
                    << prop.getValue().toString() << PEGASUS_STD(endl);
            }

            PEGASUS_STD(cout) << "Retrieved Error Instance: " <<
                ret.getPath().toString() << PEGASUS_STD(endl);
            for (unsigned int i = 0, n = ret.getPropertyCount();
                 i < n; i++)
            {
                CIMProperty prop = ret.getProperty(i);
                PEGASUS_STD(cout) << i << ". " << prop.getName().getString()
                    << prop.getValue().toString() << PEGASUS_STD(endl);
            }

            CIMProperty localEmbeddedProp = errorInstance->getProperty(
                errorInstance->findProperty("EmbeddedInst"));
            CIMProperty retEmbeddedProp = ret.getProperty(
                ret.findProperty("EmbeddedInst"));
            CIMInstance localEmbeddedInst;
            CIMInstance retEmbeddedInst;
            localEmbeddedProp.getValue().get(localEmbeddedInst);
            retEmbeddedProp.getValue().get(retEmbeddedInst);
            CIMObjectPath localEmbeddedPath = localEmbeddedInst.getPath();
            CIMObjectPath retEmbeddedPath = retEmbeddedInst.getPath();

            PEGASUS_STD(cout) << "Local Embedded Path: " <<
                localEmbeddedPath.toString() << PEGASUS_STD(endl);
            PEGASUS_STD(cout) << "Ret Embedded Path: " <<
                retEmbeddedPath.toString() << PEGASUS_STD(endl);
            return -1;
        }
    }
    catch (Exception& e)
    {
        cout << "Exception caught while getting error instance: "
            << e.getMessage() << endl;
        return -1;
    }

    try
    {
        Array<CIMInstance> ret = client.enumerateInstances(
            TEST_NAMESPACE,
            "PG_EmbeddedError",
            true,
            true,
            false,
            false,
            errorPropList);
        int count = ret.size();
        for (int i = 0; i < count; i++)
        {
            if (!errorInstance->identical(ret[i]))
            {
                printf("Error instance and instance retrieved through "
                    "EnumerateInstances operation not the same\n");
                return -1;
            }
        }
    }
    catch (Exception& e)
    {
        cout << "Exception caught while enumerating error instances: "
            << e.getMessage() << endl;
        return -1;
    }

    return 0;
}
开发者ID:rdobson,项目名称:openpegasus,代码行数:94,代码来源:EmbeddedInstanceTest.cpp

示例14: modifyInstance

/////////////////////////////////////////////////////////////////////////////
// WMIInstanceProvider::modifyInstance
//
// ///////////////////////////////////////////////////////////////////////////
void WMIInstanceProvider::modifyInstance(
    const String& nameSpace,
    const String& userName,
    const String& password,
    const CIMInstance& modifiedInstance,
    Boolean includeQualifiers,
    const CIMPropertyList& propertylist)
{
    PEG_METHOD_ENTER(TRC_WMIPROVIDER,"WMIClassProvider::modifyInstance()");

    HRESULT hr;
    CComPtr<IWbemClassObject> pClass;
    CComPtr<IWbemClassObject> pInstance;

    setup(nameSpace, userName, password);

    PEG_TRACE((TRC_WMIPROVIDER,
                  Tracer::LEVEL3,
                  "ModifyInstance() - nameSpace %s, userName %s",
                  nameSpace.getCString(),
                  userName.getCString()));

    if (!m_bInitialized)
    {
        PEG_TRACE((TRC_WMIPROVIDER, Tracer::LEVEL1,
            "WMIInstanceProvider::ModifyInstance - m_bInitilized= %x, "
            "throw CIM_ERR_FAILED exception",
            m_bInitialized));

        throw CIMException(CIM_ERR_FAILED);
    }

    // Check if the instance's class is valid.
    String className = modifiedInstance.getClassName().getString();

    if (!(_collector->getObject(&pClass, className)))
    {
        if (pClass)
            pClass.Release();

        throw CIMException(CIM_ERR_INVALID_CLASS);
    }
    else if (_collector->isInstance(pClass))
    {
        if (pClass)
            pClass.Release();

        throw CIMException(CIM_ERR_INVALID_PARAMETER);
    }

    if (pClass)
        pClass.Release();

    // Get the instance path
    CIMObjectPath objPath = modifiedInstance.getPath();

    // Get the name of the instance
    String instanceName = getObjectName(objPath);

    // Check if the instance exists
    if (!(_collector->getObject(&pInstance, instanceName)))
    {
        if (pInstance)
            pInstance.Release();

        throw CIMException(CIM_ERR_NOT_FOUND);
    }
    else if (!(_collector->isInstance(pInstance)))
    {
        if (pInstance)
            pInstance.Release();

        throw CIMException(CIM_ERR_INVALID_PARAMETER);
    }

    // Set the properties that are into propertylist
    Array<CIMName> listNames;
    listNames = propertylist.getPropertyNameArray();

    bool foundInArray;
    bool bPropertySet = false;

    for(Uint32 i = 0; i < modifiedInstance.getPropertyCount(); i++)
    {
        CComVariant v;
        CIMProperty property = modifiedInstance.getProperty(i).clone();
        String sPropName = property.getName().getString();

        // change only the properties defined into the array
        // if the array is null, change all properties
        if (propertylist.isNull())
        {
            foundInArray = true;
        }
        else
        {
//.........这里部分代码省略.........
开发者ID:rdobson,项目名称:openpegasus,代码行数:101,代码来源:WMIInstanceProvider.cpp


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