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