(file) Return to CIMValue.h CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Common

Diff for /pegasus/src/Pegasus/Common/CIMValue.h between version 1.2 and 1.32

version 1.2, 2001/02/20 05:16:57 version 1.32, 2002/09/20 04:06:42
Line 1 
Line 1 
 //BEGIN_LICENSE  //%/////////////////////////////////////////////////////////////////////////////
 // //
 // Copyright (c) 2000 The Open Group, BMC Software, Tivoli Systems, IBM  // Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Company, IBM,
   // The Open Group, Tivoli Systems
 // //
 // Permission is hereby granted, free of charge, to any person obtaining a  // Permission is hereby granted, free of charge, to any person obtaining a copy
 // copy of this software and associated documentation files (the "Software"),  // of this software and associated documentation files (the "Software"), to
 // to deal in the Software without restriction, including without limitation  // deal in the Software without restriction, including without limitation the
 // the rights to use, copy, modify, merge, publish, distribute, sublicense,  // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 // and/or sell copies of the Software, and to permit persons to whom the  // sell copies of the Software, and to permit persons to whom the Software is
 // Software is furnished to do so, subject to the following conditions:  // furnished to do so, subject to the following conditions:
   //
   // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
   // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
   // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
   // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
   // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
   // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
   // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
   // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
   //
   //==============================================================================
   //
   // Author: Mike Brasher (mbrasher@bmc.com)
   //
   // Modified By: Karl schopmeyer (k.schopmeyer@opengroup.org)
   //              Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com)
   //              Carol Ann Krug Graves, Hewlett-Packard Company
   //                (carolann_graves@hp.com)
 // //
 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR  //%/////////////////////////////////////////////////////////////////////////////
 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,  
 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL  
 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER  
 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING  
 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER  
 // DEALINGS IN THE SOFTWARE.  
 //  
 //END_LICENSE  
 //BEGIN_HISTORY  
 //  
 // Author:  
 //  
 // $Log$  
 // Revision 1.2  2001/02/20 05:16:57  mike  
 // Implemented CIMInstance::getInstanceName()  
 //  
 // Revision 1.1  2001/02/18 18:39:06  mike  
 // new  
 //  
 // Revision 1.2  2001/02/18 02:49:00  mike  
 // Removed ugly workarounds for MSVC++ 5.0 (using SP3 now)  
 //  
 // Revision 1.1  2001/02/16 02:07:06  mike  
 // Renamed many classes and headers (using new CIM prefixes).  
 //  
 // Revision 1.3  2001/01/30 08:00:43  karl  
 // DOC++ Documentation update for header files  
 //  
 // Revision 1.2  2001/01/29 08:03:12  karl  
 // DOC++ Documentation  
 //  
 // Revision 1.1.1.1  2001/01/14 19:53:21  mike  
 // Pegasus import  
 //  
 //  
 //END_HISTORY  
  
 #ifndef Pegasus_Value_h #ifndef Pegasus_Value_h
 #define Pegasus_Value_h #define Pegasus_Value_h
  
   #include <Pegasus/Common/String.h>
 #include <Pegasus/Common/Config.h> #include <Pegasus/Common/Config.h>
 #include <Pegasus/Common/CIMType.h> #include <Pegasus/Common/CIMType.h>
 #include <Pegasus/Common/String.h>  #include <Pegasus/Common/CIMObjectPath.h>
 #include <Pegasus/Common/CIMDateTime.h> #include <Pegasus/Common/CIMDateTime.h>
 #include <Pegasus/Common/Union.h>  #include <Pegasus/Common/Exception.h>
 #include <Pegasus/Common/Array.h> #include <Pegasus/Common/Array.h>
   #include <Pegasus/Common/Linkage.h>
  
 PEGASUS_NAMESPACE_BEGIN PEGASUS_NAMESPACE_BEGIN
  
   class CIMValueRep;
   
 /** /**
     The CIMValue class represents a value of any of the CIM data types     The CIMValue class represents a value of any of the CIM data types
     (see CIMType.h for a list of valid CIM data types). This class     (see CIMType.h for a list of valid CIM data types). This class
Line 68 
Line 55 
 class PEGASUS_COMMON_LINKAGE CIMValue class PEGASUS_COMMON_LINKAGE CIMValue
 { {
 public: public:
     /// Constructor      /** Constructor with no value. This constructor creates an NULL CIMValue
           object set to null and with type CIMType:none and !arraytype.
       */
     CIMValue();     CIMValue();
  
     /// Constructor      /** Constructor that creates a NULL CIMValue object with the type and
     CIMValue(Boolean x) { _init(); set(x); }          array indicator set as specified.
           @exception TypeMismatchException If the given type is not valid for a
           CIMValue object.
       */
       CIMValue(CIMType type, Boolean isArray, Uint32 arraySize = 0);
   
       // ATTN This needs an example
       /** Constructor with the Value constructor and a value.
           This constructs a
           CIMValue object with the type defined by the value constructor
           and the value
           installed
       */
       CIMValue(Boolean x);
  
     /// Constructor     /// Constructor
     CIMValue(Uint8 x) { _init(); set(x); }      CIMValue(Uint8 x);
  
     /// Constructor     /// Constructor
     CIMValue(Sint8 x) { _init(); set(x); }      CIMValue(Sint8 x);
  
     /// Constructor     /// Constructor
     CIMValue(Uint16 x) { _init(); set(x); }      CIMValue(Uint16 x);
  
     /// Constructor     /// Constructor
     CIMValue(Sint16 x) { _init(); set(x); }      CIMValue(Sint16 x);
  
     /// Constructor     /// Constructor
     CIMValue(Uint32 x) { _init(); set(x); }      CIMValue(Uint32 x);
  
     /// Constructor     /// Constructor
     CIMValue(Sint32 x) { _init(); set(x); }      CIMValue(Sint32 x);
  
     /// Constructor     /// Constructor
     CIMValue(Uint64 x) { _init(); set(x); }      CIMValue(Uint64 x);
  
     /// Constructor     /// Constructor
     CIMValue(Sint64 x) { _init(); set(x); }      CIMValue(Sint64 x);
  
     /// Constructor     /// Constructor
     CIMValue(Real32 x) { _init(); set(x); }      CIMValue(Real32 x);
  
     /// Constructor     /// Constructor
     CIMValue(Real64 x) { _init(); set(x); }      CIMValue(Real64 x);
  
     /// Constructor     /// Constructor
     CIMValue(const Char16& x) { _init(); set(x); }      CIMValue(const Char16& x);
  
     /// Constructor     /// Constructor
     CIMValue(const String& x) { _init(); set(x); }      CIMValue(const String& x);
  
     /// Constructor     /// Constructor
     CIMValue(const char* x) { _init(); set(x); }      CIMValue(const CIMDateTime& x);
  
     /// Constructor     /// Constructor
     CIMValue(const CIMDateTime& x) { _init(); set(x); }      CIMValue(const CIMObjectPath& x);
  
     /// Constructor     /// Constructor
     CIMValue(const CIMReference& x) { _init(); set(x); }      CIMValue(const Array<Boolean>& x);
  
     /// Constructor     /// Constructor
     CIMValue(const Array<Boolean>& x) { _init(); set(x); }      CIMValue(const Array<Uint8>& x);
  
     /// Constructor     /// Constructor
     CIMValue(const Array<Uint8>& x) { _init(); set(x); }      CIMValue(const Array<Sint8>& x);
  
     /// Constructor     /// Constructor
     CIMValue(const Array<Sint8>& x) { _init(); set(x); }      CIMValue(const Array<Uint16>& x);
  
     /// Constructor     /// Constructor
     CIMValue(const Array<Uint16>& x) { _init(); set(x); }      CIMValue(const Array<Sint16>& x);
  
     /// Constructor     /// Constructor
     CIMValue(const Array<Sint16>& x) { _init(); set(x); }      CIMValue(const Array<Uint32>& x);
  
     /// Constructor     /// Constructor
     CIMValue(const Array<Uint32>& x) { _init(); set(x); }      CIMValue(const Array<Sint32>& x);
  
     /// Constructor     /// Constructor
     CIMValue(const Array<Sint32>& x) { _init(); set(x); }      CIMValue(const Array<Uint64>& x);
  
     /// Constructor     /// Constructor
     CIMValue(const Array<Uint64>& x) { _init(); set(x); }      CIMValue(const Array<Sint64>& x);
  
     /// Constructor     /// Constructor
     CIMValue(const Array<Sint64>& x) { _init(); set(x); }      CIMValue(const Array<Real32>& x);
  
     /// Constructor     /// Constructor
     CIMValue(const Array<Real32>& x) { _init(); set(x); }      CIMValue(const Array<Real64>& x);
  
     /// Constructor     /// Constructor
     CIMValue(const Array<Real64>& x) { _init(); set(x); }      CIMValue(const Array<Char16>& x);
  
     /// Constructor     /// Constructor
     CIMValue(const Array<Char16>& x) { _init(); set(x); }      CIMValue(const Array<String>& x);
  
     /// Constructor     /// Constructor
     CIMValue(const Array<String>& x) { _init(); set(x); }      CIMValue(const Array<CIMDateTime>& x);
  
     /// Constructor     /// Constructor
     CIMValue(const Array<CIMDateTime>& x) { _init(); set(x); }      CIMValue(const Array<CIMObjectPath>& x);
  
     /// Constructor     /// Constructor
     CIMValue(const CIMValue& x);     CIMValue(const CIMValue& x);
  
     /// Destrustructor      /// Destructor
     ~CIMValue();     ~CIMValue();
  
     /// Operator =     /// Operator =
     CIMValue& operator=(const CIMValue& x)      CIMValue& operator=(const CIMValue& x);
     {  
         assign(x); return *this;  
     }  
  
     /// CIMMethod assign      /** assign - The method to assign one CIMValue object to another CIMValue
       object.
       */
     void assign(const CIMValue& x);     void assign(const CIMValue& x);
  
     /// CIMMethod clear      /** clear - Clears the attributes and value of the CIMValue object.
       */
     void clear();     void clear();
  
     /** CIMMethod typeCompatible - Compares the types of two values.      /** typeCompatible - Compares the types of two CIMValues. This
         @return true if compatible.          compares the type field and the array indicators.
           @return true if both are of the same type and both are either arrays
           or not. Else returns false.
           <pre>
               CIMValue a(Boolean(true);
               CIMValue b = a;
               if b.typeCompatible(a)
                   ...
           </pre>
     */     */
     Boolean typeCompatible(const CIMValue& x) const      Boolean typeCompatible(const CIMValue& x) const;
     {  
         return _type == x._type && _isArray == x._isArray;  
     }  
  
     /** CIMMethod isArray - Determines if the value is an array      /** isArray - Determines if the value is an array
         @return TRUE if the value is an array         @return TRUE if the value is an array
     */     */
     Boolean isArray() const { return _isArray; }      Boolean isArray() const;
  
     /** CIMMethod getArraySize      /** Returns whether the CIMvalue object is Null.
           Null is the specific condition where no value has
           yet been set into the value.
           If a CIMValue object is Null, any get on that object
           will create an exception.
           @return Returns True if the CIMValue object is Null
       */
       Boolean isNull() const;
   
       /** getArraySize = Returns the size of an Array CIMValue
         @return The number of entries in the array         @return The number of entries in the array
     */     */
     Uint32 getArraySize() const;     Uint32 getArraySize() const;
  
     CIMType getType() const      /** getType - Gets the CIMType attribute for the CIMValue.
     {          @return the CIMType value
         return CIMType(_type);      */
     }      CIMType getType() const;
  
     /// method setNullvalue - ATTN:      /** setNullValue - Sets the CIMType, the Array indicator and if it is
           the arraytype, the Arraysize of a CIMValue and sets the isNull
           Attribute.  This function is used to set up CIMValues an NULL but
           with valid CIMType and array characteristics (ex. when update from
           XML)
           @param type - The CIMType for this CIMValue
           @param isArray - Boolean indicating whether this is an array CIMValue
           @param arraySize (optional) Uint32 parameter indicating the array
           size
           @return void
           <pre>
               CIMValue value;                   // Create a CIMValue object
               value.setNullValue(CIMType::BOOLEAN, false);  // Set it
           </pre>
       */
     void setNullValue(CIMType type, Boolean isArray, Uint32 arraySize = 0);     void setNullValue(CIMType type, Boolean isArray, Uint32 arraySize = 0);
  
     /// method set - ATTN:      //  All of the CIMTypes defined in ATTN: and the Array types defined in
       //  ATTN: may be set.
       /** set - Sets the type, Array attribute and puts the value provided
           into the value of the target CIMValue. This function sets the
           CIMValue to nonNull also. The result is a complete CIMValue object
           @param x Typed value (ex. Boolean(true).
           @return void
           <pre>
               CIMValue x;
               x.set(Uint16(9));
           </pre>
       */
     void set(Boolean x);     void set(Boolean x);
  
     /// CIMMethod Set      /// Set
     void set(Uint8 x);     void set(Uint8 x);
       ///
     void set(Sint8 x);     void set(Sint8 x);
       ///
     void set(Uint16 x);     void set(Uint16 x);
       ///
     void set(Sint16 x);     void set(Sint16 x);
       ///
     void set(Uint32 x);     void set(Uint32 x);
       ///
     void set(Sint32 x);     void set(Sint32 x);
       ///
     void set(Uint64 x);     void set(Uint64 x);
       ///
     void set(Sint64 x);     void set(Sint64 x);
       ///
     void set(Real32 x);     void set(Real32 x);
       ///
     void set(Real64 x);     void set(Real64 x);
       ///
     void set(const Char16& x);     void set(const Char16& x);
       ///
     void set(const String& x);     void set(const String& x);
       ///
     void set(const char* x);  
   
     void set(const CIMDateTime& x);     void set(const CIMDateTime& x);
       ///
     void set(const CIMReference& x);      void set(const CIMObjectPath& x);
       ///
     void set(const Array<Boolean>& x);     void set(const Array<Boolean>& x);
       ///
     void set(const Array<Uint8>& x);     void set(const Array<Uint8>& x);
       ///
     void set(const Array<Sint8>& x);     void set(const Array<Sint8>& x);
       ///
     void set(const Array<Uint16>& x);     void set(const Array<Uint16>& x);
       ///
     void set(const Array<Sint16>& x);     void set(const Array<Sint16>& x);
       ///
     void set(const Array<Uint32>& x);     void set(const Array<Uint32>& x);
       ///
     void set(const Array<Sint32>& x);     void set(const Array<Sint32>& x);
       ///
     void set(const Array<Uint64>& x);     void set(const Array<Uint64>& x);
       ///
     void set(const Array<Sint64>& x);     void set(const Array<Sint64>& x);
       ///
     void set(const Array<Real32>& x);     void set(const Array<Real32>& x);
       ///
     void set(const Array<Real64>& x);     void set(const Array<Real64>& x);
       ///
     void set(const Array<Char16>& x);     void set(const Array<Char16>& x);
       ///
     void set(const Array<String>& x);     void set(const Array<String>& x);
       ///
     void set(const Array<CIMDateTime>& x);     void set(const Array<CIMDateTime>& x);
       ///
       void set(const Array<CIMObjectPath>& x);
  
     /// CIMMethod get - ATTN      /** get - Gets the value of a CIMValue
     void get(Boolean& x) const;  
  
           Note: Before using get, the caller should use getType () and isNull ()
           to ensure that the value is not null, and is of the correct type.
           If the CIMValue is null, the output parameter is not updated.
   
           @param Variable in which we return the value
   
           @exception TypeMismatchException If the CIMValue type is not compatible
                      with the type of the output parameter
                   <pre>
                   Uint32 v;
                   CIMValue value(CIMValue::UINT32, UINT32(99));
                   value.get(v);
                   </pre>
   
           <pre>
           Uint32 v;
           CIMValue value = property.getValue ();
           if ((value.getType () == CIMTYPE_UINT32) && (!value.isNull ()))
               value.get (v);
           </pre>
       */
       void get(Boolean& x) const;
       ///
     void get(Uint8& x) const;     void get(Uint8& x) const;
       ///
     void get(Sint8& x) const;     void get(Sint8& x) const;
       ///
     void get(Uint16& x) const;     void get(Uint16& x) const;
       ///
     void get(Sint16& x) const;     void get(Sint16& x) const;
       ///
     void get(Uint32& x) const;     void get(Uint32& x) const;
       ///
     void get(Sint32& x) const;     void get(Sint32& x) const;
       ///
     void get(Uint64& x) const;     void get(Uint64& x) const;
       ///
     void get(Sint64& x) const;     void get(Sint64& x) const;
       ///
     void get(Real32& x) const;     void get(Real32& x) const;
       ///
     void get(Real64& x) const;     void get(Real64& x) const;
       ///
     void get(Char16& x) const;     void get(Char16& x) const;
       ///
     void get(String& x) const;     void get(String& x) const;
       ///
     void get(CIMDateTime& x) const;     void get(CIMDateTime& x) const;
       ///
     void get(CIMReference& x) const;      void get(CIMObjectPath& x) const;
       ///
     void get(Array<Boolean>& x) const;     void get(Array<Boolean>& x) const;
       ///
     void get(Array<Uint8>& x) const;     void get(Array<Uint8>& x) const;
       //////
     void get(Array<Sint8>& x) const;     void get(Array<Sint8>& x) const;
       ///
     void get(Array<Uint16>& x) const;     void get(Array<Uint16>& x) const;
       ///
     void get(Array<Sint16>& x) const;     void get(Array<Sint16>& x) const;
       ///
     void get(Array<Uint32>& x) const;     void get(Array<Uint32>& x) const;
       ///
     void get(Array<Sint32>& x) const;     void get(Array<Sint32>& x) const;
       ///
     void get(Array<Uint64>& x) const;     void get(Array<Uint64>& x) const;
       ///
     void get(Array<Sint64>& x) const;     void get(Array<Sint64>& x) const;
       ///
     void get(Array<Real32>& x) const;     void get(Array<Real32>& x) const;
       ///
     void get(Array<Real64>& x) const;     void get(Array<Real64>& x) const;
       ///
     void get(Array<Char16>& x) const;     void get(Array<Char16>& x) const;
       ///
     void get(Array<String>& x) const;     void get(Array<String>& x) const;
       ///
     void get(Array<CIMDateTime>& x) const;     void get(Array<CIMDateTime>& x) const;
       ///
       void get(Array<CIMObjectPath>& x) const;
  
     /// CIMMethod toXML  - ATTN      /** Compare with another CIMValue object for equality.
     void toXml(Array<Sint8>& out) const;          @param x - CIMValue to compare with
           @return True if they are identical in type, attribute and value.
     /// CIMMethod print - ATTN      */
     void print() const;      Boolean equal(const CIMValue& x) const;
  
     /// CIMMethod toString      - ATTN      /** toString - Converts the CIMvalue to a string.  Should only be
               used for output purposes.  To get an actual String value, use
               get(String &).
           @return - String output for CIMValue.
           <PRE>
           Example:
               String test;
               CIMValue value(Boolean(true));
               test = value.toString();  // puts "TRUE" into test
           </PRE>
           */
     String toString() const;     String toString() const;
  
 private: private:
  
     void _init();      // ATTN-RK-P2-20020719: For debugging only; remove before API release.
       // Use CIMValue(const String&) instead.
       PEGASUS_EXPLICIT CIMValue(const char* x) {}
  
     CIMType _type;      CIMValueRep* _rep;
     Boolean _isArray;  
     Union _u;  
  
     friend class CIMMethodRep;     friend class CIMMethodRep;
     friend class CIMParameterRep;     friend class CIMParameterRep;
     friend class CIMPropertyRep;     friend class CIMPropertyRep;
     friend class CIMQualifierRep;     friend class CIMQualifierRep;
     friend class CIMQualifierDeclRep;     friend class CIMQualifierDeclRep;
     PEGASUS_COMMON_LINKAGE friend Boolean operator==(  
         const CIMValue& x,  
         const CIMValue& y);  
 }; };
  
   /** operator == compares two CIMValue objects for equality.
           @param x - First CIMValue to compare
           @param y - Second CIMValue to compare
           @return True if they are identical in type, attribute and value.
   */
 PEGASUS_COMMON_LINKAGE Boolean operator==(const CIMValue& x, const CIMValue& y); PEGASUS_COMMON_LINKAGE Boolean operator==(const CIMValue& x, const CIMValue& y);
  
 inline Boolean operator!=(const CIMValue& x, const CIMValue& y)  /** operator != compares two CIMValue objects for inequality
 {  */
     return !operator==(x, y);  PEGASUS_COMMON_LINKAGE Boolean operator!=(const CIMValue& x, const CIMValue& y);
 }  
   #define PEGASUS_ARRAY_T CIMValue
   # include <Pegasus/Common/ArrayInter.h>
   #undef PEGASUS_ARRAY_T
  
 PEGASUS_NAMESPACE_END PEGASUS_NAMESPACE_END
  


Legend:
Removed from v.1.2  
changed lines
  Added in v.1.32

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2