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


C++ CIMValue类代码示例

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


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

示例1: _checkStringValue

void _checkStringValue (CIMValue & theValue,
    const String & value,
    Boolean null = false)
{
    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);
    }
}
开发者ID:brunolauze,项目名称:pegasus,代码行数:29,代码来源:TestCMPIBroker.cpp

示例2: methodName

void _sendIndicationShouldBeBlocked 
    (CIMClient & client)
{
    Array <CIMParamValue> inParams;
    Array <CIMParamValue> outParams;
    Array <CIMKeyBinding> keyBindings;
    Sint32 result;

    CIMName methodName ("SendTestIndication");
    CIMObjectPath className (String::EMPTY, CIMNamespaceName (), 
        CIMName("Test_IndicationProviderClass"), keyBindings);

    try
    {
        CIMValue retValue = client.invokeMethod 
            (SOURCENAMESPACE,
            className,
            methodName,
            inParams,
            outParams);
        retValue.get (result);
        PEGASUS_TEST_ASSERT (false);
    }
    catch (CIMException & e)
    {
        PEGASUS_TEST_ASSERT (e.getCode () == CIM_ERR_NOT_SUPPORTED);
    }
}
开发者ID:host1812,项目名称:scx_plugin_public,代码行数:28,代码来源:DisableEnable2.cpp

示例3: mbGetProperty

    static CMPIData mbGetProperty(
        const CMPIBroker *mb,
        const CMPIContext *ctx,
        const CMPIObjectPath *cop,
        const char *name,
        CMPIStatus *rc)
    {
        PEG_METHOD_ENTER(
            TRC_CMPIPROVIDERINTERFACE,
            "CMPI_Broker:mbGetProperty()");
        mb = CM_BROKER;
        CMPIData data = {0,CMPI_nullValue,{0}};

        SCMOInstance* scmoObjPath = SCMO_ObjectPath(cop);
        CIMObjectPath qop;
        scmoObjPath->getCIMObjectPath(qop);

        try
        {
            CIMValue v = CM_CIMOM(mb)->getProperty(
                *CM_Context(ctx),
                SCMO_ObjectPath(cop)->getNameSpace(),
                qop,
                String(name));
            CIMType vType = v.getType();
            CMPIType t = type2CMPIType(vType,v.isArray());
            value2CMPIData(v,t,&data);
            CMSetStatus(rc,CMPI_RC_OK);
        }
        HandlerCatchSetStatus(rc, data);

        PEG_METHOD_EXIT();
        return data; // "data" will be valid data or nullValue (in error case)
    }
开发者ID:rdobson,项目名称:openpegasus,代码行数:34,代码来源:CMPI_Broker.cpp

示例4: _resolveProviderName

ProviderName DefaultProviderManager::_resolveProviderName(
    const ProviderIdContainer& providerId)
{
    String providerName;
    String fileName;
    String moduleName;
    CIMValue genericValue;

    genericValue = providerId.getModule().getProperty(
        providerId.getModule().findProperty(
            PEGASUS_PROPERTYNAME_NAME)).getValue();
    genericValue.get(moduleName);

    genericValue = providerId.getProvider().getProperty(
        providerId.getProvider().findProperty(
            PEGASUS_PROPERTYNAME_NAME)).getValue();
    genericValue.get(providerName);

    genericValue = providerId.getModule().getProperty(
        providerId.getModule().findProperty("Location")).getValue();
    genericValue.get(fileName);

    String resolvedFileName = _resolvePhysicalName(fileName);

    if (resolvedFileName == String::EMPTY)
    {
        // Provider library not found
        throw Exception(MessageLoaderParms(
            "ProviderManager.ProviderManagerService.PROVIDER_FILE_NOT_FOUND",
            "File \"$0\" was not found for provider module \"$1\".",
            FileSystem::buildLibraryFileName(fileName), moduleName));
    }

    return ProviderName(moduleName, providerName, resolvedFileName);
}
开发者ID:brunolauze,项目名称:pegasus,代码行数:35,代码来源:DefaultProviderManager.cpp

示例5: _testHostedIndicationServiceInstance

void _testHostedIndicationServiceInstance(CIMClient &client)
{
    cout << "Testing Association Class "
        << (const char *)PEGASUS_CLASSNAME_PG_HOSTEDINDICATIONSERVICE.
             getString().getCString()
        << "...";
    // Get PG_HostedIndicationService Instances
    Array<CIMInstance> hostedInstances = client.enumerateInstances(
        PEGASUS_NAMESPACENAME_INTEROP,
        PEGASUS_CLASSNAME_PG_HOSTEDINDICATIONSERVICE);
    PEGASUS_TEST_ASSERT(hostedInstances.size() == 1);

    // Get PG_HostedIndicationService Instance names
    Array<CIMObjectPath> hostedPaths = client.enumerateInstanceNames(
        PEGASUS_NAMESPACENAME_INTEROP,
        PEGASUS_CLASSNAME_PG_HOSTEDINDICATIONSERVICE);
    PEGASUS_TEST_ASSERT(hostedPaths.size() == 1);

    // Get CIM_IndicationService instance names
    Array<CIMObjectPath> servicePaths = client.enumerateInstanceNames(
        PEGASUS_NAMESPACENAME_INTEROP,
        PEGASUS_CLASSNAME_CIM_INDICATIONSERVICE);
    PEGASUS_TEST_ASSERT(servicePaths.size() == 1);

    // Test the CIM_IndicationService value.
    CIMValue capValue = hostedInstances[0].getProperty(
        hostedInstances[0].findProperty("Dependent")).getValue();
    CIMObjectPath testPath;
    capValue.get(testPath);
    testPath.setNameSpace(CIMNamespaceName());
    PEGASUS_TEST_ASSERT(testPath.identical(servicePaths[0]));

    cout << "Test Complete" << endl;
}
开发者ID:brunolauze,项目名称:pegasus,代码行数:34,代码来源:ServerProfile.cpp

示例6: main

int main (int argc, char** argv)
{
    String stringVal;
    verbose = (getenv("PEGASUS_TEST_VERBOSE")) ? true : false;

    CIMClient client;
    try
    {
        client.connectLocal ();
    }
    catch (Exception & e)
    {
        PEGASUS_STD (cerr) << e.getMessage () << PEGASUS_STD (endl);
        return -1;
    }

    _enumerateInstanceNames(client);
    _getInstance(client);
    _setProperty(client, 7890);
    _getProperty(client);
    // getProperty() only returns CIMValues of type String.
    value.get(stringVal);
    PEGASUS_TEST_ASSERT(atoi((const char*)stringVal.getCString())==7890);
    _setProperty(client,1234);
    _getProperty(client);
    // getProperty() only returns CIMValues of type String.
    // Verify that setProperty worked as expected.
    value.get(stringVal);
    PEGASUS_TEST_ASSERT(atoi((const char*)stringVal.getCString())==1234);

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

示例7: _sendTestIndication

void _sendTestIndication(
    CIMClient* client,
    const CIMName & methodName,
    Uint32 indicationSendCount)
{
    //
    //  Invoke method to send test indication
    //
    Array <CIMParamValue> inParams;
    Array <CIMParamValue> outParams;
    Array <CIMKeyBinding> keyBindings;
    Sint32 result;

    CIMObjectPath className (String::EMPTY, CIMNamespaceName (),
                             CIMName ("Test_IndicationProviderClass"), keyBindings);

    inParams.append(CIMParamValue(String("indicationSendCount"),
                                  CIMValue(indicationSendCount)));

    CIMValue retValue = client->invokeMethod
                        (SOURCE_NAMESPACE,
                         className,
                         methodName,
                         inParams,
                         outParams);

    retValue.get (result);
    PEGASUS_TEST_ASSERT (result == 0);
}
开发者ID:xenserver,项目名称:openpegasus,代码行数:29,代码来源:testSnmpHandler.cpp

示例8: getPropertyValue

String CIMHelper::getPropertyAsString(const CIMInstance &instanceObject, String name)
{
    CIMValue value = getPropertyValue(instanceObject, name);
    if (value.isNull()) return String("");
    String result;
    value.get(result);
    return result;
}
开发者ID:brunolauze,项目名称:pegasus-providers,代码行数:8,代码来源:CIMHelper.cpp

示例9: equal

Boolean CIMKeyBinding::equal(CIMValue value)
{
    if (value.isArray())
    {
        return false;
    }

    CIMValue kbValue;

    try
    {
        switch (value.getType())
        {
        case CIMTYPE_CHAR16:
            if (getType() != STRING) return false;
            kbValue.set(getValue()[0]);
            break;
        case CIMTYPE_DATETIME:
            if (getType() != STRING) return false;
            kbValue.set(CIMDateTime(getValue()));
            break;
        case CIMTYPE_STRING:
            if (getType() != STRING) return false;
            kbValue.set(getValue());
            break;
        case CIMTYPE_REFERENCE:
            if (getType() != REFERENCE) return false;
            kbValue.set(CIMObjectPath(getValue()));
            break;
        case CIMTYPE_BOOLEAN:
            if (getType() != BOOLEAN) return false;
            kbValue = XmlReader::stringToValue(0, getValue().getCString(),
                                               value.getType());
            break;
//      case CIMTYPE_REAL32:
//      case CIMTYPE_REAL64:
        case CIMTYPE_OBJECT:
        case CIMTYPE_INSTANCE:
            // From PEP 194: EmbeddedObjects cannot be keys.
            return false;
        default:  // Numerics
            if (getType() != NUMERIC) return false;
            kbValue = XmlReader::stringToValue(0, getValue().getCString(),
                                               value.getType());
            break;
        }
    }
    catch (Exception&)
    {
        return false;
    }

    return value.equal(kbValue);
}
开发者ID:brunolauze,项目名称:pegasus,代码行数:54,代码来源:CIMObjectPath.cpp

示例10: setValue

void CIMPropertyRep::setValue(const CIMValue& value)
{
    // CIMType of value is immutable:

    if (!value.typeCompatible(_value))
	throw TypeMismatchException();

    if (_arraySize && _arraySize != value.getArraySize())
	throw TypeMismatchException();

    _value = value;
}
开发者ID:ncultra,项目名称:Pegasus-2.5,代码行数:12,代码来源:CIMPropertyRep.cpp

示例11: _Check

void CIMError::setInstance(const CIMInstance& instance)
{
    for (Uint32 i = 0; i < instance.getPropertyCount(); i++)
    {
        CIMConstProperty p = instance.getProperty(i);

        _Check("ErrorType", p, (Uint16*)0);
        _Check("OtherErrorType", p, (String*)0);
        _Check("OwningEntity", p, (String*)0);
        _Check("MessageID", p, (String*)0);
        _Check("Message", p, (String*)0);
        _Check("MessageArguments", p, (Array<String>*)0);
        _Check("PerceivedSeverity", p, (Uint16*)0);
        _Check("ProbableCause", p, (Uint16*)0);
        _Check("ProbableCauseDescription", p, (String*)0);
        _Check("RecommendedActions", p, (Array<String>*)0);
        _Check("ErrorSource", p, (String*)0);
        _Check("ErrorSourceFormat", p, (Uint16*)0);
        _Check("OtherErrorSourceFormat", p, (String*)0);
        _Check("CIMStatusCode", p, (Uint32*)0);
        _Check("CIMStatusCodeDescription", p, (String*)0);
    }

    // Verify that the instance contains all of the required properties.

    for (Uint32 i = 0; i < _numRequiredProperties; i++)
    {
        // Does inst have this property?

        Uint32 pos = instance.findProperty(_requiredProperties[i]);

        if (pos == PEG_NOT_FOUND)
        {
            char buffer[80];
            sprintf(buffer, "required property does not exist: %s",
                    _requiredProperties[i]);
            throw CIMException(CIM_ERR_NO_SUCH_PROPERTY, buffer);
        }
        // is required property non-null?
        CIMConstProperty p = instance.getProperty(pos);
        CIMValue v = p.getValue();
        if (v.isNull())
        {
            char buffer[80];
            sprintf(buffer, "required property MUST NOT be Null: %s",
                    _requiredProperties[i]);
            throw CIMException(CIM_ERR_FAILED, buffer);
        }
    }
    _inst = instance;
}
开发者ID:xenserver,项目名称:openpegasus,代码行数:51,代码来源:CIMError.cpp

示例12: outputKEYVALUE

static void
outputKEYVALUE(ostream& ostr, const CIMProperty& cp)
{
	CIMDataType dtype = cp.getDataType();
	String type;
	if (dtype.isArrayType())
	{
		OW_THROWCIMMSG(CIMException::INVALID_PARAMETER,
			"An array cannot be a KEY");
	}
	if (dtype.isReferenceType())
	{
		CIMProperty lcp(cp);
		// This is sort of a bad thing to do, basically we are taking advantage
		// of a side effect of setDataType.  If the type isn't correct then
		// the value will be cast to the correct type.	This is to work around
		// a problem that may happen if a provider writer sets the value of a
		// reference property to a String instead of an CIMObjectPath.
		// If the value is a string, the xml that is output will be malformed,
		// and the client will throw an exception.
		lcp.setDataType(lcp.getDataType());
		CIMtoXML(lcp.getValue(), ostr);
		return;
	}
	//
	// Regular key value
	switch (dtype.getType())
	{
		case CIMDataType::CHAR16:
		case CIMDataType::DATETIME:
		case CIMDataType::STRING:
			type = "string";
			break;
		case CIMDataType::BOOLEAN:
			type = "boolean";
			break;
		default:
			type = "numeric";
	}
	CIMValue keyValue = cp.getValue();
	if (!keyValue)
	{
		OW_THROWCIMMSG(CIMException::FAILED, "No key value");
	}
	ostr
		<< "<KEYVALUE VALUETYPE=\""
		<<  type
		<< "\">"
		<< XMLEscape(keyValue.toString())
		<< "</KEYVALUE>";
}
开发者ID:kkaempf,项目名称:openwbem,代码行数:51,代码来源:OW_CIMtoXML.cpp

示例13: _getKeyValue

void _getKeyValue (
    const CIMInstance& namespaceInstance,
    CIMNamespaceName& childNamespaceName,
    Boolean& isRelativeName)

{
    //Validate key property

    Uint32 pos;
    CIMValue propertyValue;

    // [Key, MaxLen (256), Description (
    //       "A string that uniquely identifies the Namespace "
    //       "within the ObjectManager.") ]
    // string Name;

    pos = namespaceInstance.findProperty(NAMESPACE_PROPERTYNAME);
    if (pos == PEG_NOT_FOUND)
    {
        throw CIMPropertyNotFoundException
        (NAMESPACE_PROPERTYNAME.getString());
    }

    propertyValue = namespaceInstance.getProperty(pos).getValue();
    if (propertyValue.getType() != CIMTYPE_STRING)
    {
        //l10n
        //throw CIMInvalidParameterException("Invalid type for property: "
        //+ NAMESPACE_PROPERTYNAME.getString());
        throw CIMInvalidParameterException(MessageLoaderParms(
                                               "ControlProviders.NamespaceProvider.NamespaceProvider.INVALID_TYPE_FOR_PROPERTY",
                                               "Invalid type for property: $0",
                                               NAMESPACE_PROPERTYNAME.getString()));
    }

    String cnsName;
    propertyValue.get(cnsName);
    if (cnsName == String::EMPTY)
    {
        childNamespaceName = CIMNamespaceName();
    }
    else
    {
        childNamespaceName = CIMNamespaceName(cnsName);
    }

    isRelativeName = !(childNamespaceName.isNull());

}
开发者ID:ncultra,项目名称:Pegasus-2.5,代码行数:49,代码来源:NamespaceProvider.cpp

示例14: _testServiceAffectsElementInstances

void _testServiceAffectsElementInstances(CIMClient &client)
{
    cout << "Testing Association Class "
        << (const char *)PEGASUS_CLASSNAME_PG_SERVICEAFFECTSELEMENT.
             getString().getCString()
        << "...";

    // Get PG_ServiceAffectsElement instances.
    Array<CIMInstance> sfInstances = client.enumerateInstances(
        PEGASUS_NAMESPACENAME_INTEROP,
        PEGASUS_CLASSNAME_PG_SERVICEAFFECTSELEMENT);

    // Get PG_ServiceAffectsElement instance names
    Array<CIMObjectPath> sfPaths = client.enumerateInstanceNames(
        PEGASUS_NAMESPACENAME_INTEROP,
        PEGASUS_CLASSNAME_PG_SERVICEAFFECTSELEMENT);

    PEGASUS_TEST_ASSERT(sfInstances.size() == sfPaths.size());

    // Get CIM_IndicationFilter instance names
    Array<CIMObjectPath> filterPaths = client.enumerateInstanceNames(
        PEGASUS_NAMESPACENAME_INTEROP,
        PEGASUS_CLASSNAME_INDFILTER);

    // Get CIM_ListenerDestination instance names
    Array<CIMObjectPath> handlerPaths = client.enumerateInstanceNames(
        PEGASUS_NAMESPACENAME_INTEROP,
        PEGASUS_CLASSNAME_LSTNRDST);

    // Count only handlers and filters from interop namespace
    Uint32 elements = 0;
    for (Uint32 i = 0; i < sfInstances.size() ; ++i)
    {
        CIMValue value = sfInstances[i].getProperty(
            sfInstances[i].findProperty("AffectedElement")).getValue();
        CIMObjectPath path;
        value.get(path);
        PEGASUS_TEST_ASSERT(path.getNameSpace() != CIMNamespaceName());
        if (path.getNameSpace() == PEGASUS_NAMESPACENAME_INTEROP)
        {
             elements++;
        }
    }
    PEGASUS_TEST_ASSERT(
        elements == (filterPaths.size() + handlerPaths.size()));

    cout << "Test Complete" << endl;
}
开发者ID:brunolauze,项目名称:pegasus,代码行数:48,代码来源:ServerProfile.cpp

示例15: className

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


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