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_CIMQualifier.hpp" 00038 #include "OWBI1_CIMQualifierRep.hpp" 00039 #include "OWBI1_CIMName.hpp" 00040 #include "OWBI1_CIMNameRep.hpp" 00041 #include "OWBI1_CIMQualifierType.hpp" 00042 #include "OWBI1_CIMQualifierTypeRep.hpp" 00043 #include "OWBI1_CIMValue.hpp" 00044 #include "OWBI1_CIMValueRep.hpp" 00045 #include "OWBI1_NULLValueException.hpp" 00046 #include "OWBI1_CIMFlavor.hpp" 00047 #include "OWBI1_CIMFlavorRep.hpp" 00048 #include "OWBI1_CIMDetail.hpp" 00049 #include "OW_Assertion.hpp" 00050 00051 namespace OWBI1 00052 { 00053 00054 using namespace detail; 00055 using std::istream; 00056 using std::ostream; 00057 00059 CIMQualifier::CIMQualifier() 00060 : m_rep(new CIMQualifierRep(OpenWBEM::CIMQualifier())) 00061 { 00062 } 00064 CIMQualifier::CIMQualifier(CIMNULL_t) 00065 : m_rep(new CIMQualifierRep(OpenWBEM::CIMQualifier(OpenWBEM::CIMNULL))) 00066 { 00067 } 00069 CIMQualifier::CIMQualifier(const CIMName& name) 00070 : m_rep(new CIMQualifierRep(OpenWBEM::CIMQualifier(name.getRep()->name))) 00071 { 00072 } 00074 CIMQualifier::CIMQualifier(const char* name) 00075 : m_rep(new CIMQualifierRep(OpenWBEM::CIMQualifier(name))) 00076 { 00077 } 00079 CIMQualifier::CIMQualifier(const CIMQualifierType& cgt) 00080 : m_rep(new CIMQualifierRep(OpenWBEM::CIMQualifier(cgt.getRep()->qualtype))) 00081 { 00082 } 00084 CIMQualifier::CIMQualifier(const CIMQualifier& x) 00085 : CIMElement(x) 00086 , m_rep(x.m_rep) 00087 { 00088 } 00089 00091 CIMQualifier::CIMQualifier(const CIMQualifierRepRef& rep) 00092 : m_rep(rep) 00093 { 00094 } 00095 00097 CIMQualifier::~CIMQualifier() 00098 { 00099 } 00101 void 00102 CIMQualifier::setNull() 00103 { 00104 m_rep->qual.setNull(); 00105 } 00107 CIMQualifier& 00108 CIMQualifier::operator= (const CIMQualifier& x) 00109 { 00110 m_rep = x.m_rep; 00111 return *this; 00112 } 00114 bool 00115 CIMQualifier::isKeyQualifier() const 00116 { 00117 return m_rep->qual.isKeyQualifier(); 00118 } 00120 bool 00121 CIMQualifier::isAssociationQualifier() const 00122 { 00123 return m_rep->qual.isAssociationQualifier(); 00124 } 00126 CIMValue 00127 CIMQualifier::getValue() const 00128 { 00129 return CIMValue(CIMValueRepRef(new CIMValueRep(m_rep->qual.getValue()))); 00130 } 00132 CIMValue 00133 CIMQualifier::getValueT() const 00134 { 00135 CIMValue rv = getValue(); 00136 if (!rv) 00137 { 00138 OWBI1_THROW(NULLValueException, ""); 00139 } 00140 return rv; 00141 } 00143 CIMQualifier& 00144 CIMQualifier::setValue(const CIMValue& value) 00145 { 00146 m_rep->qual.setValue(value.getRep()->value); 00147 return *this; 00148 } 00150 CIMQualifier& 00151 CIMQualifier::setDefaults(const CIMQualifierType& qtype) 00152 { 00153 m_rep->qual.setDefaults(qtype.getRep()->qualtype); 00154 return *this; 00155 } 00157 CIMQualifierType 00158 CIMQualifier::getDefaults() const 00159 { 00160 return CIMQualifierType(new CIMQualifierTypeRep(m_rep->qual.getDefaults())); 00161 } 00163 bool 00164 CIMQualifier::hasFlavor(const CIMFlavor& flavor) const 00165 { 00166 return m_rep->qual.hasFlavor(flavor.getRep()->flavor); 00167 } 00169 CIMQualifier& 00170 CIMQualifier::addFlavor(const CIMFlavor& flavor) 00171 { 00172 m_rep->qual.addFlavor(flavor.getRep()->flavor); 00173 return *this; 00174 } 00176 CIMQualifier& 00177 CIMQualifier::removeFlavor(Int32 flavor) 00178 { 00179 m_rep->qual.removeFlavor(flavor); 00180 return *this; 00181 } 00183 bool 00184 CIMQualifier::hasValue() const 00185 { 00186 return m_rep->qual.hasValue(); 00187 } 00189 bool 00190 CIMQualifier::equals(const CIMQualifier& arg) const 00191 { 00192 return m_rep->qual.equals(arg.getRep()->qual); 00193 } 00195 CIMFlavorArray 00196 CIMQualifier::getFlavors() const 00197 { 00198 return wrapArray<CIMFlavorArray>(m_rep->qual.getFlavor()); 00199 } 00201 CIMQualifier& 00202 CIMQualifier::setPropagated(bool propagated) 00203 { 00204 m_rep->qual.setPropagated(propagated); 00205 return *this; 00206 } 00208 bool 00209 CIMQualifier::getPropagated() const 00210 { 00211 return m_rep->qual.getPropagated(); 00212 } 00214 CIMQualifier& 00215 CIMQualifier::setLanguage(const String& language) 00216 { 00217 OW_ASSERT(hasFlavor(CIMFlavor::TRANSLATE)); 00218 m_rep->qual.setLanguage(language.c_str()); 00219 return *this; 00220 } 00222 String 00223 CIMQualifier::getLanguage() const 00224 { 00225 return m_rep->qual.getLanguage().c_str(); 00226 } 00228 CIMName 00229 CIMQualifier::getName() const 00230 { 00231 return m_rep->qual.getName().c_str(); 00232 } 00234 void 00235 CIMQualifier::setName(const CIMName& name) 00236 { 00237 m_rep->qual.setName(name.getRep()->name); 00238 } 00240 void 00241 CIMQualifier::readObject(istream &istrm) 00242 { 00243 m_rep->qual.readObject(istrm); 00244 } 00246 void 00247 CIMQualifier::writeObject(ostream &ostrm) const 00248 { 00249 m_rep->qual.writeObject(ostrm); 00250 } 00252 String 00253 CIMQualifier::toMOF() const 00254 { 00255 return m_rep->qual.toMOF().c_str(); 00256 } 00258 String 00259 CIMQualifier::toString() const 00260 { 00261 return m_rep->qual.toString().c_str(); 00262 } 00264 // STATIC 00265 CIMQualifier 00266 CIMQualifier::createKeyQualifier() 00267 { 00268 return CIMQualifier(new CIMQualifierRep(OpenWBEM::CIMQualifier::createKeyQualifier())); 00269 } 00270 00272 CIMQualifierRepRef 00273 CIMQualifier::getRep() const 00274 { 00275 return m_rep; 00276 } 00277 00279 CIMQualifier::operator safe_bool () const 00280 { 00281 return m_rep->qual ? &CIMQualifier::m_rep : 0; 00282 } 00283 00285 bool 00286 CIMQualifier::operator!() const 00287 { 00288 return !m_rep->qual; 00289 } 00290 00291 00293 bool operator<(const CIMQualifier& x, const CIMQualifier& y) 00294 { 00295 return *x.m_rep < *y.m_rep; 00296 } 00297 00298 // Meta qualifiers 00299 const char* const CIMQualifier::CIM_QUAL_ASSOCIATION = "Association"; 00300 const char* const CIMQualifier::CIM_QUAL_INDICATION = "Indication"; 00301 // Standard qualifiers 00302 const char* const CIMQualifier::CIM_QUAL_ABSTRACT = "Abstract"; 00303 const char* const CIMQualifier::CIM_QUAL_AGGREGATE = "Aggregate"; 00304 const char* const CIMQualifier::CIM_QUAL_AGGREGATION = "Aggregation"; 00305 const char* const CIMQualifier::CIM_QUAL_ALIAS = "Alias"; 00306 const char* const CIMQualifier::CIM_QUAL_ARRAYTYPE = "ArrayType"; 00307 const char* const CIMQualifier::CIM_QUAL_BITMAP = "BitMap"; 00308 const char* const CIMQualifier::CIM_QUAL_BITVALUES = "BitValues"; 00309 const char* const CIMQualifier::CIM_QUAL_COMPOSITION = "Composition"; 00310 const char* const CIMQualifier::CIM_QUAL_COUNTER = "Counter"; 00311 const char* const CIMQualifier::CIM_QUAL_DELETE = "Delete"; 00312 const char* const CIMQualifier::CIM_QUAL_DEPRECATED = "Deprecated"; 00313 const char* const CIMQualifier::CIM_QUAL_DESCRIPTION = "Description"; 00314 const char* const CIMQualifier::CIM_QUAL_DISPLAYNAME = "DisplayName"; 00315 const char* const CIMQualifier::CIM_QUAL_DN = "DN"; 00316 const char* const CIMQualifier::CIM_QUAL_EMBEDDEDOBJECT = "EmbeddedObject"; 00317 const char* const CIMQualifier::CIM_QUAL_EXCEPTION = "Exception"; 00318 const char* const CIMQualifier::CIM_QUAL_EXPENSIVE = "Expensive"; 00319 const char* const CIMQualifier::CIM_QUAL_EXPERIMENTAL = "Experimental"; 00320 const char* const CIMQualifier::CIM_QUAL_GAUGE = "Gauge"; 00321 const char* const CIMQualifier::CIM_QUAL_IFDELETED = "Ifdeleted"; 00322 const char* const CIMQualifier::CIM_QUAL_IN = "In"; 00323 const char* const CIMQualifier::CIM_QUAL_INVISIBLE = "Invisible"; 00324 const char* const CIMQualifier::CIM_QUAL_KEY = "Key"; 00325 const char* const CIMQualifier::CIM_QUAL_LARGE = "Large"; 00326 const char* const CIMQualifier::CIM_QUAL_MAPPINGSTRINGS = "MappingStrings"; 00327 const char* const CIMQualifier::CIM_QUAL_MAX = "Max"; 00328 const char* const CIMQualifier::CIM_QUAL_MAXLEN = "MaxLen"; 00329 const char* const CIMQualifier::CIM_QUAL_MAXVALUE = "MaxValue"; 00330 const char* const CIMQualifier::CIM_QUAL_MIN = "Min"; 00331 const char* const CIMQualifier::CIM_QUAL_MINLEN = "MinLen"; 00332 const char* const CIMQualifier::CIM_QUAL_MINVALUE = "MinValue"; 00333 const char* const CIMQualifier::CIM_QUAL_MODELCORRESPONDENCE = "ModelCorrespondence"; 00334 const char* const CIMQualifier::CIM_QUAL_NONLOCAL = "Nonlocal"; 00335 const char* const CIMQualifier::CIM_QUAL_NONLOCALTYPE = "NonlocalType"; 00336 const char* const CIMQualifier::CIM_QUAL_NULLVALUE = "NullValue"; 00337 const char* const CIMQualifier::CIM_QUAL_OCTETSTRING = "Octetstring"; 00338 const char* const CIMQualifier::CIM_QUAL_OUT = "Out"; 00339 const char* const CIMQualifier::CIM_QUAL_OVERRIDE = "Override"; 00340 const char* const CIMQualifier::CIM_QUAL_PROPAGATED = "Propagated"; 00341 const char* const CIMQualifier::CIM_QUAL_PROPERTYUSAGE = "PropertyUsage"; 00342 const char* const CIMQualifier::CIM_QUAL_PROVIDER = "Provider"; 00343 const char* const CIMQualifier::CIM_QUAL_READ = "Read"; 00344 const char* const CIMQualifier::CIM_QUAL_REQUIRED = "Required"; 00345 const char* const CIMQualifier::CIM_QUAL_REVISION = "Revision"; 00346 const char* const CIMQualifier::CIM_QUAL_SCHEMA = "Schema"; 00347 const char* const CIMQualifier::CIM_QUAL_SOURCE = "Source"; 00348 const char* const CIMQualifier::CIM_QUAL_SOURCETYPE = "SourceType"; 00349 const char* const CIMQualifier::CIM_QUAL_STATIC = "Static"; 00350 const char* const CIMQualifier::CIM_QUAL_SYNTAX = "Syntax"; 00351 const char* const CIMQualifier::CIM_QUAL_SYNTAXTYPE = "SyntaxType"; 00352 const char* const CIMQualifier::CIM_QUAL_TERMINAL = "Terminal"; 00353 const char* const CIMQualifier::CIM_QUAL_TRIGGERTYPE = "TriggerType"; 00354 const char* const CIMQualifier::CIM_QUAL_UNITS = "Units"; 00355 const char* const CIMQualifier::CIM_QUAL_UNKNOWNVALUES = "UnknownValues"; 00356 const char* const CIMQualifier::CIM_QUAL_UNSUPPORTEDVALUES = "UnsupportedValues"; 00357 const char* const CIMQualifier::CIM_QUAL_VALUEMAP = "ValueMap"; 00358 const char* const CIMQualifier::CIM_QUAL_VALUES = "Values"; 00359 const char* const CIMQualifier::CIM_QUAL_VERSION = "Version"; 00360 const char* const CIMQualifier::CIM_QUAL_WEAK = "Weak"; 00361 const char* const CIMQualifier::CIM_QUAL_WRITE = "Write"; 00362 00363 } // end namespace OWBI1 00364