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


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

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


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

示例1: test01


//.........这里部分代码省略.........
    instance1.addProperty(CIMProperty(CIMName("message"), String("Goodbye")));

    assert(instance1.findProperty(CIMName("message")) != PEG_NOT_FOUND);

    assert(instance1.findProperty(CIMName("count")) == PEG_NOT_FOUND);
    assert(instance1.findProperty(CIMName("ratio")) == PEG_NOT_FOUND);
    assert(instance1.findProperty(CIMName("nuts")) == PEG_NOT_FOUND);
    assert(instance1.getPropertyCount() == 1);

    if (verbose)
    {
        XmlWriter::printInstanceElement(instance1);
    }

    Resolver::resolveInstance(instance1, context, NAMESPACE, true);

    if (verbose)
    {
        XmlWriter::printInstanceElement(instance1);
    }

    // Now test for properties after resolution.

    assert(instance1.findProperty(CIMName("message")) != PEG_NOT_FOUND);
    assert(instance1.findProperty(CIMName("count")) != PEG_NOT_FOUND);
    assert(instance1.findProperty(CIMName("ratio")) != PEG_NOT_FOUND);
    assert(instance1.findProperty(CIMName("nuts")) == PEG_NOT_FOUND);
    assert(instance1.getPropertyCount() == 3);

    // Now remove a property

    Uint32 posProperty;
    posProperty = instance1.findProperty(CIMName("count"));
    instance1.removeProperty(posProperty);

    assert(instance1.findProperty(CIMName("message")) != PEG_NOT_FOUND);
    assert(instance1.findProperty(CIMName("count")) == PEG_NOT_FOUND);
    assert(instance1.findProperty(CIMName("ratio")) != PEG_NOT_FOUND);
    assert(instance1.findProperty(CIMName("nuts")) == PEG_NOT_FOUND);

    assert(instance1.getPropertyCount() == 2);

    // Instance qualifier tests

    CIMQualifier cq=instance1.getQualifier(instance1.findQualifier(
        CIMName("classcounter")));

    const CIMInstance instance2 = instance1.clone();
    assert(instance2.identical(instance1));
    assert(instance1.findQualifier(CIMName("nuts")) == PEG_NOT_FOUND);
    assert(instance2.findQualifier(CIMName("nuts")) == PEG_NOT_FOUND);
    assert(instance1.getQualifierCount() != 4);
    assert(instance1.getQualifierCount() == 1);
    assert(instance2.getQualifierCount() == 1);

    if (verbose)
    {
        XmlWriter::printInstanceElement(instance2);
    }

    // Tests for CIMConstInstance
    CIMConstInstance cinstance1(CIMName("MyClass")), cinstance3;
    CIMConstInstance ccopy(cinstance1);

    cinstance1 = instance1;
    assert(cinstance1.identical(instance1));

    assert(cinstance1.getQualifierCount() == 1);
    CIMConstQualifier ccq = cinstance1.getQualifier(cinstance1.findQualifier(
        CIMName("classcounter")));
    assert(cinstance1.findProperty(CIMName("message")) != PEG_NOT_FOUND);
    CIMConstProperty ccp =
        cinstance1.getProperty(cinstance1.findProperty(CIMName("message")));

    cinstance3 = cinstance1;
    assert(cinstance3.identical(cinstance1));

    assert(cinstance1.getClassName() == CIMName("MyClass"));
    assert(cinstance1.getClassName().equal(CIMName("MyClass")));
    assert(cinstance1.getClassName().equal(CIMName("MYCLASS")));
    assert(cinstance1.getClassName().equal(CIMName("myclass")));
    assert(!cinstance1.getClassName().equal(CIMName("blob")));

    assert(cinstance1.getQualifierCount() != 4);
    assert(cinstance1.getPropertyCount() == 2);

    CIMConstInstance cinstance2 = cinstance1.clone();
    assert(cinstance2.identical(cinstance1));

    if (verbose)
    {
        XmlWriter::printInstanceElement(cinstance1);
    }

    cinstance1.buildPath(class1);

    assert( !cinstance1.isUninitialized() );

    delete context;
}
开发者ID:ncultra,项目名称:Pegasus-2.5,代码行数:101,代码来源:InstanceDecl.cpp

示例2: test04


//.........这里部分代码省略.........
        pl1.set(pl1Array);

        CIMInstance newInstance = class1.buildInstance(false, true, pl1);

        assert(newInstance.getPropertyCount() == 1);
        assert(newInstance.findProperty("ratio") != PEG_NOT_FOUND);
        assert(newInstance.findProperty("blob") == PEG_NOT_FOUND);
        assert(newInstance.findProperty("message") == PEG_NOT_FOUND);
        assert(newInstance.getQualifierCount() == 0);
    }

    ///////////////////////////////////////////////////////////////////////
    //
    // Instance Filtering function tests
    //
    ///////////////////////////////////////////////////////////////////////

    // build instance as starting point for tests.
    CIMInstance tstInstance =
        class1.buildInstance(true, true, CIMPropertyList());

    //
    // Test complete copy, no change
    //
    {
        if (verbose)
        {
            cout << "Test1" << endl;
        }

        CIMInstance filterInstance = tstInstance.clone();
        filterInstance.filter(true, true, CIMPropertyList());

        assert(tstInstance.identical(filterInstance));
        assert(filterInstance.getPropertyCount() == 3);
        assert(filterInstance.getQualifierCount() ==
            tstInstance.getQualifierCount());
    }

    //
    // Filter to one property, ratio
    //
    {
        if (verbose)
        {
            cout << "Test2" << endl;
        }

        Array<CIMName> pl1Array;
        pl1Array.append("ratio");
        CIMPropertyList pl1(pl1Array);

        CIMInstance filterInstance = tstInstance.clone();
        filterInstance.filter(true, true, pl1);

        if (verbose)
        {
            XmlWriter::printInstanceElement(filterInstance);
        }

        assert(filterInstance.getPropertyCount() == 1);
        assert(filterInstance.findProperty("ratio") != PEG_NOT_FOUND);
        assert(_propertyIdentical("ratio", filterInstance, tstInstance));
        assert(filterInstance.getQualifierCount() ==
                tstInstance.getQualifierCount());
    }
开发者ID:ncultra,项目名称:Pegasus-2.5,代码行数:67,代码来源:InstanceDecl.cpp


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