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

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