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

  1 mike  1.11 //%/////////////////////////////////////////////////////////////////////////////
  2            //
  3            // Copyright (c) 2000, 2001 The Open group, BMC Software, Tivoli Systems, IBM
  4            //
  5            // Permission is hereby granted, free of charge, to any person obtaining a copy
  6            // of this software and associated documentation files (the "Software"), to 
  7            // deal in the Software without restriction, including without limitation the 
  8            // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 
  9            // sell copies of the Software, and to permit persons to whom the Software is
 10            // furnished to do so, subject to the following conditions:
 11            // 
 12            // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN 
 13            // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
 14            // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
 15            // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 
 16            // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 
 17            // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 
 18            // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 19            // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 20            //
 21            //==============================================================================
 22 mike  1.11 //
 23            // Author: Mike Brasher (mbrasher@bmc.com)
 24            //
 25 karl  1.13 // Modified By: Karl schopmeyer (k.schopmeyer@opengroup.org)
 26 kumpf 1.14 //              Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com)
 27 mike  1.11 //
 28            //%/////////////////////////////////////////////////////////////////////////////
 29            
 30            #ifndef Pegasus_Value_h
 31            #define Pegasus_Value_h
 32            
 33            #include <Pegasus/Common/String.h>
 34            #include <Pegasus/Common/Config.h>
 35            #include <Pegasus/Common/CIMType.h>
 36 kumpf 1.18 #include <Pegasus/Common/CIMReference.h>
 37 mike  1.11 #include <Pegasus/Common/CIMDateTime.h>
 38 kumpf 1.18 #include <Pegasus/Common/Exception.h>
 39 mike  1.11 #include <Pegasus/Common/Array.h>
 40            
 41            PEGASUS_NAMESPACE_BEGIN
 42            
 43 kumpf 1.18 class CIMValueRep;
 44            
 45 mike  1.11 /**
 46                The CIMValue class represents a value of any of the CIM data types
 47                (see CIMType.h for a list of valid CIM data types). This class
 48                encapsulates a union which holds the current value. The class also
 49                has a type field indicating the type of that value.
 50            */
 51            class PEGASUS_COMMON_LINKAGE CIMValue
 52            {
 53            public:
 54 kumpf 1.18     /** Constructor with no value. This constructor creates an NULL CIMValue
 55 karl  1.15         object set to null and with type CIMType:none and !arraytype.
 56                */
 57 mike  1.11     CIMValue();
 58            
 59 karl  1.15     /** Constructor with only the Type. This constructor creates a NULL CIMValue
 60                    object with the array indicator set as shown and with the
 61                */
 62                CIMValue(CIMType type, Boolean isArray, Uint32 arraySize = 0);
 63            
 64 kumpf 1.18     /** Constructor with the Value constructor and a value.  This constructs a
 65 karl  1.15         CIMValue object with the type defined by the value constructor and the value
 66                    installed
 67                    <pre>
 68                    ATTN: Add example
 69                    </pre> 
 70                */
 71 kumpf 1.18     CIMValue(Boolean x);
 72 mike  1.11 
 73 kumpf 1.18     /// Constructor
 74                CIMValue(Uint8 x);
 75 mike  1.11 
 76 kumpf 1.18     /// Constructor
 77                CIMValue(Sint8 x);
 78 mike  1.11 
 79 kumpf 1.18     /// Constructor
 80                CIMValue(Uint16 x);
 81 mike  1.11 
 82 kumpf 1.18     /// Constructor
 83                CIMValue(Sint16 x);
 84 mike  1.11 
 85 kumpf 1.18     /// Constructor
 86                CIMValue(Uint32 x);
 87 mike  1.11 
 88 kumpf 1.18     /// Constructor
 89                CIMValue(Sint32 x);
 90 mike  1.11 
 91 kumpf 1.18     /// Constructor
 92                CIMValue(Uint64 x);
 93 mike  1.11 
 94 kumpf 1.18     /// Constructor
 95                CIMValue(Sint64 x);
 96 mike  1.11 
 97 kumpf 1.18     /// Constructor
 98                CIMValue(Real32 x);
 99 mike  1.11 
100 kumpf 1.18     /// Constructor
101                CIMValue(Real64 x);
102 mike  1.11 
103 kumpf 1.18     /// Constructor
104                CIMValue(const Char16& x);
105 mike  1.11 
106 kumpf 1.18     /// Constructor
107                CIMValue(const String& x);
108 mike  1.11 
109 kumpf 1.18     /// Constructor
110                CIMValue(const char* x);
111 mike  1.11 
112 kumpf 1.18     /// Constructor
113                CIMValue(const CIMDateTime& x);
114 mike  1.11 
115 kumpf 1.18     /// Constructor
116                CIMValue(const CIMReference& x);
117 mike  1.11 
118 kumpf 1.18     /// Constructor
119                CIMValue(const Array<Boolean>& x);
120 mike  1.11 
121 kumpf 1.18     /// Constructor
122                CIMValue(const Array<Uint8>& x);
123 mike  1.11 
124 kumpf 1.18     /// Constructor
125                CIMValue(const Array<Sint8>& x);
126 mike  1.11 
127 kumpf 1.18     /// Constructor
128                CIMValue(const Array<Uint16>& x);
129 mike  1.11 
130 kumpf 1.18     /// Constructor
131                CIMValue(const Array<Sint16>& x);
132 mike  1.11 
133 kumpf 1.18     /// Constructor
134                CIMValue(const Array<Uint32>& x);
135 mike  1.11 
136 kumpf 1.18     /// Constructor
137                CIMValue(const Array<Sint32>& x);
138 mike  1.11 
139 kumpf 1.18     /// Constructor
140                CIMValue(const Array<Uint64>& x);
141 mike  1.11 
142 kumpf 1.18     /// Constructor
143                CIMValue(const Array<Sint64>& x);
144 mike  1.11 
145 kumpf 1.18     /// Constructor
146                CIMValue(const Array<Real32>& x);
147 mike  1.11 
148 kumpf 1.18     /// Constructor
149                CIMValue(const Array<Real64>& x);
150 mike  1.11 
151 kumpf 1.18     /// Constructor
152                CIMValue(const Array<Char16>& x);
153 mike  1.11 
154 kumpf 1.18     /// Constructor
155                CIMValue(const Array<String>& x);
156 mike  1.11 
157 kumpf 1.18     /// Constructor
158                CIMValue(const Array<CIMDateTime>& x);
159 mike  1.11 
160 kumpf 1.18     /// Constructor
161                CIMValue(const Array<CIMReference>& x);
162 kumpf 1.14 
163 kumpf 1.18     /// Constructor
164 mike  1.11     CIMValue(const CIMValue& x);
165            
166 kumpf 1.18     /// Destructor
167 mike  1.11     ~CIMValue();
168            
169                /// Operator =
170 kumpf 1.18     CIMValue& operator=(const CIMValue& x);
171 mike  1.11 
172 karl  1.13     /** assign - The method to assign one CIMValue object to another CIMValue
173                object.
174                */
175 mike  1.11     void assign(const CIMValue& x);
176            
177 karl  1.13     /** clear - Clears the attributes and value of the CIMValue object.
178                <pre>
179                ATTNDOC:
180                </pre>
181                */
182 mike  1.11     void clear();
183            
184 karl  1.13     /** typeCompatible - Compares the types of two CIMvalues. This
185                    compares the type field and the array indicators.
186 kumpf 1.18         @return true if both are of the same type and both are either arrays
187 karl  1.13         or not. Else returns false.
188                    <pre>
189                        CIMValue a(Boolean(true);
190                        CIMValue b = a;
191                        if b.typeCompatible(a)
192                            ...
193                    </pre>
194 mike  1.11     */
195 kumpf 1.18     Boolean typeCompatible(const CIMValue& x) const;
196 mike  1.11 
197 karl  1.13     /** isArray - Determines if the value is an array
198 kumpf 1.18         @return TRUE if the value is an array
199 mike  1.11     */
200 kumpf 1.18     Boolean isArray() const;
201 mike  1.11 
202 karl  1.13     /** Returns whether the CIMvalue object is Null. 
203 kumpf 1.18         Null is the specific condition where no value has
204                    yet been set into the value.
205                    If a CIMValue object is Null, any get on that object
206                    will create an exception.
207                    @return Returns True if the CIMValue object is Null
208 mike  1.12     */
209 kumpf 1.18     Boolean isNull() const;
210 mike  1.12 
211 karl  1.13     /** getArraySize = Returns the size of an Array CIMValue
212 kumpf 1.18         @return The number of entries in the array
213 mike  1.11     */
214                Uint32 getArraySize() const;
215            
216 karl  1.13     /** getType - Gets the CIMType attribute for the CIMValue.
217                    The CIMType is defined in ATTN:
218                    @return Returns the CIMType value
219                */
220 kumpf 1.18     CIMType getType() const;
221 mike  1.11 
222 kumpf 1.18     /** setNullValue - Sets the CIMType, the Array indicator and if it is
223 karl  1.13         the arraytype, the Arraysize of a CIMValue and sets the isNull
224                    Attribute.  This function is used to set up CIMValues an NULL but
225                    with valid CIMType and array characteristics (ex. when update from
226                    XML)
227                    @param type - The CIMType for this CIMValue
228 kumpf 1.18         @param isArray - Boolean indicating whether this is an array CIMValue
229                    @param arraySize (optional) Uint32 parameter indicating the array
230 karl  1.13         size
231                    @return void
232 karl  1.15         <pre>
233                        CIMValue value;                   // Create a CIMValue object
234                        value.setNullValue(CIMType::BOOLEAN, false);  // Set it       
235                    </pre>
236 karl  1.13     */
237 mike  1.11     void setNullValue(CIMType type, Boolean isArray, Uint32 arraySize = 0);
238            
239 karl  1.13     /** set - Sets the type, Array attribute and puts the value provided
240                    into the value of the target CIMValue. This function sets the
241 karl  1.15         CIMValue to nonNull also. The result is a complete CIMValue object
242 karl  1.13         All of the CIMTypes defined in ATTN: and the Array types defined in
243                    ATTN: may be set.
244                    @param x Typed value (ex. Boolean(true).
245                    @return void
246                    <pre>
247                        CIMValue x;
248                        x.set(Uint16(9));
249                    </pre>
250                */    
251 mike  1.11     void set(Boolean x);
252            
253 karl  1.13     /// Set
254 mike  1.11     void set(Uint8 x);
255 karl  1.13     ///
256 mike  1.11     void set(Sint8 x);
257 karl  1.13     ///
258 mike  1.11     void set(Uint16 x);
259 karl  1.13     ///
260 mike  1.11     void set(Sint16 x);
261 karl  1.13     ///
262 mike  1.11     void set(Uint32 x);
263 karl  1.13     ///
264 mike  1.11     void set(Sint32 x);
265 karl  1.13     ///
266 mike  1.11     void set(Uint64 x);
267 karl  1.13     ///
268 mike  1.11     void set(Sint64 x);
269 karl  1.13     ///
270 mike  1.11     void set(Real32 x);
271 karl  1.13     ///
272 mike  1.11     void set(Real64 x);
273 karl  1.13     ///
274 mike  1.11     void set(const Char16& x);
275 karl  1.13     ///
276 mike  1.11     void set(const String& x);
277 karl  1.13     ///
278 mike  1.11     void set(const char* x);
279 karl  1.13     ///
280 mike  1.11     void set(const CIMDateTime& x);
281 karl  1.13     ///
282 mike  1.11     void set(const CIMReference& x);
283 karl  1.13     ///
284 mike  1.11     void set(const Array<Boolean>& x);
285 karl  1.13     ///
286 mike  1.11     void set(const Array<Uint8>& x);
287 karl  1.13     ///
288 mike  1.11     void set(const Array<Sint8>& x);
289 karl  1.13     ///
290 mike  1.11     void set(const Array<Uint16>& x);
291 karl  1.13     ///
292 mike  1.11     void set(const Array<Sint16>& x);
293 karl  1.13     ///
294 mike  1.11     void set(const Array<Uint32>& x);
295 karl  1.13     ///
296 mike  1.11     void set(const Array<Sint32>& x);
297 karl  1.13     ///
298 mike  1.11     void set(const Array<Uint64>& x);
299 karl  1.13     ///
300 mike  1.11     void set(const Array<Sint64>& x);
301 karl  1.13     ///
302 mike  1.11     void set(const Array<Real32>& x);
303 karl  1.13     ///
304 mike  1.11     void set(const Array<Real64>& x);
305 karl  1.13     ///
306 mike  1.11     void set(const Array<Char16>& x);
307 karl  1.13     ///
308 mike  1.11     void set(const Array<String>& x);
309 karl  1.13     ///
310 mike  1.11     void set(const Array<CIMDateTime>& x);
311 kumpf 1.14     ///
312                void set(const Array<CIMReference>& x);
313 mike  1.11 
314 karl  1.13     /** get - Gets the value of a CIMValue
315 karl  1.17         @param Variable in which we return the value:
316                    @return void
317 kumpf 1.18                 <pre>
318                            Uint32 v;
319                            CIMValue value(CIMValue::UINT32, UINT32(99));
320                            value.get(v);
321                            </pre>
322 karl  1.13     */
323 mike  1.11     void get(Boolean& x) const;
324 karl  1.13     ///
325 mike  1.11     void get(Uint8& x) const;
326 karl  1.13     ///
327 mike  1.11     void get(Sint8& x) const;
328 karl  1.13     ///
329 mike  1.11     void get(Uint16& x) const;
330 karl  1.13     ///
331 mike  1.11     void get(Sint16& x) const;
332 karl  1.13     ///
333 mike  1.11     void get(Uint32& x) const;
334 karl  1.13     ///
335 mike  1.11     void get(Sint32& x) const;
336 karl  1.13     ///
337 mike  1.11     void get(Uint64& x) const;
338 karl  1.13     ///
339 mike  1.11     void get(Sint64& x) const;
340 karl  1.13     ///
341 mike  1.11     void get(Real32& x) const;
342 karl  1.13     ///
343 mike  1.11     void get(Real64& x) const;
344 karl  1.13     ///
345 mike  1.11     void get(Char16& x) const;
346 karl  1.13     ///
347 mike  1.11     void get(String& x) const;
348 karl  1.13     ///
349 mike  1.11     void get(CIMDateTime& x) const;
350 karl  1.13     ///
351 mike  1.11     void get(CIMReference& x) const;
352 karl  1.13     ///
353 mike  1.11     void get(Array<Boolean>& x) const;
354 karl  1.13     ///
355 mike  1.11     void get(Array<Uint8>& x) const;
356 karl  1.13     //////
357 mike  1.11     void get(Array<Sint8>& x) const;
358 karl  1.13     ///
359 mike  1.11     void get(Array<Uint16>& x) const;
360 karl  1.13     ///
361 mike  1.11     void get(Array<Sint16>& x) const;
362 karl  1.13     ///
363 mike  1.11     void get(Array<Uint32>& x) const;
364 karl  1.13     ///
365 mike  1.11     void get(Array<Sint32>& x) const;
366 karl  1.13     ///
367 mike  1.11     void get(Array<Uint64>& x) const;
368 karl  1.13     ///
369 mike  1.11     void get(Array<Sint64>& x) const;
370 karl  1.13     ///
371 mike  1.11     void get(Array<Real32>& x) const;
372 karl  1.13     ///
373 mike  1.11     void get(Array<Real64>& x) const;
374 karl  1.13     ///
375 mike  1.11     void get(Array<Char16>& x) const;
376 karl  1.13     ///
377 mike  1.11     void get(Array<String>& x) const;
378 karl  1.13     ///
379 mike  1.11     void get(Array<CIMDateTime>& x) const; 
380 kumpf 1.14     ///
381                void get(Array<CIMReference>& x) const; 
382 mike  1.11 
383 kumpf 1.20     /** Makes a deep copy (clone) of the given object. */
384                CIMValue clone() const;
385            
386 mike  1.12     /** toString - Converts the CIMvalue to a string.  Should only be
387                        used for output purposes.  To get an actual String value, use
388                        get(String &).
389 kumpf 1.18         @return - String output for CIMValue.
390 karl  1.13         @exception - Throws exception CIMValueInvalidType if the CIMValue
391                        has an invalid type. Normally this is a Pegasus internal error.
392 kumpf 1.18         <PRE>
393                    Example:
394                        String test;
395                        CIMValue value(Boolean(true));
396                        test = value.toString();  // puts "TRUE" into test
397                    </PRE>
398                    */
399 mike  1.11     String toString() const;
400            
401            private:
402            
403 kumpf 1.18     CIMValueRep* _rep;
404 mike  1.11 
405                friend class CIMMethodRep;
406                friend class CIMParameterRep;
407                friend class CIMPropertyRep;
408                friend class CIMQualifierRep;
409                friend class CIMQualifierDeclRep;
410                PEGASUS_COMMON_LINKAGE friend Boolean operator==(
411 kumpf 1.18         const CIMValue& x, 
412                    const CIMValue& y);
413 mike  1.11 };
414 kumpf 1.18 
415 karl  1.17 /** operator == compares two CIMValue objects for equality.
416 kumpf 1.18         @param x - First CIMvalue to compare
417                    @parm y - Second CIMValue to compare
418                    @return True if they are identical in type, attribute and value.
419 karl  1.17 */
420 mike  1.11 PEGASUS_COMMON_LINKAGE Boolean operator==(const CIMValue& x, const CIMValue& y);
421            
422 karl  1.17 /** operator != compares two CIMValue objects for nonequality
423            */
424 kumpf 1.18 PEGASUS_COMMON_LINKAGE Boolean operator!=(const CIMValue& x, const CIMValue& y);
425 mike  1.11 
426            #define PEGASUS_ARRAY_T CIMValue
427            # include "ArrayInter.h"
428            #undef PEGASUS_ARRAY_T
429            
430            PEGASUS_NAMESPACE_END
431            
432            #endif /* Pegasus_Value_h */

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2