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

📄 cimpropertyrep.cpp

📁 Pegasus is an open-source implementationof the DMTF CIM and WBEM standards. It is designed to be por
💻 CPP
📖 第 1 页 / 共 2 页
字号:
                    // However, in this case we really do want to add the                    // EmbeddedObject qualifier, so we cast away the implied                    // const-ness of _qualifiers.                    CIMQualifierList * tmpQualifiers =                        const_cast<CIMQualifierList *>(&_qualifiers);                    tmpQualifiers->add(                        CIMQualifier(CIMName("EmbeddedObject"), true));                }#ifndef PEGASUS_SNIA_INTEROP_COMPATIBILITY            }#endif        }#ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT        else if (_value.getType() == CIMTYPE_INSTANCE)        {            // If the property array type is CIMInstance, then            //   encode the property in CIM-XML as a string array with the            //   EMBEDDEDOBJECT attribute (there is not currently a CIM-XML            //   "instance" datatype)            Array<CIMInstance> a;            _value.get(a);            out << " TYPE=\"string\"";            // add the EMBEDDEDOBJECT attribute            if (a.size() > 0)            {                out << " EMBEDDEDOBJECT=\"instance\"";                // Note that if the macro PEGASUS_SNIA_INTEROP_COMPATIBILITY is                // defined, then the EmbeddedInstance qualifier will be added#ifdef PEGASUS_SNIA_INTEROP_COMPATIBILITY                if (_qualifiers.find(CIMName("EmbeddedInstance")) ==                    PEG_NOT_FOUND)                {                    // Note that _qualifiers is not defined as const, and                    // neither is add(), but this method toXml() *is* const.                    // However, in this case we really do want to add the                    // EmbeddedObject qualifier, so we cast away the implied                    // const-ness of _qualifiers.                    // For now, we assume that all the embedded instances in                    // the array are of the same type                    CIMQualifierList * tmpQualifiers =                        const_cast<CIMQualifierList *>(&_qualifiers);                    tmpQualifiers->add(CIMQualifier(                        CIMName("EmbeddedInstance"),                        a[0].getClassName().getString()));                }#endif            }        }#endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT        else        {            out << STRLIT(" TYPE=\"") << cimTypeToString(_value.getType ());            out.append('"');        }        if (_arraySize)        {            char buffer[32];            sprintf(buffer, "%d", _arraySize);            out << STRLIT(" ARRAYSIZE=\"") << buffer;            out.append('"');        }        if (!_classOrigin.isNull())        {            out << STRLIT(" CLASSORIGIN=\"") << _classOrigin;            out.append('"');        }        if (_propagated != false)        {            out << STRLIT(" PROPAGATED=\"") << _toString(_propagated);            out.append('"');        }        out << STRLIT(">\n");        _qualifiers.toXml(out);        XmlWriter::appendValueElement(out, _value);        out << STRLIT("</PROPERTY.ARRAY>\n");    }    else if (_value.getType() == CIMTYPE_REFERENCE)    {        out << STRLIT("<PROPERTY.REFERENCE");        out << STRLIT(" NAME=\"") << _name << STRLIT("\" ");        if (!_referenceClassName.isNull())        {            out << STRLIT(" REFERENCECLASS=\"") << _referenceClassName;            out.append('"');        }        if (!_classOrigin.isNull())        {            out << STRLIT(" CLASSORIGIN=\"") << _classOrigin;            out.append('"');        }        if (_propagated != false)        {            out << STRLIT(" PROPAGATED=\"") << _toString(_propagated);            out.append('"');        }        out << STRLIT(">\n");        _qualifiers.toXml(out);        XmlWriter::appendValueElement(out, _value);        out << STRLIT("</PROPERTY.REFERENCE>\n");    }    else    {        out << STRLIT("<PROPERTY NAME=\"") << _name << STRLIT("\" ");        if (!_classOrigin.isNull())        {            out << STRLIT(" CLASSORIGIN=\"") << _classOrigin;            out.append('"');        }        if (_propagated != false)        {            out << STRLIT(" PROPAGATED=\"") << _toString(_propagated);            out.append('"');        }        if (_value.getType() == CIMTYPE_OBJECT)        {            // If the property type is CIMObject, then            //   encode the property in CIM-XML as a string with the            //   EMBEDDEDOBJECT attribute (there is not currently a CIM-XML            //   "object" datatype)            CIMObject a;            _value.get(a);            out << STRLIT(" TYPE=\"string\"");            // If the Embedded Object is an instance, always add the            // EMBEDDEDOBJECT attribute.            if (a.isInstance())                out << STRLIT(" EMBEDDEDOBJECT=\"object\"");            // Else the Embedded Object is a class, always add the            // EmbeddedObject qualifier.#ifndef PEGASUS_SNIA_INTEROP_COMPATIBILITY            else            {#endif                // Note that if the macro PEGASUS_SNIA_INTEROP_COMPATIBILITY                // is defined, then the EmbeddedObject qualifier will always                // be added, whether it's a class or an instance.                if (_qualifiers.find(CIMName("EmbeddedObject")) ==                    PEG_NOT_FOUND)                {                    // Note that _qualifiers is not defined as const, and                    // neither is add(), but this method toXml() *is* const.                    // However, in this case we really do want to add the                    // EmbeddedObject qualifier, so we cast away the implied                    // const-ness of _qualifiers.                    CIMQualifierList * tmpQualifiers =                        const_cast<CIMQualifierList *>(&_qualifiers);                    tmpQualifiers->add(                        CIMQualifier(CIMName("EmbeddedObject"), true));                }#ifndef PEGASUS_SNIA_INTEROP_COMPATIBILITY            }#endif        }#ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT        else if (_value.getType() == CIMTYPE_INSTANCE)        {            CIMInstance a;            _value.get(a);            out << " TYPE=\"string\"";            out << " EMBEDDEDOBJECT=\"instance\"";#ifdef PEGASUS_SNIA_INTEROP_COMPATIBILITY            if (_qualifiers.find(CIMName("EmbeddedObject")) == PEG_NOT_FOUND)            {                // Note that _qualifiers is not defined as const, and neither                // is add(), but this method toXml() *is* const. However, in                // this case we really do want to add the EmbeddedObject                // qualifier, so we cast away the implied const-ness of                // _qualifiers.                CIMQualifierList * tmpQualifiers =                    const_cast<CIMQualifierList *>(&_qualifiers);                tmpQualifiers->add(                  CIMQualifier(CIMName("EmbeddedInstance"),                  a.getClassName.getString()));            }#endif        }#endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT        else        {            out << STRLIT(" TYPE=\"") << cimTypeToString(_value.getType());            out.append('"');        }        out << STRLIT(">\n");        _qualifiers.toXml(out);        XmlWriter::appendValueElement(out, _value);        out << STRLIT("</PROPERTY>\n");    }}/** toMof - returns the MOF for the CIM Property Object in the parameter.    The MOF for property declaration in a class and value presentation in    an instance are different.    The BNF for the property Declaration MOF is:    <pre>    propertyDeclaration     =   [ qualifierList ] dataType propertyName                                [ array ] [ defaultValue ] ";"    array                   =   "[" [positiveDecimalValue] "]"    defaultValue            =   "=" initializer    </pre>    Format with qualifiers on one line and declaration on another. Start    with newline but none at the end.    Note that instances have a different format that propertyDeclarations:    instanceDeclaration = [ qualifiersList ] INSTANCE OF className | alias         "["valueInitializer "]" ";"    valueInitializer = [ qualifierList ] [ propertyName | referenceName ] "="                       initializer ";"*/void CIMPropertyRep::toMof(Boolean isDeclaration, Buffer& out) const{    //Output the qualifier list    if (_qualifiers.getCount())        out.append('\n');    _qualifiers.toMof(out);    // Output the Type and name on a new line    out << '\n';    if (isDeclaration)    {        out << cimTypeToString(_value.getType ());        out.append(' ');    }    out << _name;    // If array put the Array indicator "[]" and possible size after name.    if (isDeclaration)    {        if (_value.isArray())        {            if (_arraySize)            {                char buffer[32];                int n = sprintf(buffer, "[%d]", _arraySize);                out.append(buffer, n);            }            else                out << STRLIT("[]");        }    }    // If the property value is not Null, add value after "="    if (!_value.isNull())    {        out << STRLIT(" = ");        if (_value.isArray())        {            // Insert any property values            MofWriter::appendValueElement(out, _value);        }        else if (_value.getType() == CIMTYPE_REFERENCE)        {            MofWriter::appendValueElement(out, _value);        }        else        {            MofWriter::appendValueElement(out, _value);        }    }    else if (!isDeclaration)            out << STRLIT(" = NULL");    // Close the property MOF    out.append(';');}Boolean CIMPropertyRep::identical(const CIMPropertyRep* x) const{    if (!_name.equal (x->_name))        return false;    if (_value != x->_value)        return false;    if (!_referenceClassName.equal (x->_referenceClassName))        return false;    if (!_qualifiers.identical(x->_qualifiers))        return false;    if (!_classOrigin.equal (x->_classOrigin))        return false;    if (_propagated != x->_propagated)        return false;    return true;}void CIMPropertyRep::setValue(const CIMValue& value){    // CIMType of value is immutable:    if (!value.typeCompatible(_value))        throw TypeMismatchException();    if (_arraySize && _arraySize != value.getArraySize())        throw TypeMismatchException();    // A CIM Property may not be of reference array type    if (value.isArray() && (value.getType() == CIMTYPE_REFERENCE))    {        throw TypeMismatchException();    }    _value = value;}PEGASUS_NAMESPACE_END

⌨️ 快捷键说明

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