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


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

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


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

示例1: buildElementConformsToProfile

PEGASUS_NAMESPACE_BEGIN

//
// Given the two references in the association, this function creates an
// instance of the PG_ElementConformsToProfile class.
//
CIMInstance buildElementConformsToProfile(
    const CIMObjectPath & currentProfile,
    const CIMObjectPath & currentElement,
    const CIMClass & elementConformsClass)
{
    Array<CIMName> elementPropArray;
    elementPropArray.append(
        ELEMENTCONFORMSTOPROFILE_PROPERTY_CONFORMANTSTANDARD);
    elementPropArray.append(
        ELEMENTCONFORMSTOPROFILE_PROPERTY_MANAGEDELEMENT);
    CIMPropertyList elementPropList(elementPropArray);

    CIMInstance tmpInstance =
        elementConformsClass.buildInstance(false, false,
            elementPropList);
    setPropertyValue(tmpInstance,
        ELEMENTCONFORMSTOPROFILE_PROPERTY_CONFORMANTSTANDARD,
        currentProfile);
    setPropertyValue(tmpInstance,
        ELEMENTCONFORMSTOPROFILE_PROPERTY_MANAGEDELEMENT,
        currentElement);
    tmpInstance.setPath(tmpInstance.buildPath(
        elementConformsClass));
    return tmpInstance;
}
开发者ID:host1812,项目名称:scx_plugin_public,代码行数:31,代码来源:ElementConformsToProfile.cpp

示例2: createInstance

/**
    Stores a copy of the provided instance locally in the errorInstance
    class property, and also creates a copy of the instance in the static
    repository namespace. The instance is then read back out of the repository
    and compared against the one stored by the class.
*/
void EmbeddedInstanceProvider::createInstance(
    const OperationContext& context,
    const CIMObjectPath& ref,
    const CIMInstance& obj,
    ObjectPathResponseHandler& handler)
{
    handler.processing();
    errorInstance.reset(new CIMInstance(obj));
    Array<CIMName> propNameList;
    propNameList.append(CIMName("errorKey"));
    propNameList.append(CIMName("EmbeddedInst"));
    CIMPropertyList propList(propNameList);
    CIMClass objClass = cimom.getClass(
        context,
        STATIC_REPOSITORY,
        obj.getClassName(),
        false,
        true,
        false,
        propList);
    CIMObjectPath objPath = obj.buildPath(objClass);
    errorInstance->setPath(objPath);

    repositoryPath = cimom.createInstance(
        context, STATIC_REPOSITORY, *errorInstance);

    CIMInstance repositoryInstance = cimom.getInstance(
        context,
        STATIC_REPOSITORY,
        repositoryPath,
        false,
        false,
        false,
        propList);
    repositoryInstance.setPath(repositoryPath);
    
    if (!errorInstance->identical(repositoryInstance))
    {
        throw Exception(
            "Repository instance and local instance for embedded error not "
                "identical");
    }

    handler.deliver(objPath);
    handler.complete();
}
开发者ID:brunolauze,项目名称:pegasus,代码行数:52,代码来源:EmbeddedInstanceProvider.cpp

示例3: test04

//
//  Test identical() function with keys that are references
//
void test04()
{
    //
    // Create classes A and B referenced classes, C - Association
    //
    CIMClass classA (CIMName ("A"), CIMName ());
    CIMProperty propertyX ("x", String ());
    propertyX.addQualifier (CIMQualifier (CIMName ("Key"), true));
    CIMProperty propertyY ("y", String ());
    propertyY.addQualifier (CIMQualifier (CIMName ("Key"), true));
    CIMProperty propertyZ ("z", String ());
    propertyZ.addQualifier (CIMQualifier (CIMName ("Key"), true));
    classA.addProperty (propertyX);
    classA.addProperty (propertyY);
    classA.addProperty (propertyZ);

    CIMClass classB ("B");
    CIMProperty propertyQ ("q", String ());
    propertyQ.addQualifier (CIMQualifier (CIMName ("Key"), true));
    CIMProperty propertyR ("r", String ());
    propertyR.addQualifier (CIMQualifier (CIMName ("Key"), true));
    CIMProperty propertyS ("s", String ());
    propertyS.addQualifier (CIMQualifier (CIMName ("Key"), true));
    classB.addProperty (propertyQ);
    classB.addProperty (propertyR);
    classB.addProperty (propertyS);

    CIMClass classC ("C");
    CIMProperty propertyA ("a", CIMValue ());
    propertyA.addQualifier (CIMQualifier (CIMName ("Key"), true));
    CIMProperty propertyB ("b", CIMValue ());
    propertyB.addQualifier (CIMQualifier (CIMName ("Key"), true));
    classC.addProperty (propertyA);
    classC.addProperty (propertyB);

    //
    //  Create instances of each classa
    //
    CIMInstance instanceA (CIMName ("A"));
    instanceA.addProperty (CIMProperty (CIMName ("x"), String ("rose")));
    instanceA.addProperty (CIMProperty (CIMName ("y"), String ("lavender")));
    instanceA.addProperty (CIMProperty (CIMName ("z"), String ("rosemary")));
    CIMObjectPath aPath = instanceA.buildPath (classA);
    CIMObjectPath aPath2 ("A.y=\"lavender\",x=\"rose\",z=\"rosemary\"");
    PEGASUS_TEST_ASSERT (aPath.identical (aPath2));

    CIMInstance instanceB (CIMName ("B"));
    instanceB.addProperty (CIMProperty (CIMName ("q"),
        String ("pelargonium")));
    instanceB.addProperty (CIMProperty (CIMName ("r"), String ("thyme")));
    instanceB.addProperty (CIMProperty (CIMName ("s"), String ("sage")));

    // Test to assure that the buildpath function works.
    CIMObjectPath bPath = instanceB.buildPath (classB);
    CIMObjectPath bPath2 ("B.s=\"sage\",q=\"pelargonium\",r=\"thyme\"");
    PEGASUS_TEST_ASSERT (bPath.identical (bPath2));

    // Build instance of C and build path from buildPath function.
    CIMInstance instanceC (CIMName ("C"));
    instanceC.addProperty (CIMProperty (CIMName ("a"), aPath, 0,
        CIMName ("A")));
    instanceC.addProperty (CIMProperty (CIMName ("b"), bPath, 0,
        CIMName ("B")));
    CIMObjectPath cPath = instanceC.buildPath (classC);

    // Build CIMObjectPath from keybindings.
    Array <CIMKeyBinding> keyBindings;
    CIMKeyBinding aBinding ("a", "A.y=\"lavender\",x=\"rose\",z=\"rosemary\"",
        CIMKeyBinding::REFERENCE);
    CIMKeyBinding bBinding ("b", "B.s=\"sage\",q=\"pelargonium\",r=\"thyme\"",
        CIMKeyBinding::REFERENCE);
    keyBindings.append (aBinding);
    keyBindings.append (bBinding);

    CIMObjectPath cPath2 ("", CIMNamespaceName (),
        cPath.getClassName (), keyBindings);

    // Assert that the CIMObjectPaths for C from build path and direct
    // from keybindings are equal.
    PEGASUS_TEST_ASSERT (cPath.identical (cPath2));

    // ATTN: KS 25 Feb 2003 P3 - Think we can extend these tests
    // since this is creation of classes and
    // instnaces for associations and referenced classes.
}
开发者ID:brunolauze,项目名称:pegasus,代码行数:88,代码来源:Reference.cpp

示例4: TestAssociations

void TestAssociations(CIMRepository& r)
{
    String nameSpace = "root";
    {
	CIMObjectPath instanceName = CIMObjectPath ("X.key=\"John Smith\"");

	Array<CIMObjectPath> names = r.associatorNames(
	    nameSpace,
	    instanceName,
	    CIMName ("A"),
	    CIMName ("Y"),
	    "left",
	    "right");

	assert(names.size() == 1);
	Boolean cond = names[0] == CIMObjectPath("Y.key=\"John Jones\"");
	assert(cond);
    }

    {
	CIMObjectPath instanceName = CIMObjectPath ("X.key=\"John Smith\"");

	Array<CIMObject> result = r.associators(
	    nameSpace,
	    instanceName,
	    CIMName ("a"),
	    CIMName ("y"),
	    "LEFT",
	    "RIGHT");

	assert(result.size() == 1);

	CIMObjectPath cimReference = result[0].getPath ();
	CIMInstance cimInstance = CIMInstance(result[0]);

	CIMClass tmpClass = r.getClass(nameSpace, cimInstance.getClassName());
	CIMObjectPath tmpInstanceName = cimInstance.buildPath(tmpClass);

	Boolean t = tmpInstanceName == CIMObjectPath("Y.key=\"John Jones\"");
	assert(t);
	// result[0].print();
    }

    {
	CIMObjectPath instanceName = CIMObjectPath ("X.key=\"John Smith\"");

	Array<CIMObjectPath> result = r.referenceNames(
	    nameSpace,
	    instanceName,
	    CIMName ("A"),
	    "left");

	assert(result.size() == 1);

	CIMObjectPath tmp = CIMObjectPath ("A."
	    "left=\"x.key=\\\"John Smith\\\"\","
	    "right=\"y.key=\\\"John Jones\\\"\"");
	
	Boolean cond = (result[0] == tmp);
	assert(cond);
    }

    {
	CIMObjectPath instanceName = CIMObjectPath ("X.key=\"John Smith\"");

	Array<CIMObject> result = r.references(
	    nameSpace,
	    instanceName,
	    CIMName ("A"),
	    "left");

	assert(result.size() == 1);

	CIMClass tmpClass = r.getClass(
	    nameSpace, CIMInstance(result[0]).getClassName());

	CIMObjectPath tmpInstanceName = 
	    CIMInstance(result[0]).buildPath(tmpClass);

	CIMObjectPath tmp = CIMObjectPath ("A."
	    "left=\"x.key=\\\"John Smith\\\"\","
	    "right=\"y.key=\\\"John Jones\\\"\"");
	
	Boolean cond = (tmpInstanceName == tmp);
	assert(cond);
    }

    // Delete all the object we created:
    {
	// First delete the association:

	CIMObjectPath assocInstanceName = CIMObjectPath ("A."
	    "left=\"x.key=\\\"John Smith\\\"\","
	    "right=\"y.key=\\\"John Jones\\\"\"");

	r.deleteInstance(nameSpace, assocInstanceName);
    }
}
开发者ID:ncultra,项目名称:Pegasus-2.5,代码行数:98,代码来源:CompAssoc.cpp


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