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

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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2