OW_CIMClass.cpp

Go to the documentation of this file.
00001 /*******************************************************************************
00002 * Copyright (C) 2001-2004 Vintela, Inc. All rights reserved.
00003 *
00004 * Redistribution and use in source and binary forms, with or without
00005 * modification, are permitted provided that the following conditions are met:
00006 *
00007 *  - Redistributions of source code must retain the above copyright notice,
00008 *    this list of conditions and the following disclaimer.
00009 *
00010 *  - Redistributions in binary form must reproduce the above copyright notice,
00011 *    this list of conditions and the following disclaimer in the documentation
00012 *    and/or other materials provided with the distribution.
00013 *
00014 *  - Neither the name of Vintela, Inc. nor the names of its
00015 *    contributors may be used to endorse or promote products derived from this
00016 *    software without specific prior written permission.
00017 *
00018 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
00019 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00020 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00021 * ARE DISCLAIMED. IN NO EVENT SHALL Vintela, Inc. OR THE CONTRIBUTORS
00022 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00023 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00024 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00025 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00026 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00027 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00028 * POSSIBILITY OF SUCH DAMAGE.
00029 *******************************************************************************/
00030 
00036 #include "OW_config.h"
00037 #include "OW_CIMClass.hpp"
00038 #include "OW_StringBuffer.hpp"
00039 #include "OW_Assertion.hpp"
00040 #include "OW_CIMQualifier.hpp"
00041 #include "OW_CIMQualifierType.hpp"
00042 #include "OW_CIMProperty.hpp"
00043 #include "OW_CIMMethod.hpp"
00044 #include "OW_CIMInstance.hpp"
00045 #include "OW_CIMUrl.hpp"
00046 #include "OW_CIMValue.hpp"
00047 #include "OW_CIMName.hpp"
00048 #include "OW_BinarySerialization.hpp"
00049 #include "OW_StrictWeakOrdering.hpp"
00050 #include "OW_COWIntrusiveCountableBase.hpp"
00051 
00052 #include <algorithm>
00053 
00054 namespace OW_NAMESPACE
00055 {
00056 
00057 using std::istream;
00058 using std::ostream;
00059 using namespace WBEMFlags;
00060 
00062 struct CIMClass::CLSData : public COWIntrusiveCountableBase
00063 {
00064    CLSData() :
00065       m_associationFlag(false), m_isKeyed(false){  }
00066    CIMName m_name;
00067    CIMName m_parentClassName;
00068    CIMQualifierArray m_qualifiers;
00069    CIMPropertyArray m_properties;
00070    CIMMethodArray m_methods;
00071    Bool m_associationFlag;
00072    Bool m_isKeyed;
00073    CLSData* clone() const { return new CLSData(*this); }
00074 };
00076 bool operator<(const CIMClass::CLSData& x, const CIMClass::CLSData& y)
00077 {
00078    return StrictWeakOrdering(x.m_name, y.m_name, 
00079       x.m_parentClassName, y.m_parentClassName,
00080       x.m_qualifiers, y.m_qualifiers,
00081       x.m_properties, y.m_properties,
00082       x.m_methods, y.m_methods);
00083 }
00085 bool operator==(const CIMClass::CLSData& x, const CIMClass::CLSData& y)
00086 {
00087    return x.m_name == y.m_name && 
00088       x.m_parentClassName == y.m_parentClassName &&
00089       x.m_qualifiers == y.m_qualifiers &&
00090       x.m_properties == y.m_properties &&
00091       x.m_methods == y.m_methods;
00092 }
00094 CIMClass::CIMClass() :
00095    m_pdata(new CLSData)
00096 {
00097 }
00099 CIMClass::CIMClass(CIMNULL_t) :
00100    m_pdata(0)
00101 {
00102 }
00104 CIMClass::CIMClass(const char* name) :
00105    m_pdata(new CLSData)
00106 {
00107    m_pdata->m_name = name;
00108 }
00110 CIMClass::CIMClass(const CIMName& name) :
00111    m_pdata(new CLSData)
00112 {
00113    m_pdata->m_name = name;
00114 }
00116 void
00117 CIMClass::setName(const CIMName& name)
00118 {
00119    m_pdata->m_name = name;
00120 }
00122 String
00123 CIMClass::getSuperClass() const
00124 {
00125    return m_pdata->m_parentClassName.toString();
00126 }
00128 CIMClass&
00129 CIMClass::setSuperClass(const CIMName& pname)
00130 {
00131    m_pdata->m_parentClassName = pname;
00132    return *this;
00133 }
00135 bool
00136 CIMClass::isKeyed() const
00137 {
00138    return m_pdata->m_isKeyed;
00139 }
00141 CIMClass&
00142 CIMClass::setIsKeyed(bool isKeyedParm)
00143 {
00144    m_pdata->m_isKeyed = isKeyedParm;
00145    return *this;
00146 }
00148 CIMPropertyArray
00149 CIMClass::getKeys() const
00150 {
00151    CIMPropertyArray v;
00152    for (size_t i = 0; i < m_pdata->m_properties.size(); i++)
00153    {
00154       const CIMProperty& p = m_pdata->m_properties[i];
00155       if (p.isKey())
00156       {
00157          v.append(p);
00158       }
00159    }
00160    return v;
00161 }
00163 CIMQualifier
00164 CIMClass::getQualifier(const CIMName& name) const
00165 {
00166    for (size_t i = 0; i < m_pdata->m_qualifiers.size(); i++)
00167    {
00168       CIMQualifier q = m_pdata->m_qualifiers[i];
00169       if (q.getName() == name)
00170       {
00171          return q;
00172       }
00173    }
00174    return CIMQualifier(CIMNULL);
00175 }
00177 CIMProperty
00178 CIMClass::getProperty(const CIMName& prpName) const
00179 {
00180    return getProperty(prpName, "");
00181 }
00183 CIMProperty
00184 CIMClass::getProperty(const CIMName& name,
00185    const CIMName& originClass) const
00186 {
00187    //
00188    // See if property name is in the form originClass.propName
00189    // and if it is, work to find real origin class
00190    //
00191    if (originClass != "")
00192    {
00193       for (size_t i = 0; i < m_pdata->m_properties.size(); i++)
00194       {
00195          CIMProperty cp = m_pdata->m_properties[i];
00196          if (cp.getOriginClass() == originClass && cp.getName() == name)
00197          {
00198             return cp;
00199          }
00200       }
00201    }
00202    else
00203    {
00204       for (size_t i = 0; i < m_pdata->m_properties.size(); i++)
00205       {
00206          CIMProperty cp = m_pdata->m_properties[i];
00207          if (cp.getName() == name)
00208          {
00209             return(cp);
00210          }
00211       }
00212    }
00213    return CIMProperty(CIMNULL);
00214 }
00216 CIMMethod
00217 CIMClass::getMethod(const CIMName& name) const
00218 {
00219    return getMethod(name, "");
00220 }
00222 CIMMethod
00223 CIMClass::getMethod(const CIMName& name,
00224    const CIMName& originClass) const
00225 {
00226    //
00227    // See if method name is in the form originClass.propName
00228    // and if it is, work to find real origin class
00229    //
00230    if (originClass != "")
00231    {
00232       int tsize = m_pdata->m_methods.size();
00233       for (int i = 0; i < tsize; i++)
00234       {
00235          CIMMethod q = m_pdata->m_methods[i];
00236          if (q.getOriginClass() == originClass && (q.getName() == name))
00237          {
00238             return q;
00239          }
00240       }
00241    }
00242    else
00243    {
00244       int tsize = m_pdata->m_methods.size();
00245       for (int i = 0; i < tsize; i++)
00246       {
00247          CIMMethod q = m_pdata->m_methods[i];
00248          if (q.getName() == name)
00249          {
00250             return q;
00251          }
00252       }
00253    }
00254    return CIMMethod(CIMNULL);
00255 }
00257 bool
00258 CIMClass::isAssociation() const
00259 {
00260    return m_pdata->m_associationFlag;
00261 }
00263 CIMClass&
00264 CIMClass::setIsAssociation(bool isAssocFlag)
00265 {
00266    m_pdata->m_associationFlag = isAssocFlag;
00267    return *this;
00268 }
00270 CIMQualifierArray
00271 CIMClass::getQualifiers() const
00272 {
00273    return m_pdata->m_qualifiers;
00274 }
00276 CIMPropertyArray
00277 CIMClass::getAllProperties() const
00278 {
00279    return m_pdata->m_properties;
00280 }
00282 String
00283 CIMClass::getKeyClass() const
00284 {
00285    for (size_t i = 0; i < m_pdata->m_properties.size(); i++)
00286    {
00287       CIMProperty p = m_pdata->m_properties[i];
00288       if (p.isKey())
00289       {
00290          return p.getOriginClass();
00291       }
00292    }
00293    return String();
00294 }
00296 CIMPropertyArray
00297 CIMClass::getProperties() const
00298 {
00299    CIMPropertyArray prop;
00300    for (size_t i = 0; i < m_pdata->m_properties.size(); i++)
00301    {
00302       CIMProperty cp = m_pdata->m_properties[i];
00303       if (!cp.hasTrueQualifier(CIMQualifier::CIM_QUAL_OVERRIDE))
00304       {
00305          prop.append(cp);
00306       }
00307    }
00308    return(prop);
00309 }
00311 CIMMethodArray
00312 CIMClass::getAllMethods() const
00313 {
00314    return m_pdata->m_methods;
00315 }
00317 CIMMethodArray
00318 CIMClass::getMethods() const
00319 {
00320    CIMMethodArray meth;
00321    int tsize = m_pdata->m_methods.size();
00322    for (int i = 0; i < tsize; i++)
00323    {
00324       CIMMethod cm = m_pdata->m_methods[i];
00325       if (cm.getQualifier(CIMQualifier::CIM_QUAL_OVERRIDE))
00326       {
00327          meth.append(cm);
00328       }
00329    }
00330    return meth;
00331 }
00333 CIMClass&
00334 CIMClass::addProperty(const CIMProperty& prop)
00335 {
00336    if (prop)
00337    {
00338       m_pdata->m_properties.append(prop);
00339       if (prop.isKey())
00340       {
00341          m_pdata->m_isKeyed = true;
00342       }
00343    }
00344    return *this;
00345 }
00347 int
00348 CIMClass::numberOfProperties() const
00349 {
00350    return m_pdata->m_properties.size();
00351 }
00353 CIMClass&
00354 CIMClass::setProperties(const CIMPropertyArray& props)
00355 {
00356    m_pdata->m_properties = props;
00357    return *this;
00358 }
00360 CIMClass&
00361 CIMClass::setProperty(const CIMProperty& prop)
00362 {
00363    CIMName argName = prop.getName();
00364    for (size_t i = 0; i < m_pdata->m_properties.size(); i++)
00365    {
00366       if (argName == m_pdata->m_properties[i].getName())
00367       {
00368          m_pdata->m_properties[i] = prop;
00369          return *this;
00370       }
00371    }
00372    m_pdata->m_properties.append(prop);
00373    return *this;
00374 }
00376 CIMClass&
00377 CIMClass::setMethod(const CIMMethod& meth)
00378 {
00379    CIMName argName = meth.getName();
00380    for (size_t i = 0; i < m_pdata->m_methods.size(); i++)
00381    {
00382       if (argName == m_pdata->m_methods[i].getName())
00383       {
00384          m_pdata->m_methods[i] = meth;
00385          return *this;
00386       }
00387    }
00388    m_pdata->m_methods.append(meth);
00389    return *this;
00390 }
00392 CIMClass&
00393 CIMClass::addQualifier(const CIMQualifier& qual)
00394 {
00395    if (!qual)
00396    {
00397       return *this;
00398    }
00399    //
00400    // See if qualifier already present
00401    //
00402    for (size_t i = 0; i < m_pdata->m_qualifiers.size(); i++)
00403    {
00404       if (m_pdata->m_qualifiers[i].equals(qual))
00405       {
00406          m_pdata->m_qualifiers.remove(i);
00407          break;
00408       }
00409    }
00410    if (qual.getName().equalsIgnoreCase(CIMQualifier::CIM_QUAL_ASSOCIATION))
00411    {
00412       CIMValue v = qual.getValue();
00413       if (v && v.getType() == CIMDataType::BOOLEAN)
00414       {
00415          Bool b;
00416          qual.getValue().get(b);
00417          m_pdata->m_associationFlag = b;
00418       }
00419       else
00420       {
00421          m_pdata->m_associationFlag = false;
00422       }
00423    }
00424    m_pdata->m_qualifiers.append(qual);
00425    return *this;
00426 }
00428 bool
00429 CIMClass::hasQualifier(const CIMQualifier& qual) const
00430 {
00431    if (qual)
00432    {
00433       for (size_t i = 0; i < m_pdata->m_qualifiers.size(); i++)
00434       {
00435          if (m_pdata->m_qualifiers[i].equals(qual))
00436          {
00437             return true;
00438          }
00439       }
00440    }
00441    return false;
00442 }
00444 int
00445 CIMClass::numberOfQualifiers() const
00446 {
00447    return m_pdata->m_qualifiers.size();
00448 }
00450 bool
00451 CIMClass::removeQualifier(const CIMQualifier& qual)
00452 {
00453    bool cc = false;
00454    if (qual)
00455    {
00456       for (size_t i = 0; i < m_pdata->m_qualifiers.size(); i++)
00457       {
00458          CIMQualifier cq = m_pdata->m_qualifiers[i];
00459          if (cq.equals(qual))
00460          {
00461             m_pdata->m_qualifiers.remove(i);
00462             cc = true;
00463             break;
00464          }
00465       }
00466    }
00467    return cc;
00468 }
00470 bool
00471 CIMClass::removeQualifier(const CIMName& name)
00472 {
00473    bool cc = false;
00474    for (size_t i = 0; i < m_pdata->m_qualifiers.size(); i++)
00475    {
00476       CIMQualifier cq = m_pdata->m_qualifiers[i];
00477       if (cq.getName() == name)
00478       {
00479          m_pdata->m_qualifiers.remove(i);
00480          cc = true;
00481          break;
00482       }
00483    }
00484    return cc;
00485 }
00487 bool
00488 CIMClass::removeProperty(const CIMName& name)
00489 {
00490    bool cc = false;
00491    for (size_t i = 0; i < m_pdata->m_properties.size(); i++)
00492    {
00493       CIMProperty prop = m_pdata->m_properties[i];
00494       if (prop.getName() == name)
00495       {
00496          m_pdata->m_properties.remove(i);
00497          cc = true;
00498          break;
00499       }
00500    }
00501    return cc;
00502 }
00504 CIMClass&
00505 CIMClass::setQualifiers(const CIMQualifierArray& quals)
00506 {
00507    m_pdata->m_qualifiers = quals;
00508    return *this;
00509 }
00511 CIMClass&
00512 CIMClass::setQualifier(const CIMQualifier& qual)
00513 {
00514    if (qual)
00515    {
00516       bool found = false;
00517       for (size_t i = 0; i < m_pdata->m_qualifiers.size(); i++)
00518       {
00519          CIMQualifier cq = m_pdata->m_qualifiers[i];
00520          if (cq.equals(qual))
00521          {
00522             m_pdata->m_qualifiers[i] = qual;
00523             found = true;
00524             break;
00525          }
00526       }
00527       if (!found)
00528       {
00529          m_pdata->m_qualifiers.append(qual);
00530       }
00531    }
00532    return *this;
00533 }
00535 CIMClass&
00536 CIMClass::addMethod(const CIMMethod& meth)
00537 {
00538    if (meth)
00539    {
00540       m_pdata->m_methods.append(meth);
00541    }
00542    return *this;
00543 }
00545 CIMClass&
00546 CIMClass::setMethods(const CIMMethodArray& meths)
00547 {
00548    m_pdata->m_methods = meths;
00549    return *this;
00550 }
00552 CIMInstance
00553 CIMClass::newInstance() const
00554 {
00555    CIMInstance cInstance;
00556    cInstance.syncWithClass(*this, E_INCLUDE_QUALIFIERS);
00557    cInstance.setClassName(m_pdata->m_name);
00558    return cInstance;
00559 }
00561 CIMClass
00562 CIMClass::filterProperties(const StringArray& propertyList,
00563    EIncludeQualifiersFlag includeQualifiers,
00564    EIncludeClassOriginFlag includeClassOrigin) const
00565 {
00566    return clone(E_NOT_LOCAL_ONLY, includeQualifiers, includeClassOrigin,
00567       propertyList, false);
00568 }
00570 CIMClass
00571 CIMClass::clone(ELocalOnlyFlag localOnly, EIncludeQualifiersFlag includeQualifiers,
00572    EIncludeClassOriginFlag includeClassOrigin, const StringArray& propertyList,
00573    bool noProps) const
00574 {
00575    if (!m_pdata)
00576    {
00577       return CIMClass(CIMNULL);
00578    }
00579    CIMClass theClass;
00580    theClass.m_pdata->m_name = m_pdata->m_name;
00581    theClass.m_pdata->m_parentClassName = m_pdata->m_parentClassName;
00582    theClass.m_pdata->m_associationFlag = m_pdata->m_associationFlag;
00583    theClass.m_pdata->m_isKeyed = m_pdata->m_isKeyed;
00584    //
00585    // Process qualifiers
00586    //
00587    if (includeQualifiers)
00588    {
00589       CIMQualifierArray qra;
00590       for (size_t i = 0; i < m_pdata->m_qualifiers.size(); i++)
00591       {
00592          CIMQualifier cq = m_pdata->m_qualifiers[i];
00593          if (localOnly && cq.getPropagated() == true)
00594          {
00595             continue;
00596          }
00597          qra.append(cq);
00598       }
00599       theClass.m_pdata->m_qualifiers = qra;
00600    }
00601    if (!noProps)
00602    {
00603       CIMPropertyArray pra;
00604       for (size_t i = 0; i < m_pdata->m_properties.size(); i++)
00605       {
00606          CIMProperty prop = m_pdata->m_properties[i];
00607          if (localOnly && prop.getPropagated() == true)
00608          {
00609             continue;
00610          }
00611          // If the given property list has any elements, then ensure this
00612          // property name is in the property list before including it
00613          if (propertyList.size() > 0)
00614          {
00615             CIMName pName = prop.getName();
00616             for (size_t j = 0; j < propertyList.size(); j++)
00617             {
00618                if (pName == propertyList[j])
00619                {
00620                   pra.append(prop.clone(includeQualifiers,
00621                      includeClassOrigin));
00622                   break;
00623                }
00624             }
00625          }
00626          else
00627          {
00628             pra.append(prop.clone(includeQualifiers,
00629                includeClassOrigin));
00630          }
00631       }
00632       theClass.m_pdata->m_properties = pra;
00633    }
00634    // Process methods
00635    CIMMethodArray mra;
00636    for (size_t i = 0; i < m_pdata->m_methods.size(); i++)
00637    {
00638       CIMMethod meth = m_pdata->m_methods[i];
00639       if (localOnly && meth.getPropagated() == true)
00640       {
00641          continue;
00642       }
00643       mra.append(meth.clone(includeQualifiers, includeClassOrigin));
00644    }
00645    theClass.m_pdata->m_methods = mra;
00646    return theClass;
00647 }
00649 void
00650 CIMClass::readObject(istream &istrm)
00651 {
00652    CIMName name;
00653    CIMName pcName;
00654    CIMQualifierArray qra;
00655    CIMPropertyArray pra;
00656    CIMMethodArray mra;
00657    Bool isAssocFlag;
00658    Bool isK;
00659 
00660    UInt32 version = CIMBase::readSig(istrm, OW_CIMCLASSSIG, OW_CIMCLASSSIG_V, CIMClass::SERIALIZATION_VERSION);
00661    name.readObject(istrm);
00662    pcName.readObject(istrm);
00663    isAssocFlag.readObject(istrm);
00664    isK.readObject(istrm);
00665    BinarySerialization::readArray(istrm, qra);
00666    BinarySerialization::readArray(istrm, pra);
00667    BinarySerialization::readArray(istrm, mra);
00668    // If dealing with version 1 format, then read language (it was removed in version 2)
00669    // TODO: This was only present in CVS builds and never released.  Remove it right before the release.
00670    if (version == 1)
00671    {
00672       String language;
00673       language.readObject(istrm);
00674    }
00675    if (!m_pdata)
00676    {
00677       m_pdata = new CLSData;
00678    }
00679    m_pdata->m_name = name;
00680    m_pdata->m_parentClassName = pcName;
00681    m_pdata->m_associationFlag = isAssocFlag;
00682    m_pdata->m_isKeyed = isK;
00683    m_pdata->m_qualifiers = qra;
00684    m_pdata->m_properties = pra;
00685    m_pdata->m_methods = mra;
00686 }
00688 void
00689 CIMClass::writeObject(ostream &ostrm) const
00690 {
00691    // ATTENTION: There is a bad hack in MetaRepository::_getClassNameFromNode which relies on the format of a CIMClass.
00692    // If you update/change this function, make sure you update it too!
00693 
00694    // Since version 2 is the same a version 0, we're just using version 0 here, since it's more efficient.
00695    // When/if the version changes to 3, uncomment the next line.
00696    //CIMBase::writeSig(ostrm, OW_CIMCLASSSIG_V, VERSION);
00697    CIMBase::writeSig(ostrm, OW_CIMCLASSSIG);
00698    m_pdata->m_name.writeObject(ostrm);
00699    m_pdata->m_parentClassName.writeObject(ostrm);
00700    m_pdata->m_associationFlag.writeObject(ostrm);
00701    m_pdata->m_isKeyed.writeObject(ostrm);
00702    BinarySerialization::writeArray(ostrm, m_pdata->m_qualifiers);
00703    BinarySerialization::writeArray(ostrm, m_pdata->m_properties);
00704    BinarySerialization::writeArray(ostrm, m_pdata->m_methods);
00705 }
00707 String
00708 CIMClass::toMOF() const
00709 {
00710    size_t i;
00711    StringBuffer rv;
00712    if (m_pdata->m_qualifiers.size() != 0)// || m_pdata->m_associationFlag)
00713    {
00714       rv += "[";
00715       CIMQualifierArray qra = m_pdata->m_qualifiers;
00716       /*
00717        * The association needs to be at the beginning according to
00718        * the MOF grammar.
00719        */
00720       CIMQualifierArray::iterator iter = std::find(
00721          qra.begin(), qra.end(),
00722          CIMQualifier(CIMQualifier::CIM_QUAL_ASSOCIATION));
00723       if (iter != qra.end())
00724       {
00725          if (iter != qra.begin())
00726          {
00727             //std::swap(*iter, *qra.begin());
00728             CIMQualifier tmp = *iter;
00729             qra.erase(iter);
00730             qra.insert(qra.begin(), tmp);
00731          }
00732       }
00733       else
00734       {
00735 //             if (m_pdata->m_associationFlag)
00736 //             {
00737 //                 CIMQualifierType cqt(CIMQualifier::CIM_QUAL_ASSOCIATION);
00738 //                 cqt.setDataType(CIMDataType(CIMDataType::BOOLEAN));
00739 //                 CIMQualifier cq(cqt);
00740 //                 cq.setValue(CIMValue(Bool(true)));
00741 //                 qra.insert(qra.begin(), cq);
00742 //             }
00743       }
00744       iter = std::find( qra.begin(), qra.end(),
00745          CIMQualifier(CIMQualifier::CIM_QUAL_INDICATION));
00746       if (iter != qra.end())
00747       {
00748          std::swap(*iter, *qra.begin());
00749       }
00750       for (i = 0; i < qra.size(); i++)
00751       {
00752          if (i > 0)
00753          {
00754             rv += ",\n ";
00755          }
00756          rv += qra[i].toMOF();
00757       }
00758       rv += "]\n";
00759    }
00760    rv += "class ";
00761    rv += getName();
00762    if (m_pdata->m_parentClassName != "")
00763    {
00764       rv += ':';
00765       rv += m_pdata->m_parentClassName.toString();
00766    }
00767    rv += "\n{\n";
00768    for (i = 0; i < m_pdata->m_properties.size(); i++)
00769    {
00770       rv += m_pdata->m_properties[i].toMOF();
00771 // TODO:    rv += '\n';
00772    }
00773    for (i = 0; i < m_pdata->m_methods.size(); i++)
00774    {
00775       rv += m_pdata->m_methods[i].toMOF();
00776 // TODO:    rv += '\n';
00777    }
00778    rv += "};\n";
00779    return rv.releaseString();
00780 }
00782 String
00783 CIMClass::toString() const
00784 {
00785    return toMOF();
00786 }
00788 CIMClass::~CIMClass()
00789 {
00790 }
00792 CIMClass::CIMClass(const CIMClass& x)
00793    : CIMElement(x)
00794    , m_pdata(x.m_pdata)
00795 {
00796 }
00798 CIMClass& CIMClass::operator=(const CIMClass& x)
00799 {
00800    m_pdata = x.m_pdata;
00801    return *this;
00802 }
00804 void
00805 CIMClass::setNull()
00806 {
00807    m_pdata = NULL;
00808 }
00810 String
00811 CIMClass::getName() const
00812 {
00813    return m_pdata->m_name.toString();
00814 }
00816 bool operator<(const CIMClass& x, const CIMClass& y)
00817 {
00818    return *x.m_pdata < *y.m_pdata;
00819 }
00820 
00822 bool operator==(const CIMClass& x, const CIMClass& y)
00823 {
00824    return *x.m_pdata == *y.m_pdata;
00825 }
00826 
00828 bool operator<=(const CIMClass& x, const CIMClass& y)
00829 {
00830     return !(y < x);
00831 }
00832 
00834 bool operator>(const CIMClass& x, const CIMClass& y)
00835 {
00836     return y < x;
00837 }
00838 
00840 bool operator>=(const CIMClass& x, const CIMClass& y)
00841 {
00842     return !(x < y);
00843 }
00844 
00846 bool operator!=(const CIMClass& x, const CIMClass& y)
00847 {
00848    return !(x == y);
00849 }
00850 
00852 const char* const CIMClass::NAMESPACECLASS = "__Namespace";
00854 StringArray
00855 CIMClass::getCloneProps(ELocalOnlyFlag localOnly, EDeepFlag deep,
00856    const StringArray* propertyList,
00857    const CIMClass& requestedClass) const
00858 {
00859    if (propertyList && propertyList->size() == 0)
00860    {
00861       return StringArray();
00862    }
00863    StringArray rv = this->getCloneProps(E_NOT_LOCAL_ONLY, propertyList);
00864    // do processing of deep & localOnly
00865    // don't filter anything if (deep == E_DEEP && localOnly == E_NOT_LOCAL_ONLY)
00866    if (deep != E_DEEP || localOnly != E_NOT_LOCAL_ONLY)
00867    {
00868       CIMPropertyArray props = this->getAllProperties();
00869       CIMName requestedClassName = requestedClass.getName();
00870       for (size_t i = 0; i < props.size(); ++i)
00871       {
00872          CIMProperty p = props[i];
00873          CIMProperty clsp = requestedClass.getProperty(p.getName());
00874          if (clsp)
00875          {
00876             if (clsp.getOriginClass() == requestedClassName)
00877             {
00878                rv.push_back(p.getName());
00879                continue;
00880             }
00881          }
00882          if (deep == E_DEEP)
00883          {
00884             if (!clsp || p.getOriginClass() != clsp.getOriginClass())
00885             {
00886                // the property is from a derived class
00887                rv.push_back(p.getName());
00888                continue;
00889             }
00890          }
00891          if (localOnly == E_NOT_LOCAL_ONLY)
00892          {
00893             if (clsp)
00894             {
00895                // the property has to be from a superclass
00896                rv.push_back(p.getName());
00897                continue;
00898             }
00899          }
00900       }
00901    }
00902    return rv;
00903 }
00905 StringArray
00906 CIMClass::getCloneProps(ELocalOnlyFlag localOnly,
00907    const StringArray* propertyList) const
00908 {
00909    StringArray props;
00910    if (propertyList && propertyList->size() == 0)
00911    {
00912       return props;
00913    }
00914    for (size_t i = 0; i < this->getAllProperties().size(); i++)
00915    {
00916       CIMProperty prop = this->getAllProperties()[i];
00917       if (localOnly && prop.getPropagated())
00918       {
00919          continue;
00920       }
00921       //
00922       // If propertyList is not NULL then check this is a request property
00923       //
00924       if (propertyList)
00925       {
00926          CIMName pName = prop.getName();
00927          for (size_t j = 0; j < propertyList->size(); j++)
00928          {
00929             if (pName == (*propertyList)[j])
00930             {
00931                props.push_back(prop.getName());
00932                break;
00933             }
00934          }
00935       }
00936       else
00937       {
00938          props.append(prop.getName());
00939       }
00940    }
00941    return props;
00942 }
00943 
00944 } // end namespace OW_NAMESPACE
00945 

Generated on Thu Feb 9 08:47:52 2006 for openwbem by  doxygen 1.4.6