⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 subscription.cpp

📁 Pegasus is an open-source implementationof the DMTF CIM and WBEM standards. It is designed to be por
💻 CPP
📖 第 1 页 / 共 5 页
字号:
    subscriptionKeyBindings.append (CIMKeyBinding ("Filter",        filterPath.toString (), CIMKeyBinding::REFERENCE));    subscriptionKeyBindings.append (CIMKeyBinding ("Handler",        handlerPath.toString (), CIMKeyBinding::REFERENCE));    CIMObjectPath subscriptionPath ("", CIMNamespaceName (),        PEGASUS_CLASSNAME_INDSUBSCRIPTION, subscriptionKeyBindings);    return subscriptionPath;}CIMObjectPath _buildSubscriptionPath    (const String & filterName,     const CIMName & handlerClass,     const String & handlerName){    return _buildSubscriptionPath (filterName, handlerClass, handlerName,        String::EMPTY, String::EMPTY, CIMNamespaceName (), CIMNamespaceName ());}CIMInstance _buildSubscriptionInstance    (const CIMObjectPath & filterPath,     const CIMName & handlerClass,     const CIMObjectPath & handlerPath){    CIMInstance subscriptionInstance (PEGASUS_CLASSNAME_INDSUBSCRIPTION);    subscriptionInstance.addProperty (CIMProperty (CIMName ("Filter"),        filterPath, 0, PEGASUS_CLASSNAME_INDFILTER));    subscriptionInstance.addProperty (CIMProperty (CIMName ("Handler"),        handlerPath, 0, handlerClass));    return subscriptionInstance;}void _checkFilterOrHandlerPath    (const CIMObjectPath & path,     const CIMName & className,     const String & name){    PEGASUS_TEST_ASSERT (path.getClassName () == className);    Array <CIMKeyBinding> keyBindings = path.getKeyBindings ();    Boolean SCCNfound = false;    Boolean SNfound = false;    Boolean CCNfound = false;    Boolean Nfound = false;    for (Uint32 i = 0; i < keyBindings.size (); i++)    {        if (keyBindings [i].getName ().equal ("SystemCreationClassName"))        {            SCCNfound = true;            PEGASUS_TEST_ASSERT (keyBindings [i].getValue () ==                System::getSystemCreationClassName ());        }        else if (keyBindings [i].getName ().equal ("SystemName"))        {            SNfound = true;            PEGASUS_TEST_ASSERT (keyBindings [i].getValue () ==                System::getFullyQualifiedHostName ());        }        else if (keyBindings [i].getName ().equal ("CreationClassName"))        {            CCNfound = true;            PEGASUS_TEST_ASSERT (keyBindings [i].getValue () ==                className.getString ());        }        else if (keyBindings [i].getName ().equal ("Name"))        {            Nfound = true;            PEGASUS_TEST_ASSERT (keyBindings [i].getValue () == name);        }        else        {            PEGASUS_TEST_ASSERT (false);        }    }    PEGASUS_TEST_ASSERT (SCCNfound);    PEGASUS_TEST_ASSERT (SNfound);    PEGASUS_TEST_ASSERT (CCNfound);    PEGASUS_TEST_ASSERT (Nfound);}void _checkSubscriptionPath    (const CIMObjectPath & path,     const String & filterName,     const CIMName & handlerClass,     const String & handlerName,     const String & filterHost,     const String & handlerHost,     const CIMNamespaceName & filterNS,     const CIMNamespaceName & handlerNS){    PEGASUS_TEST_ASSERT (path.getClassName () == PEGASUS_CLASSNAME_INDSUBSCRIPTION);    Array <CIMKeyBinding> keyBindings = path.getKeyBindings ();    Boolean filterFound = false;    Boolean handlerFound = false;    for (Uint32 i = 0; i < keyBindings.size (); i++)    {        if (keyBindings [i].getName ().equal ("Filter"))        {            filterFound = true;            CIMObjectPath filterPath = _buildFilterOrHandlerPath                (PEGASUS_CLASSNAME_INDFILTER, filterName, filterHost, filterNS);            PEGASUS_TEST_ASSERT (keyBindings [i].getValue () ==                filterPath.toString ());        }        else if (keyBindings [i].getName ().equal ("Handler"))        {            handlerFound = true;            CIMObjectPath handlerPath = _buildFilterOrHandlerPath                (handlerClass, handlerName, handlerHost, handlerNS);            PEGASUS_TEST_ASSERT (keyBindings [i].getValue () ==                handlerPath.toString ());        }        else        {            PEGASUS_TEST_ASSERT (false);        }    }    PEGASUS_TEST_ASSERT (filterFound);    PEGASUS_TEST_ASSERT (handlerFound);}void _checkSubscriptionPath    (const CIMObjectPath & path,     const String & filterName,     const CIMName & handlerClass,     const String & handlerName){    _checkSubscriptionPath (path, filterName, handlerClass, handlerName,        String::EMPTY, String::EMPTY, CIMNamespaceName (), CIMNamespaceName ());}void _checkStringProperty    (CIMInstance & instance,     const String & name,     const String & value,     Boolean null = false){    Uint32 pos = instance.findProperty (name);    PEGASUS_TEST_ASSERT (pos != PEG_NOT_FOUND);    CIMProperty theProperty = instance.getProperty (pos);    CIMValue theValue = theProperty.getValue ();    PEGASUS_TEST_ASSERT (theValue.getType () == CIMTYPE_STRING);    PEGASUS_TEST_ASSERT (!theValue.isArray ());    if (null)    {        PEGASUS_TEST_ASSERT (theValue.isNull ());    }    else    {        PEGASUS_TEST_ASSERT (!theValue.isNull ());        String result;        theValue.get (result);        if (verbose)        {            if (result != value)            {                cerr << "Property value comparison failed.  ";                cerr << "Expected " << value << "; ";                cerr << "Actual property value was " << result << "." << endl;            }        }        PEGASUS_TEST_ASSERT (result == value);    }}void _checkUint16Property    (CIMInstance & instance,     const String & name,     Uint16 value){    Uint32 pos = instance.findProperty (name);    PEGASUS_TEST_ASSERT (pos != PEG_NOT_FOUND);    CIMProperty theProperty = instance.getProperty (pos);    CIMValue theValue = theProperty.getValue ();    PEGASUS_TEST_ASSERT (theValue.getType () == CIMTYPE_UINT16);    PEGASUS_TEST_ASSERT (!theValue.isArray ());    PEGASUS_TEST_ASSERT (!theValue.isNull ());    Uint16 result;    theValue.get (result);    if (verbose)    {        if (result != value)        {            cerr << "Property value comparison failed.  ";            cerr << "Expected " << value << "; ";            cerr << "Actual property value was " << result << "." << endl;        }    }    PEGASUS_TEST_ASSERT (result == value);}void _checkUint32Property    (CIMInstance & instance,     const String & name,     Uint32 value){    Uint32 pos = instance.findProperty (name);    PEGASUS_TEST_ASSERT (pos != PEG_NOT_FOUND);    CIMProperty theProperty = instance.getProperty (pos);    CIMValue theValue = theProperty.getValue ();    PEGASUS_TEST_ASSERT (theValue.getType () == CIMTYPE_UINT32);    PEGASUS_TEST_ASSERT (!theValue.isArray ());    PEGASUS_TEST_ASSERT (!theValue.isNull ());    Uint32 result;    theValue.get (result);    if (verbose)    {        if (result != value)        {            cerr << "Property value comparison failed.  ";            cerr << "Expected " << value << "; ";            cerr << "Actual property value was " << result << "." << endl;        }    }    PEGASUS_TEST_ASSERT (result == value);}void _checkUint64Property    (CIMInstance & instance,     const String & name,     Uint64 value){    Uint32 pos = instance.findProperty (name);    PEGASUS_TEST_ASSERT (pos != PEG_NOT_FOUND);    CIMProperty theProperty = instance.getProperty (pos);    CIMValue theValue = theProperty.getValue ();    PEGASUS_TEST_ASSERT (theValue.getType () == CIMTYPE_UINT64);    PEGASUS_TEST_ASSERT (!theValue.isArray ());    PEGASUS_TEST_ASSERT (!theValue.isNull ());    Uint64 result;    theValue.get (result);    if (verbose)    {        if (result != value)        {            char buffer [32];  // Should need 21 chars max            sprintf (buffer, "%" PEGASUS_64BIT_CONVERSION_WIDTH "u", value);            cerr << "Property value comparison failed.  ";            cerr << "Expected " << buffer << "; ";            sprintf (buffer, "%" PEGASUS_64BIT_CONVERSION_WIDTH "u", result);            cerr << "Actual property value was " << buffer << "." << endl;        }    }    PEGASUS_TEST_ASSERT (result == value);}void _checkExceptionCode    (const CIMException & e,     const CIMStatusCode expectedCode){    if (verbose)    {        if (e.getCode () != expectedCode)        {            cerr << "CIMException comparison failed.  ";            cerr << "Expected " << cimStatusCodeToString (expectedCode) << "; ";            cerr << "Actual exception was " << e.getMessage () << "." << endl;        }    }    PEGASUS_TEST_ASSERT (e.getCode () == expectedCode);}void _deleteSubscriptionInstance    (CIMClient & client,     const String & filterName,     const CIMName & handlerClass,     const String & handlerName,     const String & filterHost,     const String & handlerHost,     const CIMNamespaceName & filterNS,     const CIMNamespaceName & handlerNS,     const CIMNamespaceName & subscriptionNS){    CIMObjectPath subscriptionPath = _buildSubscriptionPath        (filterName, handlerClass, handlerName, filterHost, handlerHost,        filterNS, handlerNS);    client.deleteInstance (subscriptionNS, subscriptionPath);}void _deleteSubscriptionInstance    (CIMClient & client,     const String & filterName,     const CIMName & handlerClass,     const String & handlerName){    _deleteSubscriptionInstance (client, filterName, handlerClass, handlerName,        String::EMPTY, String::EMPTY,        CIMNamespaceName (), CIMNamespaceName (), PEGASUS_NAMESPACENAME_INTEROP);}void _deleteHandlerInstance    (CIMClient & client,     const CIMName & className,     const String & name,     const CIMNamespaceName & nameSpace){    CIMObjectPath path = _buildFilterOrHandlerPath (className, name);    client.deleteInstance (nameSpace, path);}void _deleteHandlerInstance    (CIMClient & client,     const CIMName & className,     const String & name){    _deleteHandlerInstance (client, className, name,

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -