OWBI1_CIMProperty.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 "OWBI1_config.h"
00037 #include "OWBI1_CIMProperty.hpp"
00038 #include "OWBI1_CIMPropertyRep.hpp"
00039 #include "OW_CIMProperty.hpp"
00040 #include "OWBI1_CIMName.hpp"
00041 #include "OWBI1_CIMNameRep.hpp"
00042 #include "OWBI1_CIMValue.hpp"
00043 #include "OWBI1_CIMValueRep.hpp"
00044 #include "OWBI1_CIMDataType.hpp"
00045 #include "OWBI1_CIMDataTypeRep.hpp"
00046 #include "OWBI1_CIMDetail.hpp"
00047 #include "OWBI1_NULLValueException.hpp"
00048 #include "OWBI1_CIMQualifier.hpp"
00049 #include "OWBI1_CIMQualifierRep.hpp"
00050 #include "OWBI1_NoSuchQualifierException.hpp"
00051 #include "OW_CIMException.hpp"
00052 #include "OWBI1_ProxyProviderDetail.hpp"
00053 
00054 namespace OWBI1
00055 {
00056 
00057 using std::istream;
00058 using std::ostream;
00059 using namespace WBEMFlags;
00060 using namespace detail;
00061 
00063 CIMProperty::CIMProperty()
00064    : m_rep(new CIMPropertyRep(OpenWBEM::CIMProperty()))
00065 {
00066 }
00068 CIMProperty::CIMProperty(CIMNULL_t)
00069    : m_rep(new CIMPropertyRep(OpenWBEM::CIMProperty(OpenWBEM::CIMNULL)))
00070 {
00071 }
00073 CIMProperty::CIMProperty(const CIMName& name) 
00074    : m_rep(new CIMPropertyRep(OpenWBEM::CIMProperty(name.getRep()->name)))
00075 {
00076 }
00078 CIMProperty::CIMProperty(const char* name) 
00079    : m_rep(new CIMPropertyRep(OpenWBEM::CIMProperty(name)))
00080 {
00081 }
00083 CIMProperty::CIMProperty(const CIMName& name, const CIMValue& value) 
00084    : m_rep(new CIMPropertyRep(OpenWBEM::CIMProperty(name.getRep()->name, value.getRep()->value)))
00085 {
00086 }
00088 CIMProperty::CIMProperty(const CIMName& name, const CIMDataType& dt) 
00089    : m_rep(new CIMPropertyRep(OpenWBEM::CIMProperty(name.getRep()->name, dt.getRep()->datatype)))
00090 {
00091 }
00093 CIMProperty::CIMProperty(const CIMProperty& x) 
00094    : CIMElement(x)
00095    , m_rep(x.m_rep)
00096 {
00097 }
00099 CIMProperty::CIMProperty(const CIMPropertyRepRef& rep)
00100    : m_rep(rep)
00101 {
00102 }
00103 
00105 CIMProperty::~CIMProperty()
00106 {
00107 }
00109 void
00110 CIMProperty::setNull()
00111 {
00112    m_rep->prop.setNull();
00113 }
00115 CIMProperty&
00116 CIMProperty::operator= (const CIMProperty& x)
00117 {
00118    m_rep = x.m_rep;
00119    return *this;
00120 }
00122 CIMQualifierArray
00123 CIMProperty::getQualifiers() const
00124 {
00125    return wrapArray<CIMQualifierArray>(m_rep->prop.getQualifiers());
00126 }
00128 CIMProperty&
00129 CIMProperty::setQualifiers(const CIMQualifierArray& quals)
00130 {
00131    m_rep->prop.setQualifiers(unwrapArray<OpenWBEM::CIMQualifierArray>(quals));
00132    return *this;
00133 }
00135 CIMName
00136 CIMProperty::getOriginClass() const
00137 {
00138    return CIMName(new CIMNameRep(m_rep->prop.getOriginClass()));
00139 }
00141 CIMProperty&
00142 CIMProperty::setOriginClass(const CIMName& originCls)
00143 {
00144    m_rep->prop.setOriginClass(originCls.getRep()->name);
00145    return *this;
00146 }
00148 CIMProperty&
00149 CIMProperty::setValue(const CIMValue& val)
00150 {
00151    m_rep->prop.setValue(val.getRep()->value);
00152    return *this;
00153 }
00155 CIMValue
00156 CIMProperty::getValue() const
00157 {
00158    return CIMValue(CIMValueRepRef(new CIMValueRep(m_rep->prop.getValue())));
00159 }
00161 CIMValue
00162 CIMProperty::getValueT() const
00163 {
00164    CIMValue rv(CIMValueRepRef(new CIMValueRep(m_rep->prop.getValue())));
00165    if (!rv)
00166    {
00167       OWBI1_THROW(NULLValueException, getName().c_str());
00168    }
00169    return rv;
00170 }
00172 CIMProperty&
00173 CIMProperty::setDataType(const CIMDataType& type)
00174 {
00175    m_rep->prop.setDataType(type.getRep()->datatype);
00176    return *this;
00177 }
00179 CIMProperty&
00180 CIMProperty::setDataType(const CIMDataType::Type& type)
00181 {
00182    return setDataType(CIMDataType(type));
00183 }
00185 CIMDataType
00186 CIMProperty::getDataType() const
00187 {
00188    return CIMDataType(new CIMDataTypeRep(m_rep->prop.getDataType()));
00189 }
00191 Int32
00192 CIMProperty::getSize() const
00193 {
00194    return m_rep->prop.getSize();
00195 }
00197 CIMProperty&
00198 CIMProperty::setDataSize(Int32 size)
00199 {
00200    m_rep->prop.setDataSize(size);
00201    return *this;
00202 }
00204 CIMProperty&
00205 CIMProperty::setOverridingProperty(const CIMName& opname)
00206 {
00207    m_rep->prop.setOverridingProperty(opname.getRep()->name);
00208    return *this;
00209 }
00211 CIMName
00212 CIMProperty::getOverridingProperty() const
00213 {
00214    return CIMName(new CIMNameRep(m_rep->prop.getOverridingProperty()));
00215 }
00217 bool
00218 CIMProperty::isReference() const
00219 {
00220    return m_rep->prop.isReference();
00221 }
00223 CIMQualifier
00224 CIMProperty::getQualifier(const CIMName& name) const
00225 {
00226    return CIMQualifier(new CIMQualifierRep(m_rep->prop.getQualifier(name.getRep()->name)));
00227 }
00229 CIMQualifier
00230 CIMProperty::getQualifierT(const CIMName& name) const
00231 {
00232    CIMQualifier rval = getQualifier(name);
00233    if (!rval)
00234    {
00235       OWBI1_THROW(NoSuchQualifierException, name.toString().c_str());
00236    }
00237    return rval;
00238 }
00240 CIMProperty&
00241 CIMProperty::setQualifier(const CIMQualifier& qual)
00242 {
00243    m_rep->prop.setQualifier(qual.getRep()->qual);
00244    return *this;
00245 }
00247 bool
00248 CIMProperty::addQualifier(const CIMQualifier& qual)
00249 {
00250    try
00251    {
00252       m_rep->prop.addQualifier(qual.getRep()->qual);
00253    }
00254    catch (OpenWBEM::CIMException& e)
00255    {
00256       return false;
00257    }
00258    return true;
00259 }
00261 bool
00262 CIMProperty::removeQualifier(const CIMName& name)
00263 {
00264    return m_rep->prop.removeQualifier(name.getRep()->name);
00265 }
00267 bool
00268 CIMProperty::isKey() const
00269 {
00270    return m_rep->prop.isKey();
00271 }
00273 CIMProperty&
00274 CIMProperty::setPropagated(bool propagated)
00275 {
00276    m_rep->prop.setPropagated(propagated);
00277    return *this;
00278 }
00280 bool
00281 CIMProperty::getPropagated() const
00282 {
00283    return m_rep->prop.getPropagated();
00284 }
00286 CIMName
00287 CIMProperty::getName() const
00288 {
00289    return CIMName(new CIMNameRep(m_rep->prop.getName()));
00290 }
00292 void
00293 CIMProperty::setName(const CIMName& name)
00294 {
00295    m_rep->prop.setName(name.getRep()->name);
00296 }
00298 void
00299 CIMProperty::writeObject(ostream &ostrm) const
00300 {
00301    writeObject(ostrm, E_INCLUDE_QUALIFIERS);
00302 }
00304 void
00305 CIMProperty::writeObject(ostream &ostrm, EIncludeQualifiersFlag includeQualifiers) const
00306 {
00307    m_rep->prop.writeObject(ostrm, convertWBEMFlag(includeQualifiers));
00308 }
00310 void
00311 CIMProperty::readObject(istream &istrm)
00312 {
00313    m_rep->prop.readObject(istrm);
00314 }
00316 String
00317 CIMProperty::toString() const
00318 {
00319    return m_rep->prop.toString().c_str();
00320 }
00322 String
00323 CIMProperty::toMOF() const
00324 {
00325    return m_rep->prop.toMOF().c_str();
00326 }
00328 const char* const CIMProperty::NAME_PROPERTY = "Name";
00330 bool operator<(const CIMProperty& x, const CIMProperty& y)
00331 {
00332    return *x.getRep() < *y.getRep();
00333 }
00334 
00336 bool
00337 CIMProperty::hasTrueQualifier(const CIMName& name) const
00338 {
00339    return m_rep->prop.hasTrueQualifier(name.getRep()->name);
00340 }
00341 
00343 CIMProperty::operator safe_bool () const
00344 {  
00345    return m_rep->prop ? &CIMProperty::m_rep : 0; 
00346 }
00347 
00349 bool 
00350 CIMProperty::operator!() const
00351 {  
00352    return !(m_rep->prop); 
00353 }
00354 
00355 } // end namespace OWBI1
00356 

Generated on Thu Feb 9 08:48:26 2006 for openwbem by  doxygen 1.4.6