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


C++ CIMProperty::getName方法代码示例

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


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

示例1: Run

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

示例2: CIMInstanceNametoXML

void CIMInstanceNametoXML(CIMObjectPath const& cop, ostream& ostr)
{
	ostr << "<INSTANCENAME CLASSNAME=\"";
	ostr << cop.getClassName() << "\">";
	//
	// If keys > 1 then must use KEYBINDING - we also use it for
	// the key == 1 case - most implementations can't cope with
	// a single KEYVALUE without a KEYBINDING element
	//
	if (cop.isInstancePath())
	{
		size_t numkeys = cop.getKeys().size();
		for (size_t i = 0; i < numkeys; i++)
		{
			CIMProperty cp = cop.getKeys()[i];
			ostr << "<KEYBINDING NAME=\"";
			ostr << cp.getName() << "\">";
			outputKEYVALUE(ostr, cp);
			ostr << "</KEYBINDING>";
		}
	}
	else
	{
		// A singleton, a class without keys
	}
	ostr << "</INSTANCENAME>";
}
开发者ID:kkaempf,项目名称:openwbem,代码行数:27,代码来源:OW_CIMtoXML.cpp

示例3: handleIndication

// l10n - note: ignoring indication language
void snmpIndicationHandler::handleIndication(
    const OperationContext& context,
    const String nameSpace,
    CIMInstance& indication,
    CIMInstance& handler,
    CIMInstance& subscription,
    ContentLanguageList & contentLanguages)
{
    Array<String> propOIDs;
    Array<String> propTYPEs;
    Array<String> propVALUEs;

    Array<String> mapStr;

    PEG_METHOD_ENTER(TRC_IND_HANDLER,
        "snmpIndicationHandler::handleIndication");

    try
    {
        PEG_TRACE ((TRC_INDICATION_GENERATION, Tracer::LEVEL4,
            "snmpIndicationHandler %s:%s.%s processing %s Indication",
           (const char*)(nameSpace.getCString()),
           (const char*)(handler.getClassName().getString().getCString()),
           (const char*)(handler.getProperty(
           handler.findProperty(PEGASUS_PROPERTYNAME_NAME)).
           getValue().toString().getCString()),
           (const char*)(indication.getClassName().getString().
           getCString())));
        CIMClass indicationClass = _repository->getClass(
            nameSpace, indication.getClassName(), false, true,
            false, CIMPropertyList());

        Uint32 propertyCount = indication.getPropertyCount();

        for (Uint32 i=0; i < propertyCount; i++)
        {
            CIMProperty prop = indication.getProperty(i);

            Uint32 propDeclPos = indicationClass.findProperty(prop.getName());
            if (propDeclPos != PEG_NOT_FOUND)
            {
                CIMProperty propDecl = indicationClass.getProperty(propDeclPos);

                Uint32 qualifierPos =
                    propDecl.findQualifier(CIMName("MappingStrings"));
                if (qualifierPos != PEG_NOT_FOUND)
                {
                    //
                    // We are looking for following fields:
                    // MappingStrings {"OID.IETF | SNMP." oidStr,
                    //     "DataType.IETF |" dataType}
                    // oidStr is the object identifier (e.g. "1.3.6.1.2.1.5..."
                    // dataType is either Integer, or OctetString,
                    // or OID
                    // Following is one example:
                    // MappingStrings {"OID.IETF | SNMP.1.3.6.6.3.1.1.5.2",
                    //    "DataType.IETF | Integer"}
                    //

                    propDecl.getQualifier(qualifierPos).getValue().get(
                        mapStr);

                    String oidStr, dataType;
                    String mapStr1, mapStr2;
                    Boolean isValidAuthority = false;
                    Boolean isValidDataType = false;

                    for (Uint32 j=0; j < mapStr.size(); j++)
                    {
                        Uint32 barPos = mapStr[j].find("|");

                        if (barPos != PEG_NOT_FOUND)
                        {
                            mapStr1 = mapStr[j].subString(0, barPos);
                            mapStr2 = mapStr[j].subString(barPos + 1);

                            _trimWhitespace(mapStr1);
                            _trimWhitespace(mapStr2);

                            if ((mapStr1 == "OID.IETF") &&
                                (String::compare(mapStr2,
                                 String("SNMP."), 5) == 0))
                            {
                                isValidAuthority = true;
                                oidStr = mapStr2.subString(5);
                            }
                            else if (mapStr1 == "DataType.IETF")
                            {
                                isValidDataType = true;
                                dataType = mapStr2;
                            }

                            if (isValidAuthority && isValidDataType)
                            {
                                propOIDs.append(oidStr);
                                propTYPEs.append(dataType);
                                propVALUEs.append(prop.getValue().toString());

                                break;
//.........这里部分代码省略.........
开发者ID:brunolauze,项目名称:pegasus,代码行数:101,代码来源:snmpIndicationHandler.cpp

示例4: _applyProjection

Boolean _applyProjection(QueryExpression& qe,
                         Array<CIMInstance>& _instances,
                         String testOption,
                         String lang)
{
    if(testOption == String::EMPTY || testOption == "2")
    {
        cout << endl << lang << " ========Apply Projection Results========" << endl;
        cout << qe.getQuery() << endl;

        for(Uint32 j = 0; j < _instances.size(); j++)
        {
            cout << "Instance of class " << _instances[j].getClassName().getString() << endl;

            try
            {
                CIMInstance projInst = _instances[j].clone();

                Boolean gotPropExc = false;
                try
                {
                    qe.applyProjection(projInst, false);
                }
                catch (QueryRuntimePropertyException & qrpe)
                {
                    // Got a missing property exception.
                    cout << "-----" << qrpe.getMessage() << endl;
                    gotPropExc = true;
                }

                if (gotPropExc)
                {
                    // Got a missing property exception.
                    // Try again, allowing missing properties.
                    // Need to use a cloned instance because the original instance
                    // was partially projected.
                    cout << "Instance of class " << _instances[j].getClassName().getString()
                         << ".  Allow missing properties." << endl;
                    projInst = _instances[j].clone();
                    qe.applyProjection(projInst, true);
                }

                Uint32 cnt = projInst.getPropertyCount();
                if (cnt == 0)
                {
                    cout << "-----No properties left after projection" << endl;
                }

                if (cnt > 10)
                {
                    // If more than 10 props, just print the count to keep
                    // the output file short
                    cout << "Instance has " << cnt << " properties" << endl;
                }
                else
                {
                    for (Uint32 n = 0; n < cnt; n++)
                    {
                        CIMProperty prop = projInst.getProperty(n);
                        CIMValue val = prop.getValue();
                        cout << "-----Prop #" << n << " Name = " << prop.getName().getString();
                        if (val.isNull())
                        {
                            cout << " Value = NULL" << endl;
                        }
                        else
                        {
                            cout << " Value = " << val.toString() << endl;
                        }
                    }
                }
            }
            catch(Exception& e) {
                cout << "-----" << e.getMessage() << endl;
            }
            catch(...) {
                cout << "Unknown Exception" << endl;
            }

        }
    }

    return true;
}
开发者ID:ncultra,项目名称:Pegasus-2.5,代码行数:84,代码来源:QueryExpression.cpp

示例5: initialize

void PG_TestPropertyTypes::initialize(CIMOMHandle& cimom)
{
    // save cimom handle
    _cimom = cimom;

    // create default instances
    CIMInstance instance1("PG_TestPropertyTypes");

    instance1.addProperty(CIMProperty(
        "CreationClassName", String("PG_TestPropertyTypes")));   // key
    instance1.addProperty(CIMProperty("InstanceId", Uint64(1))); //key
    instance1.addProperty(CIMProperty(
        "PropertyString", String("PG_TestPropertyTypes_Instance1")));
    instance1.addProperty(CIMProperty("PropertyUint8", Uint8(120)));
    instance1.addProperty(CIMProperty("PropertyUint16", Uint16(1600)));
    instance1.addProperty(CIMProperty("PropertyUint32", Uint32(3200)));
    instance1.addProperty(CIMProperty("PropertyUint64", Uint64(6400)));
    instance1.addProperty(CIMProperty("PropertySint8", Sint8(-120)));
    instance1.addProperty(CIMProperty("PropertySint16", Sint16(-1600)));
    instance1.addProperty(CIMProperty("PropertySint32", Sint32(-3200)));
    instance1.addProperty(CIMProperty("PropertySint64", Sint64(-6400)));
    instance1.addProperty(CIMProperty("PropertyBoolean", Boolean(1)));
    instance1.addProperty(CIMProperty("PropertyReal32", Real32(1.12345670123)));
    instance1.addProperty(CIMProperty(
        "PropertyReal64", Real64(1.12345678906543210123)));
    instance1.addProperty(CIMProperty(
        "PropertyDatetime", CIMDateTime("20010515104354.000000:000")));

    // update object path
    {
        CIMObjectPath objectPath = instance1.getPath();

        Array<CIMKeyBinding> keys;

        {
            CIMProperty keyProperty = instance1.getProperty(
                instance1.findProperty("CreationClassName"));

            keys.append(
                CIMKeyBinding(keyProperty.getName(), keyProperty.getValue()));
        }

        {
            CIMProperty keyProperty = instance1.getProperty(
                instance1.findProperty("InstanceId"));

            keys.append(
                CIMKeyBinding(keyProperty.getName(), keyProperty.getValue()));
        }

        objectPath.setKeyBindings(keys);

        instance1.setPath(objectPath);
    }

    _instances.append(instance1);

    CIMInstance instance2("PG_TestPropertyTypes");

    instance2.addProperty(CIMProperty(
        "CreationClassName", String("PG_TestPropertyTypes")));   // key
    instance2.addProperty(CIMProperty("InstanceId", Uint64(2))); //key
    instance2.addProperty(CIMProperty(
        "PropertyString", String("PG_TestPropertyTypes_Instance2")));

    instance2.addProperty(CIMProperty("PropertyUint8", Uint8(122)));
    instance2.addProperty(CIMProperty("PropertyUint16", Uint16(1602)));
    instance2.addProperty(CIMProperty("PropertyUint32", Uint32(3202)));
    instance2.addProperty(CIMProperty("PropertyUint64", Uint64(6402)));
    instance2.addProperty(CIMProperty("PropertySint8", Sint8(-122)));
    instance2.addProperty(CIMProperty("PropertySint16", Sint16(-1602)));
    instance2.addProperty(CIMProperty("PropertySint32", Sint32(-3202)));
    instance2.addProperty(CIMProperty("PropertySint64", Sint64(-6402)));
    instance2.addProperty(CIMProperty("PropertyBoolean", Boolean(0)));
    instance2.addProperty(CIMProperty("PropertyReal32", Real32(2.12345670123)));
    instance2.addProperty(CIMProperty(
        "PropertyReal64", Real64(2.12345678906543210123)));

    instance2.addProperty(CIMProperty(
        "PropertyDatetime", CIMDateTime("20010515104354.000000:000")));

    _instances.append(instance2);

    // update object path
    {
        CIMObjectPath objectPath = instance2.getPath();

        Array<CIMKeyBinding> keys;

        {
            CIMProperty keyProperty = instance2.getProperty(
                instance2.findProperty("CreationClassName"));

            keys.append(
                CIMKeyBinding(keyProperty.getName(), keyProperty.getValue()));
        }

        {
            CIMProperty keyProperty = instance2.getProperty(
                instance2.findProperty("InstanceId"));
//.........这里部分代码省略.........
开发者ID:rdobson,项目名称:openpegasus,代码行数:101,代码来源:PG_TestPropertyTypes.cpp

示例6: createInstance

/////////////////////////////////////////////////////////////////////////////
// WMIInstanceProvider::createInstance
//
// ///////////////////////////////////////////////////////////////////////////
CIMObjectPath WMIInstanceProvider::createInstance(
        const String& nameSpace,
        const String& userName,
        const String& password,
        const CIMInstance& newInstance)
{
    PEG_METHOD_ENTER(TRC_WMIPROVIDER,"WMIInstanceProvider::createInstance()");

    HRESULT hr;
    CComPtr<IWbemClassObject>    pClass;
    CComPtr<IWbemClassObject>    pNewInstance;
    CComBSTR bs;

    setup(nameSpace, userName, password);

    PEG_TRACE((TRC_WMIPROVIDER,
                  Tracer::LEVEL3,
                  "createInstance() - nameSpace %s, userName %s",
                  nameSpace.getCString(),
                  userName.getCString()));

    if (!m_bInitialized)
    {
        throw CIMException(CIM_ERR_FAILED);
    }

    // Get the class definition.
    String className = newInstance.getClassName().getString();

    if (!(_collector->getObject(&pClass, className)))
    {
        if (pClass)
            pClass.Release();

        throw CIMException(CIM_ERR_INVALID_CLASS);
    }
    else if (_collector->isInstance(pClass))
    {
        if (pClass)
            pClass.Release();

        throw CIMException(CIM_ERR_INVALID_PARAMETER);
    }

    // Create a new instance.
    hr = pClass->SpawnInstance(0, &pNewInstance);

    if (pClass)
        pClass.Release();

    if(FAILED(hr))
    {
        throw CIMException(CIM_ERR_FAILED);
    }

    // Set the properties
    for(Uint32 i = 0; i < newInstance.getPropertyCount(); i++)
    {
        CComVariant v;

        CIMProperty property = newInstance.getProperty(i).clone();
        CIMValue propertyValue = property.getValue();

        try
        {
            WMIValue(propertyValue).getAsVariant(
                                        &v,
                                        nameSpace,
                                        userName,
                                        password);
        }
        catch (CIMException&)
        {
            if (pNewInstance)
                pNewInstance.Release();

            v.Clear();

            throw;
        }

        bs.Empty();
        bs = property.getName().getString().getCString();

        // NULL properties in causes a CIM_ERR_FAILED
        // this conditional ignores properties with NULL.
        if (!propertyValue.isNull())
            hr = pNewInstance->Put(bs, 0, &v, 0);

        v.Clear();

        if(FAILED(hr))
        {
            if (pNewInstance)
                pNewInstance.Release();

//.........这里部分代码省略.........
开发者ID:rdobson,项目名称:openpegasus,代码行数:101,代码来源:WMIInstanceProvider.cpp

示例7: _getIndPropertyValue

String IndicationFormatter::_getIndPropertyValue(
    const String & specifiedPropertyName,
    const String & arrayIndexStr,
    const CIMInstance & indication,
    const ContentLanguages & contentLangs)
{
    PEG_METHOD_ENTER (TRC_IND_FORMATTER,
        "IndicationFormatter::_getIndPropertyValue");

    CIMInstance indicationInstance = indication.clone();
    String propertyName;

    Boolean canLocalize = false;

#if defined(PEGASUS_HAS_ICU) && defined(PEGASUS_INDFORMATTER_USE_ICU)
    Locale locale;
    canLocalize = _canLocalize(contentLangs, locale);
#endif

    for (Uint32 i=0; i < indicationInstance.getPropertyCount(); i++)
    {
        CIMProperty property = indicationInstance.getProperty(i);
        propertyName = property.getName().getString();

        // get specified property value
        if (String::equalNoCase(propertyName, specifiedPropertyName))
        {
            CIMValue propertyValue = property.getValue();
            Boolean valueIsNull = propertyValue.isNull();
	    CIMType type = propertyValue.getType();

            if (!valueIsNull)
            {
                Boolean isArray = propertyValue.isArray();

                if (isArray)
                {
                    PEG_METHOD_EXIT();
		    return (_getArrayValues(propertyValue, arrayIndexStr,
			                    contentLangs));
                }
                else // value is not an array
                {
#if defined(PEGASUS_HAS_ICU) && defined(PEGASUS_INDFORMATTER_USE_ICU)
		    if (canLocalize)
		    {
                        if (type == CIMTYPE_DATETIME)
		        {
			    CIMDateTime dateTimeValue;
			    propertyValue.get(dateTimeValue);
                            PEG_METHOD_EXIT();
			    return(_localizeDateTime(dateTimeValue, locale));
		        }
                        else if (type == CIMTYPE_BOOLEAN)
		        {
			    Boolean booleanValue;
			    propertyValue.get(booleanValue);
                            PEG_METHOD_EXIT();
			    return(_localizeBooleanStr(booleanValue, locale));
		        }
                        else
                        {
                            PEG_METHOD_EXIT();
                            return (propertyValue.toString());
                        }
		    }
		    else
		    {
			if (type == CIMTYPE_BOOLEAN)
			{
                            PEG_METHOD_EXIT();
                            return (_getBooleanStr(propertyValue));
			}
			else
			{
                            PEG_METHOD_EXIT();
                            return (propertyValue.toString());
			}
		    }
#else
		    if (type == CIMTYPE_BOOLEAN)
		    {
                        PEG_METHOD_EXIT();
                        return (_getBooleanStr(propertyValue));
		    }
		    else
		    {
                        PEG_METHOD_EXIT();
                        return (propertyValue.toString());
		    }
#endif
                }

            }
            else // value is NULL
            {
                PEG_METHOD_EXIT();
                return ("NULL");
            }

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

示例8: _formatDefaultIndicationText

String IndicationFormatter::_formatDefaultIndicationText(
    const CIMInstance & indication,
    const ContentLanguages & contentLangs)
{
    PEG_METHOD_ENTER (TRC_IND_FORMATTER,
        "IndicationFormatter::_formatDefaultIndicationText");

    CIMInstance indicationInstance = indication.clone();
    String propertyName;
    String indicationStr;
    Uint32 propertyCount = indicationInstance.getPropertyCount();

    indicationStr.append("Indication (default format):");

    Boolean canLocalize = false;

#if defined(PEGASUS_HAS_ICU) && defined(PEGASUS_INDFORMATTER_USE_ICU)
    Locale locale;
    canLocalize = _canLocalize(contentLangs, locale);
#endif

    for (Uint32 i=0; i < propertyCount; i++)
    {
        CIMProperty property = indicationInstance.getProperty(i);
        propertyName = property.getName().getString();
        CIMValue propertyValue = property.getValue();
        Boolean valueIsNull = propertyValue.isNull();
        Boolean isArray = propertyValue.isArray();

        indicationStr.append(propertyName);
        indicationStr.append(" = ");

	CIMType type = propertyValue.getType();

        if (!valueIsNull)
        {
            if (isArray)
            {
		indicationStr.append(_getArrayValues(propertyValue, "",
		    contentLangs));
            }
            else // value is not an array
            {
#if defined(PEGASUS_HAS_ICU) && defined(PEGASUS_INDFORMATTER_USE_ICU)
		if (canLocalize)
		{
		    if (type == CIMTYPE_DATETIME)
		    {
			CIMDateTime dateTimeValue;
			propertyValue.get(dateTimeValue);
		        indicationStr.append(_localizeDateTime(dateTimeValue,
		    	    locale));
		    }
		    else if (type == CIMTYPE_BOOLEAN)
		    {
			Boolean booleanValue;
			propertyValue.get(booleanValue);
		        indicationStr.append(_localizeBooleanStr(booleanValue,
		    	    locale));
		    }
		    else
		    {
			indicationStr.append(propertyValue.toString());
		    }
		}
		else
		{
		    if (type == CIMTYPE_BOOLEAN)
		    {
                        indicationStr.append(_getBooleanStr(propertyValue));
		    }
		    else
		    {
                        indicationStr.append(propertyValue.toString());
		    }
		}
#else
		if (type == CIMTYPE_BOOLEAN)
		{
                    indicationStr.append(_getBooleanStr(propertyValue));
		}
		else
		{
                    indicationStr.append(propertyValue.toString());
		}
#endif
            }
        }
	else
	{
	    indicationStr.append("NULL");
	}

        if (i < propertyCount -1)
        {
            indicationStr.append(", ");
        }

        propertyName.clear();
    }
//.........这里部分代码省略.........
开发者ID:ncultra,项目名称:Pegasus-2.5,代码行数:101,代码来源:IndicationFormatter.cpp

示例9: if

void
CIMtoXML(CIMProperty const& cp, ostream& ostr)
{
	bool isArray = false;
	bool isRef = false;
	if (cp.getName().empty())
	{
		OW_THROWCIMMSG(CIMException::FAILED, "property must have a name");
	}
	if (cp.getDataType())
	{
		isArray = cp.getDataType().isArrayType();
		isRef = cp.getDataType().isReferenceType();
		if (isArray)
		{
			ostr
				<<  "<PROPERTY.ARRAY NAME=\""
				<<  cp.getName()
				<< "\" TYPE=\"";
			CIMtoXML(cp.getDataType(), ostr);
			ostr << "\" ";
			if (cp.getDataType().getSize() != -1)
			{
				ostr
					<< "ARRAYSIZE=\""
					<< cp.getDataType().getSize()
					<< "\" ";
			}
		}
		else if (isRef)
		{
			ostr
				<< "<PROPERTY.REFERENCE NAME=\""
				<< cp.getName()
				<< "\" REFERENCECLASS=\""
				<< cp.getDataType().getRefClassName()
				<< "\" ";
		}
		else
		{
			ostr
				<< "<PROPERTY NAME=\""
				<< cp.getName()
				<< "\" TYPE=\"";
			CIMtoXML(cp.getDataType(), ostr);
			ostr << "\" ";
		}
	}
	else
	{
		String msg("Property ");
		msg += cp.getName();
		msg += " has no type defined";
		OW_THROWCIMMSG(CIMException::FAILED, msg.c_str());
	}
	if (!cp.getOriginClass().empty())
	{
		ostr
			<< "CLASSORIGIN=\""
			<< cp.getOriginClass()
			<< "\" ";
	}
	if (cp.getPropagated())
	{
		ostr << "PROPAGATED=\"true\" ";
	}
	
	CIMValue val = cp.getValue();
	if (cp.getDataType().isEmbeddedObjectType() || (val && val.getCIMDataType().isEmbeddedObjectType()))
	{
		ostr << "EmbeddedObject=\"object\" ";
	}

	ostr << '>';
	for (size_t i = 0; i < cp.getQualifiers().size(); i++)
	{
		CIMtoXML(cp.getQualifiers()[i], ostr);
	}

	if (val)
	{
		// if there isn't an EmbeddedObject qualifier on an embedded object, then output one.
		if (val.getType() == CIMDataType::EMBEDDEDINSTANCE || val.getType() == CIMDataType::EMBEDDEDCLASS)
		{
			if (!cp.getQualifier(CIMQualifier::CIM_QUAL_EMBEDDEDOBJECT))
			{
				CIMQualifier embeddedObject(CIMQualifier::CIM_QUAL_EMBEDDEDOBJECT);
				embeddedObject.setValue(CIMValue(true));
				CIMtoXML(embeddedObject, ostr);
			}
		}

		CIMtoXML(val, ostr);
	}
	if (isArray)
	{
		ostr << "</PROPERTY.ARRAY>";
	}
	else if (isRef)
	{
//.........这里部分代码省略.........
开发者ID:kkaempf,项目名称:openwbem,代码行数:101,代码来源:OW_CIMtoXML.cpp

示例10: retrieveErrorInstance

int retrieveErrorInstance(CIMClient& client)
{
    try
    {
        PEGASUS_STD(cout) << "Getting error instance: " << errorPath.toString()
            << PEGASUS_STD(endl);
        CIMInstance ret = client.getInstance(
            TEST_NAMESPACE, errorPath, true, false, false, errorPropList);
        ret.setPath(errorPath);
        if (!errorInstance->identical(ret))
        {
            if (!ret.getPath().identical(errorInstance->getPath()))
            {
                PEGASUS_STD(cout) << "Object Paths not identical"
                    << PEGASUS_STD(endl);
            }
            PEGASUS_STD(cout) << "Error Instance and instance retrieved "
                << "through GetInstance operation not the same\n"
                << PEGASUS_STD(endl);
            PEGASUS_STD(cout) << "Local Error Instance: "
                << errorInstance->getPath().toString() << PEGASUS_STD(endl);
            for (unsigned int i = 0, n = errorInstance->getPropertyCount();
                 i < n; i++)
            {
                CIMProperty prop = errorInstance->getProperty(i);
                PEGASUS_STD(cout) << i << ". " << prop.getName().getString()
                    << prop.getValue().toString() << PEGASUS_STD(endl);
            }

            PEGASUS_STD(cout) << "Retrieved Error Instance: " <<
                ret.getPath().toString() << PEGASUS_STD(endl);
            for (unsigned int i = 0, n = ret.getPropertyCount();
                 i < n; i++)
            {
                CIMProperty prop = ret.getProperty(i);
                PEGASUS_STD(cout) << i << ". " << prop.getName().getString()
                    << prop.getValue().toString() << PEGASUS_STD(endl);
            }

            CIMProperty localEmbeddedProp = errorInstance->getProperty(
                errorInstance->findProperty("EmbeddedInst"));
            CIMProperty retEmbeddedProp = ret.getProperty(
                ret.findProperty("EmbeddedInst"));
            CIMInstance localEmbeddedInst;
            CIMInstance retEmbeddedInst;
            localEmbeddedProp.getValue().get(localEmbeddedInst);
            retEmbeddedProp.getValue().get(retEmbeddedInst);
            CIMObjectPath localEmbeddedPath = localEmbeddedInst.getPath();
            CIMObjectPath retEmbeddedPath = retEmbeddedInst.getPath();

            PEGASUS_STD(cout) << "Local Embedded Path: " <<
                localEmbeddedPath.toString() << PEGASUS_STD(endl);
            PEGASUS_STD(cout) << "Ret Embedded Path: " <<
                retEmbeddedPath.toString() << PEGASUS_STD(endl);
            return -1;
        }
    }
    catch (Exception& e)
    {
        cout << "Exception caught while getting error instance: "
            << e.getMessage() << endl;
        return -1;
    }

    try
    {
        Array<CIMInstance> ret = client.enumerateInstances(
            TEST_NAMESPACE,
            "PG_EmbeddedError",
            true,
            true,
            false,
            false,
            errorPropList);
        int count = ret.size();
        for (int i = 0; i < count; i++)
        {
            if (!errorInstance->identical(ret[i]))
            {
                printf("Error instance and instance retrieved through "
                    "EnumerateInstances operation not the same\n");
                return -1;
            }
        }
    }
    catch (Exception& e)
    {
        cout << "Exception caught while enumerating error instances: "
            << e.getMessage() << endl;
        return -1;
    }

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

示例11: modifyInstance

/////////////////////////////////////////////////////////////////////////////
// WMIInstanceProvider::modifyInstance
//
// ///////////////////////////////////////////////////////////////////////////
void WMIInstanceProvider::modifyInstance(
    const String& nameSpace,
    const String& userName,
    const String& password,
    const CIMInstance& modifiedInstance,
    Boolean includeQualifiers,
    const CIMPropertyList& propertylist)
{
    PEG_METHOD_ENTER(TRC_WMIPROVIDER,"WMIClassProvider::modifyInstance()");

    HRESULT hr;
    CComPtr<IWbemClassObject> pClass;
    CComPtr<IWbemClassObject> pInstance;

    setup(nameSpace, userName, password);

    PEG_TRACE((TRC_WMIPROVIDER,
                  Tracer::LEVEL3,
                  "ModifyInstance() - nameSpace %s, userName %s",
                  nameSpace.getCString(),
                  userName.getCString()));

    if (!m_bInitialized)
    {
        PEG_TRACE((TRC_WMIPROVIDER, Tracer::LEVEL1,
            "WMIInstanceProvider::ModifyInstance - m_bInitilized= %x, "
            "throw CIM_ERR_FAILED exception",
            m_bInitialized));

        throw CIMException(CIM_ERR_FAILED);
    }

    // Check if the instance's class is valid.
    String className = modifiedInstance.getClassName().getString();

    if (!(_collector->getObject(&pClass, className)))
    {
        if (pClass)
            pClass.Release();

        throw CIMException(CIM_ERR_INVALID_CLASS);
    }
    else if (_collector->isInstance(pClass))
    {
        if (pClass)
            pClass.Release();

        throw CIMException(CIM_ERR_INVALID_PARAMETER);
    }

    if (pClass)
        pClass.Release();

    // Get the instance path
    CIMObjectPath objPath = modifiedInstance.getPath();

    // Get the name of the instance
    String instanceName = getObjectName(objPath);

    // Check if the instance exists
    if (!(_collector->getObject(&pInstance, instanceName)))
    {
        if (pInstance)
            pInstance.Release();

        throw CIMException(CIM_ERR_NOT_FOUND);
    }
    else if (!(_collector->isInstance(pInstance)))
    {
        if (pInstance)
            pInstance.Release();

        throw CIMException(CIM_ERR_INVALID_PARAMETER);
    }

    // Set the properties that are into propertylist
    Array<CIMName> listNames;
    listNames = propertylist.getPropertyNameArray();

    bool foundInArray;
    bool bPropertySet = false;

    for(Uint32 i = 0; i < modifiedInstance.getPropertyCount(); i++)
    {
        CComVariant v;
        CIMProperty property = modifiedInstance.getProperty(i).clone();
        String sPropName = property.getName().getString();

        // change only the properties defined into the array
        // if the array is null, change all properties
        if (propertylist.isNull())
        {
            foundInArray = true;
        }
        else
        {
//.........这里部分代码省略.........
开发者ID:rdobson,项目名称:openpegasus,代码行数:101,代码来源:WMIInstanceProvider.cpp

示例12: _getClass

int _getClass(const int argc, const char **argv)
{
  CIMClass cldef;
  try
  {
    cldef = _c.getClass( PEGASUS_NAMESPACENAME_INTEROP, argv[0] );
  }
  catch (Exception& e)
  {
    cerr << /* "getClass: " << */ e.getMessage() << endl;
    return 1;
  }

  // Display the class definition
  // without qualifiers, for the moment

  // First the class name and superclass
  cout << "class " << cldef.getClassName().getString() << " : "
    << cldef.getSuperClassName().getString() << endl;
  cout << "{" << endl;
  
  // Now the properties
  // No qualifiers except [key], but specify type, array
  for (int i=0; i<cldef.getPropertyCount(); i++)
  {
    CIMProperty p = cldef.getProperty(i);
    cout << "  ";
    // output key, if required
    if (_isKey(p)) cout << "[ Key ] ";
    // prepare to output type, but
    // first, if type is "reference", find target class
    if (p.getType() == CIMTYPE_REFERENCE)
      cout << p.getReferenceClassName().getString() << " REF ";
    // output type
    else cout << cimTypeToString(p.getType()) << " ";
    // output name
    cout << p.getName().getString();
    // output array, if required
    if (p.isArray()) cout << "[]";
    // final eol
    cout << ";" << endl;
  }
  
  // need to do methods
  for (int i=0; i<cldef.getMethodCount(); i++)
  {
    CIMMethod m = cldef.getMethod(i);
    // output type
    cout << "  " << cimTypeToString(m.getType()) << " ";
    // output name
    cout << m.getName().getString() << "(";
    // output parameters
    // new line if there are any parameters
    for (int j=0; j<m.getParameterCount(); j++)
    {
      CIMParameter p = m.getParameter(j);
      // output IN/OUT qualifiers on a fresh line
      cout << endl << "    [ ";
      // loop through qualifiers looking for IN, OUT
      for (int k=0; k<p.getQualifierCount(); k++)
      {
        // when one found, output its value
        CIMQualifier q = p.getQualifier(k);
        if (q.getName().equal("in") ||
            q.getName().equal("out"))
        {
          cout << q.getName().getString() << " ";
        }
      }
      // Now the type
      cout << "] " << cimTypeToString(p.getType()) << " ";
      // finally the name
      cout << p.getName().getString();
      // array brackets
      if (p.isArray()) cout << "[]";
      // closing , on parameter if not last
      if (j != m.getParameterCount()-1) cout << ",";
    }
    // after last param, indent before closing paren

    // close paren
    cout << ")";
    // if (m.isArray()) cout << "[]";
    // finish output
    cout << ";" << endl;
  }
  
  // final brace and done
  cout << "};" << endl;

  return 0; 
}
开发者ID:host1812,项目名称:scx_plugin_public,代码行数:92,代码来源:Cimpls.cpp

示例13: handleIndication

// l10n - note: ignoring indication language
void snmpIndicationHandler::handleIndication(
    const OperationContext& context,
    const String nameSpace,
    CIMInstance& indication,
    CIMInstance& handler, 
    CIMInstance& subscription,
    ContentLanguages & contentLanguages)
{
    Array<String> propOIDs;
    Array<String> propTYPEs;
    Array<String> propVALUEs;

    CIMProperty prop;
    CIMQualifier trapQualifier;

    Uint32 qualifierPos;
    
    String propValue;

    String mapstr1;
    String mapstr2;

    PEG_METHOD_ENTER (TRC_IND_HANDLER, 
	"snmpIndicationHandler::handleIndication");

    try
    {
    	CIMClass indicationClass = _repository->getClass(
	    nameSpace, indication.getClassName(), false, true, 
	    false, CIMPropertyList());

    	Uint32 propertyCount = indication.getPropertyCount();

    	for (Uint32 i=0; i < propertyCount; i++)
    	{
	    prop = indication.getProperty(i);

	    if (!prop.isUninitialized())
            {
                CIMName propName = prop.getName();
                Uint32 propPos = indicationClass.findProperty(propName);
                if (propPos != PEG_NOT_FOUND)
                {
                    CIMProperty trapProp = indicationClass.getProperty(propPos);

                    qualifierPos = trapProp.findQualifier(CIMName ("MappingStrings"));
                    if (qualifierPos != PEG_NOT_FOUND)
                    {
		        trapQualifier = trapProp.getQualifier(qualifierPos);
		
		        mapstr1.clear();
		        mapstr1 = trapQualifier.getValue().toString();

		        if ((mapstr1.find("OID.IETF") != PEG_NOT_FOUND) &&
		            (mapstr1.find("DataType.IETF") != PEG_NOT_FOUND))
		        {
		            if (mapstr1.subString(0, 8) == "OID.IETF")
		            {
			        mapstr1 = mapstr1.subString(mapstr1.find("SNMP.")+5);
                                if (mapstr1.find("|") != PEG_NOT_FOUND)
                                {
			            mapstr2.clear();
			            mapstr2 = mapstr1.subString(0, 
				        mapstr1.find("DataType.IETF")-1);
			            propOIDs.append(mapstr2);
                            
			            propValue.clear();
                                    propValue = prop.getValue().toString();
			            propVALUEs.append(propValue);
                            
			            mapstr2 = mapstr1.subString(mapstr1.find("|")+2);
                                    mapstr2 = mapstr2.subString(0, mapstr2.size()-1);
			            propTYPEs.append(mapstr2);
                                }
		            }
		        }
	            }
                }
            }
        }

        // Collected complete data in arrays and ready to send the trap.
        // trap destination and SNMP type are defined in handlerInstance
        // and passing this instance as it is to deliverTrap() call

#ifdef HPUX_EMANATE
        static snmpDeliverTrap_emanate emanateTrap;
#else
        static snmpDeliverTrap_stub emanateTrap;
#endif

        Uint32 targetHostPos = handler.findProperty(CIMName ("TargetHost"));
        Uint32 targetHostFormatPos = handler.findProperty(CIMName ("TargetHostFormat"));
        Uint32 otherTargetHostFormatPos = handler.findProperty(CIMName (
				      "OtherTargetHostFormat"));
        Uint32 portNumberPos = handler.findProperty(CIMName ("PortNumber"));
        Uint32 snmpVersionPos = handler.findProperty(CIMName ("SNMPVersion"));
        Uint32 securityNamePos =  handler.findProperty(CIMName ("SNMPSecurityName"));
        Uint32 engineIDPos =  handler.findProperty(CIMName ("SNMPEngineID"));
//.........这里部分代码省略.........
开发者ID:ncultra,项目名称:Pegasus-2.5,代码行数:101,代码来源:snmpIndicationHandler.cpp

示例14: _getProperty

int _getProperty(const int argc, const char **argv)
{
  if (argc < 2)
  {
    _gpUsage();
    return 1;
  }
  
  // need to get class definition to find keys
  // first arg is name of class
  CIMClass cldef;
  try
  {
    cldef = _c.getClass( _nameSpace, argv[0] );
  }
  catch(Exception& e)
  {
    cerr << /* "getProperty: " << */ e.getMessage() << endl;
    return 1;
  }

  CIMObjectPath ref;
  CIMInstance inst;

  // If next arg is "ask", prompt user for keys
  if (String::equalNoCase("ask",argv[1])) ref = CIMObjectPath(String::EMPTY,
                                                   _nameSpace,
                                                   argv[0],
                                                   _inputInstanceKeys(cldef) );

  // else if the next arg and is "list", enumInstNames and print
  // a list from which user will select  
  else if (String::equalNoCase("list",argv[1]))
  {
    ref = _selectInstance( argv[0] );
    if (ref.identical(CIMObjectPath())) return 0;
  }

  // else there's another arg but it's invalid
  else
  {
    _gpUsage();
    return 1;
  }

  CIMProperty pDef;
  // if no more args, display property names and ask which
  if (argc < 3)
  {
    int n;
    for (n=0; n<cldef.getPropertyCount(); n++)
    {
      pDef=cldef.getProperty(n);
      cout << n+1 << ": ";
      cout << cimTypeToString(pDef.getType()) << " ";
      cout << pDef.getName().getString();
      if (pDef.isArray()) cout << "[]";
      cout << endl;
    }
    cout << "Property (1.." << cldef.getPropertyCount() << ")? " << flush;
    cin >> n;
    pDef = cldef.getProperty(n-1);
  }
开发者ID:ncultra,项目名称:Pegasus-2.5,代码行数:63,代码来源:Cimop.cpp


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