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


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

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


在下文中一共展示了CIMInstance::getQualifierCount方法的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

//
// Test of the Instance creation and instance filtering
//
void test04()
{
    if (verbose)
    {
        cout << "Test04 - Create instance from Class. " << endl;
    }

    const CIMNamespaceName NAMESPACE = CIMNamespaceName("/zzz");

    // Create and populate a declaration context:

    SimpleDeclContext* context = new SimpleDeclContext;

    context->addQualifierDecl(
        NAMESPACE, CIMQualifierDecl(CIMName("counter"), false,
        CIMScope::PROPERTY));

    context->addQualifierDecl(
        NAMESPACE, CIMQualifierDecl(CIMName("classcounter"), false,
        CIMScope::CLASS));

    context->addQualifierDecl(
        NAMESPACE, CIMQualifierDecl(CIMName("min"), String(),
        CIMScope::PROPERTY));

    context->addQualifierDecl(
        NAMESPACE, CIMQualifierDecl(CIMName("max"), String(),
        CIMScope::PROPERTY));

    context->addQualifierDecl(NAMESPACE,
        CIMQualifierDecl(CIMName("Description"), String(),
        CIMScope::PROPERTY));

    CIMClass class1(CIMName("MyClass"));

    class1
        .addProperty(CIMProperty(CIMName("count"), Uint32(55))
            .addQualifier(CIMQualifier(CIMName("counter"), true))
            .addQualifier(CIMQualifier(CIMName("min"), String("0")))
            .addQualifier(CIMQualifier(CIMName("max"), String("1"))))
        .addProperty(CIMProperty(CIMName("message"), String("Hello"))
            .addQualifier(CIMQualifier(CIMName("description"),
                String("My Message"))))
        .addProperty(CIMProperty(CIMName("ratio"), Real32(1.5)));


    Resolver::resolveClass(class1, context, NAMESPACE);
    context->addClass(NAMESPACE, class1);


    if (verbose)
    {
        XmlWriter::printClassElement(class1);
    }

    //
    // Create instance with qualifiers, classorigin, and Null propertyList
    //
    {
        CIMInstance newInstance;

        newInstance = class1.buildInstance(true, true, CIMPropertyList());

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

        assert(newInstance.getPropertyCount() == class1.getPropertyCount());
        assert(newInstance.getQualifierCount() == class1.getQualifierCount());
        assert(newInstance.findProperty("ratio") != PEG_NOT_FOUND);
        assert(newInstance.findProperty("message") != PEG_NOT_FOUND);

    }

    //
    // Test with include qualifiers false. Should be no qualifiers in result
    //
    {
        CIMInstance newInstance =
            class1.buildInstance(false, true, CIMPropertyList());

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

    //
    // Test with empty property list.  Should have no properties.
    //
    {
        Array<CIMName> pl1Array;
        CIMPropertyList pl1(pl1Array);

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

//.........这里部分代码省略.........
开发者ID:ncultra,项目名称:Pegasus-2.5,代码行数:101,代码来源:InstanceDecl.cpp


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