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 #ifndef OW_CIMVALUE_HPP_INCLUDE_GUARD_ 00037 #define OW_CIMVALUE_HPP_INCLUDE_GUARD_ 00038 #include "OW_config.h" 00039 #include "OW_CIMBase.hpp" 00040 #include "OW_COWIntrusiveReference.hpp" 00041 #include "OW_CIMFwd.hpp" 00042 #include "OW_Array.hpp" 00043 #include "OW_CIMDataType.hpp" 00044 #include "OW_CIMNULL.hpp" 00045 00046 namespace OW_NAMESPACE 00047 { 00048 00053 class OW_COMMON_API CIMValue : public CIMBase 00054 { 00055 class CIMValueImpl; 00056 public: 00065 static CIMValue createSimpleValue(const String& cimtype, 00066 const String& value); 00070 explicit CIMValue(CIMNULL_t); 00075 CIMValue(const CIMValue& x); 00080 explicit CIMValue(Bool x); 00085 explicit CIMValue(bool x); 00090 explicit CIMValue(UInt8 x); 00095 explicit CIMValue(Int8 x); 00100 explicit CIMValue(UInt16 x); 00105 explicit CIMValue(Int16 x); 00110 explicit CIMValue(UInt32 x); 00115 explicit CIMValue(Int32 x); 00120 explicit CIMValue(UInt64 x); 00125 explicit CIMValue(Int64 x); 00130 explicit CIMValue(Real32 x); 00135 explicit CIMValue(Real64 x); 00140 explicit CIMValue(const Char16& x); 00145 explicit CIMValue(const String& x); 00150 explicit CIMValue(const char* x); 00155 explicit CIMValue(const CIMDateTime& x); 00160 explicit CIMValue(const CIMObjectPath& x); 00165 explicit CIMValue(const CIMClass& x); 00170 explicit CIMValue(const CIMInstance& x); 00175 explicit CIMValue(const BoolArray& x); 00180 explicit CIMValue(const Char16Array& x); 00185 explicit CIMValue(const UInt8Array& x); 00190 explicit CIMValue(const Int8Array& x); 00195 explicit CIMValue(const UInt16Array& x); 00200 explicit CIMValue(const Int16Array& x); 00205 explicit CIMValue(const UInt32Array& x); 00210 explicit CIMValue(const Int32Array& x); 00215 explicit CIMValue(const UInt64Array& x); 00220 explicit CIMValue(const Int64Array& x); 00225 explicit CIMValue(const Real64Array& x); 00230 explicit CIMValue(const Real32Array& x); 00235 explicit CIMValue(const StringArray& x); 00240 explicit CIMValue(const CIMDateTimeArray& x); 00245 explicit CIMValue(const CIMObjectPathArray& x); 00250 explicit CIMValue(const CIMClassArray& x); 00255 explicit CIMValue(const CIMInstanceArray& x); 00256 private: 00257 // These are private/unimplemented to help prevent unintended errors of 00258 // passing a pointer to the constructor. 00259 explicit CIMValue(const void*); 00260 explicit CIMValue(void*); 00261 explicit CIMValue(volatile const void*); 00262 explicit CIMValue(volatile void*); 00263 public: 00267 ~CIMValue(); 00272 UInt32 getArraySize() const; 00276 void get(Bool& x) const; 00280 void get(Char16& x) const; 00284 void get(UInt8& x) const; 00288 void get(Int8& x) const; 00292 void get(UInt16& x) const; 00296 void get(Int16& x) const; 00300 void get(UInt32& x) const; 00304 void get(Int32& x) const; 00308 void get(UInt64& x) const; 00312 void get(Int64& x) const; 00316 void get(Real32& x) const; 00320 void get(Real64& x) const; 00324 void get(String& x) const; 00328 void get(CIMDateTime& x) const; 00332 void get(CIMObjectPath& x) const; 00336 void get(CIMClass& x) const; 00340 void get(CIMInstance& x) const; 00344 void get(CIMObjectPathArray& x) const; 00348 void get(Char16Array& x) const; 00352 void get(UInt8Array& x) const; 00356 void get(Int8Array& x) const; 00360 void get(UInt16Array& x) const; 00364 void get(Int16Array& x) const; 00368 void get(UInt32Array& x) const; 00372 void get(Int32Array& x) const; 00376 void get(UInt64Array& x) const; 00380 void get(Int64Array& x) const; 00384 void get(Real64Array& x) const; 00388 void get(Real32Array& x) const; 00392 void get(StringArray& x) const; 00396 void get(BoolArray& x) const; 00400 void get(CIMDateTimeArray& x) const; 00404 void get(CIMClassArray& x) const; 00408 void get(CIMInstanceArray& x) const; 00409 Bool toBool() const; 00410 Char16 toChar16() const; 00411 UInt8 toUInt8() const; 00412 Int8 toInt8() const; 00413 UInt16 toUInt16() const; 00414 Int16 toInt16() const; 00415 UInt32 toUInt32() const; 00416 Int32 toInt32() const; 00417 UInt64 toUInt64() const; 00418 Int64 toInt64() const; 00419 Real32 toReal32() const; 00420 Real64 toReal64() const; 00421 CIMDateTime toCIMDateTime() const; 00422 CIMObjectPath toCIMObjectPath() const; 00423 CIMClass toCIMClass() const; 00424 CIMInstance toCIMInstance() const; 00425 CIMObjectPathArray toCIMObjectPathArray() const; 00426 Char16Array toChar16Array() const; 00427 UInt8Array toUInt8Array() const; 00428 Int8Array toInt8Array() const; 00429 UInt16Array toUInt16Array() const; 00430 Int16Array toInt16Array() const; 00431 UInt32Array toUInt32Array() const; 00432 Int32Array toInt32Array() const; 00433 UInt64Array toUInt64Array() const; 00434 Int64Array toInt64Array() const; 00435 Real64Array toReal64Array() const; 00436 Real32Array toReal32Array() const; 00437 StringArray toStringArray() const; 00438 BoolArray toBoolArray() const; 00439 CIMDateTimeArray toCIMDateTimeArray() const; 00440 CIMClassArray toCIMClassArray() const; 00441 CIMInstanceArray toCIMInstanceArray() const; 00442 00446 virtual void setNull(); 00447 00448 typedef COWIntrusiveReference<CIMValueImpl> CIMValue::*safe_bool; 00449 operator safe_bool () const 00450 { return (m_impl) ? &CIMValue::m_impl : 0; } 00451 bool operator!() const 00452 { return !m_impl; } 00458 CIMValue& set(const CIMValue& x); 00464 CIMValue& operator= (const CIMValue& x); 00470 bool equal(const CIMValue& x) const; 00477 bool operator== (const CIMValue& x) const; 00484 bool operator!= (const CIMValue& x) const; 00491 bool operator<= (const CIMValue& x) const; 00498 bool operator>= (const CIMValue& x) const; 00505 bool operator< (const CIMValue& x) const; 00512 bool operator> (const CIMValue& x) const; 00517 CIMDataType::Type getType() const; 00522 CIMDataType getCIMDataType() const; 00528 bool sameType(const CIMValue& x) const; 00532 bool isArray() const; 00537 virtual void readObject(std::istream &istrm); 00542 virtual void writeObject(std::ostream &ostrm) const; 00546 virtual String toString() const; 00550 virtual String toMOF() const; 00554 bool isNumericType() const; 00555 private: 00556 00557 #ifdef OW_WIN32 00558 #pragma warning (push) 00559 #pragma warning (disable: 4251) 00560 #endif 00561 00562 COWIntrusiveReference<CIMValueImpl> m_impl; 00563 00564 #ifdef OW_WIN32 00565 #pragma warning (pop) 00566 #endif 00567 00568 }; 00569 00570 } // end namespace OW_NAMESPACE 00571 00572 #endif