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 mike 1.11 //
29 //%/////////////////////////////////////////////////////////////////////////////
30
31 #ifndef Pegasus_Value_h
32 #define Pegasus_Value_h
33
34 #include <Pegasus/Common/String.h>
35 #include <Pegasus/Common/Config.h>
36 #include <Pegasus/Common/CIMType.h>
|
37 kumpf 1.23 #include <Pegasus/Common/CIMObjectPath.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
42 PEGASUS_NAMESPACE_BEGIN
43
|
44 kumpf 1.18 class CIMValueRep;
45
|
46 mike 1.11 /**
47 The CIMValue class represents a value of any of the CIM data types
48 (see CIMType.h for a list of valid CIM data types). This class
49 encapsulates a union which holds the current value. The class also
50 has a type field indicating the type of that value.
51 */
52 class PEGASUS_COMMON_LINKAGE CIMValue
53 {
54 public:
|
55 kumpf 1.18 /** Constructor with no value. This constructor creates an NULL CIMValue
|
56 karl 1.15 object set to null and with type CIMType:none and !arraytype.
57 */
|
58 mike 1.11 CIMValue();
59
|
60 karl 1.15 /** Constructor with only the Type. This constructor creates a NULL CIMValue
61 object with the array indicator set as shown and with the
62 */
63 CIMValue(CIMType type, Boolean isArray, Uint32 arraySize = 0);
64
|
65 kumpf 1.26 // ATTN This needs an example
66 /** Constructor with the Value constructor and a value.
67 This constructs a
68 CIMValue object with the type defined by the value constructor
69 and the value
|
70 karl 1.15 installed
71 */
|
72 kumpf 1.18 CIMValue(Boolean x);
|
73 mike 1.11
|
74 kumpf 1.18 /// Constructor
75 CIMValue(Uint8 x);
|
76 mike 1.11
|
77 kumpf 1.18 /// Constructor
78 CIMValue(Sint8 x);
|
79 mike 1.11
|
80 kumpf 1.18 /// Constructor
81 CIMValue(Uint16 x);
|
82 mike 1.11
|
83 kumpf 1.18 /// Constructor
84 CIMValue(Sint16 x);
|
85 mike 1.11
|
86 kumpf 1.18 /// Constructor
87 CIMValue(Uint32 x);
|
88 mike 1.11
|
89 kumpf 1.18 /// Constructor
90 CIMValue(Sint32 x);
|
91 mike 1.11
|
92 kumpf 1.18 /// Constructor
93 CIMValue(Uint64 x);
|
94 mike 1.11
|
95 kumpf 1.18 /// Constructor
96 CIMValue(Sint64 x);
|
97 mike 1.11
|
98 kumpf 1.18 /// Constructor
99 CIMValue(Real32 x);
|
100 mike 1.11
|
101 kumpf 1.18 /// Constructor
102 CIMValue(Real64 x);
|
103 mike 1.11
|
104 kumpf 1.18 /// Constructor
105 CIMValue(const Char16& x);
|
106 mike 1.11
|
107 kumpf 1.18 /// Constructor
108 CIMValue(const String& x);
|
109 mike 1.11
|
110 kumpf 1.18 /// Constructor
111 CIMValue(const CIMDateTime& x);
|
112 mike 1.11
|
113 kumpf 1.18 /// Constructor
|
114 kumpf 1.23 CIMValue(const CIMObjectPath& x);
|
115 mike 1.11
|
116 kumpf 1.18 /// Constructor
117 CIMValue(const Array<Boolean>& x);
|
118 mike 1.11
|
119 kumpf 1.18 /// Constructor
120 CIMValue(const Array<Uint8>& x);
|
121 mike 1.11
|
122 kumpf 1.18 /// Constructor
123 CIMValue(const Array<Sint8>& x);
|
124 mike 1.11
|
125 kumpf 1.18 /// Constructor
126 CIMValue(const Array<Uint16>& x);
|
127 mike 1.11
|
128 kumpf 1.18 /// Constructor
129 CIMValue(const Array<Sint16>& x);
|
130 mike 1.11
|
131 kumpf 1.18 /// Constructor
132 CIMValue(const Array<Uint32>& x);
|
133 mike 1.11
|
134 kumpf 1.18 /// Constructor
135 CIMValue(const Array<Sint32>& x);
|
136 mike 1.11
|
137 kumpf 1.18 /// Constructor
138 CIMValue(const Array<Uint64>& x);
|
139 mike 1.11
|
140 kumpf 1.18 /// Constructor
141 CIMValue(const Array<Sint64>& x);
|
142 mike 1.11
|
143 kumpf 1.18 /// Constructor
144 CIMValue(const Array<Real32>& x);
|
145 mike 1.11
|
146 kumpf 1.18 /// Constructor
147 CIMValue(const Array<Real64>& x);
|
148 mike 1.11
|
149 kumpf 1.18 /// Constructor
150 CIMValue(const Array<Char16>& x);
|
151 mike 1.11
|
152 kumpf 1.18 /// Constructor
153 CIMValue(const Array<String>& x);
|
154 mike 1.11
|
155 kumpf 1.18 /// Constructor
156 CIMValue(const Array<CIMDateTime>& x);
|
157 mike 1.11
|
158 kumpf 1.18 /// Constructor
|
159 kumpf 1.23 CIMValue(const Array<CIMObjectPath>& x);
|
160 kumpf 1.14
|
161 kumpf 1.18 /// Constructor
|
162 mike 1.11 CIMValue(const CIMValue& x);
163
|
164 kumpf 1.18 /// Destructor
|
165 mike 1.11 ~CIMValue();
166
167 /// Operator =
|
168 kumpf 1.18 CIMValue& operator=(const CIMValue& x);
|
169 mike 1.11
|
170 karl 1.13 /** assign - The method to assign one CIMValue object to another CIMValue
171 object.
172 */
|
173 mike 1.11 void assign(const CIMValue& x);
174
|
175 karl 1.13 /** clear - Clears the attributes and value of the CIMValue object.
176 */
|
177 mike 1.11 void clear();
178
|
179 kumpf 1.27 /** typeCompatible - Compares the types of two CIMValues. This
|
180 karl 1.13 compares the type field and the array indicators.
|
181 kumpf 1.18 @return true if both are of the same type and both are either arrays
|
182 karl 1.13 or not. Else returns false.
183 <pre>
184 CIMValue a(Boolean(true);
185 CIMValue b = a;
186 if b.typeCompatible(a)
187 ...
188 </pre>
|
189 mike 1.11 */
|
190 kumpf 1.18 Boolean typeCompatible(const CIMValue& x) const;
|
191 mike 1.11
|
192 karl 1.13 /** isArray - Determines if the value is an array
|
193 kumpf 1.18 @return TRUE if the value is an array
|
194 mike 1.11 */
|
195 kumpf 1.18 Boolean isArray() const;
|
196 mike 1.11
|
197 karl 1.13 /** Returns whether the CIMvalue object is Null.
|
198 kumpf 1.18 Null is the specific condition where no value has
199 yet been set into the value.
200 If a CIMValue object is Null, any get on that object
201 will create an exception.
202 @return Returns True if the CIMValue object is Null
|
203 mike 1.12 */
|
204 kumpf 1.18 Boolean isNull() const;
|
205 mike 1.12
|
206 karl 1.13 /** getArraySize = Returns the size of an Array CIMValue
|
207 kumpf 1.18 @return The number of entries in the array
|
208 mike 1.11 */
209 Uint32 getArraySize() const;
210
|
211 karl 1.13 /** getType - Gets the CIMType attribute for the CIMValue.
|
212 kumpf 1.26 @return the CIMType value
|
213 karl 1.13 */
|
214 kumpf 1.18 CIMType getType() const;
|
215 mike 1.11
|
216 kumpf 1.18 /** setNullValue - Sets the CIMType, the Array indicator and if it is
|
217 karl 1.13 the arraytype, the Arraysize of a CIMValue and sets the isNull
218 Attribute. This function is used to set up CIMValues an NULL but
219 with valid CIMType and array characteristics (ex. when update from
220 XML)
221 @param type - The CIMType for this CIMValue
|
222 kumpf 1.18 @param isArray - Boolean indicating whether this is an array CIMValue
223 @param arraySize (optional) Uint32 parameter indicating the array
|
224 karl 1.13 size
225 @return void
|
226 karl 1.15 <pre>
227 CIMValue value; // Create a CIMValue object
228 value.setNullValue(CIMType::BOOLEAN, false); // Set it
229 </pre>
|
230 karl 1.13 */
|
231 mike 1.11 void setNullValue(CIMType type, Boolean isArray, Uint32 arraySize = 0);
232
|
233 kumpf 1.26 // All of the CIMTypes defined in ATTN: and the Array types defined in
234 // ATTN: may be set.
|
235 karl 1.13 /** set - Sets the type, Array attribute and puts the value provided
236 into the value of the target CIMValue. This function sets the
|
237 karl 1.15 CIMValue to nonNull also. The result is a complete CIMValue object
|
238 karl 1.13 @param x Typed value (ex. Boolean(true).
239 @return void
240 <pre>
241 CIMValue x;
242 x.set(Uint16(9));
243 </pre>
244 */
|
245 mike 1.11 void set(Boolean x);
246
|
247 karl 1.13 /// Set
|
248 mike 1.11 void set(Uint8 x);
|
249 karl 1.13 ///
|
250 mike 1.11 void set(Sint8 x);
|
251 karl 1.13 ///
|
252 mike 1.11 void set(Uint16 x);
|
253 karl 1.13 ///
|
254 mike 1.11 void set(Sint16 x);
|
255 karl 1.13 ///
|
256 mike 1.11 void set(Uint32 x);
|
257 karl 1.13 ///
|
258 mike 1.11 void set(Sint32 x);
|
259 karl 1.13 ///
|
260 mike 1.11 void set(Uint64 x);
|
261 karl 1.13 ///
|
262 mike 1.11 void set(Sint64 x);
|
263 karl 1.13 ///
|
264 mike 1.11 void set(Real32 x);
|
265 karl 1.13 ///
|
266 mike 1.11 void set(Real64 x);
|
267 karl 1.13 ///
|
268 mike 1.11 void set(const Char16& x);
|
269 karl 1.13 ///
|
270 mike 1.11 void set(const String& x);
|
271 karl 1.13 ///
|
272 mike 1.11 void set(const CIMDateTime& x);
|
273 karl 1.13 ///
|
274 kumpf 1.23 void set(const CIMObjectPath& x);
|
275 karl 1.13 ///
|
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 mike 1.11
|
306 karl 1.13 /** get - Gets the value of a CIMValue
|
307 karl 1.17 @param Variable in which we return the value:
308 @return void
|
309 kumpf 1.18 <pre>
310 Uint32 v;
311 CIMValue value(CIMValue::UINT32, UINT32(99));
312 value.get(v);
313 </pre>
|
314 karl 1.13 */
|
315 mike 1.11 void get(Boolean& x) const;
|
316 karl 1.13 ///
|
317 mike 1.11 void get(Uint8& x) const;
|
318 karl 1.13 ///
|
319 mike 1.11 void get(Sint8& x) const;
|
320 karl 1.13 ///
|
321 mike 1.11 void get(Uint16& x) const;
|
322 karl 1.13 ///
|
323 mike 1.11 void get(Sint16& x) const;
|
324 karl 1.13 ///
|
325 mike 1.11 void get(Uint32& x) const;
|
326 karl 1.13 ///
|
327 mike 1.11 void get(Sint32& x) const;
|
328 karl 1.13 ///
|
329 mike 1.11 void get(Uint64& x) const;
|
330 karl 1.13 ///
|
331 mike 1.11 void get(Sint64& x) const;
|
332 karl 1.13 ///
|
333 mike 1.11 void get(Real32& x) const;
|
334 karl 1.13 ///
|
335 mike 1.11 void get(Real64& x) const;
|
336 karl 1.13 ///
|
337 mike 1.11 void get(Char16& x) const;
|
338 karl 1.13 ///
|
339 mike 1.11 void get(String& x) const;
|
340 karl 1.13 ///
|
341 mike 1.11 void get(CIMDateTime& x) const;
|
342 karl 1.13 ///
|
343 kumpf 1.23 void get(CIMObjectPath& x) const;
|
344 karl 1.13 ///
|
345 mike 1.11 void get(Array<Boolean>& x) const;
|
346 karl 1.13 ///
|
347 mike 1.11 void get(Array<Uint8>& x) const;
|
348 karl 1.13 //////
|
349 mike 1.11 void get(Array<Sint8>& x) const;
|
350 karl 1.13 ///
|
351 mike 1.11 void get(Array<Uint16>& x) const;
|
352 karl 1.13 ///
|
353 mike 1.11 void get(Array<Sint16>& x) const;
|
354 karl 1.13 ///
|
355 mike 1.11 void get(Array<Uint32>& x) const;
|
356 karl 1.13 ///
|
357 mike 1.11 void get(Array<Sint32>& x) const;
|
358 karl 1.13 ///
|
359 mike 1.11 void get(Array<Uint64>& x) const;
|
360 karl 1.13 ///
|
361 mike 1.11 void get(Array<Sint64>& x) const;
|
362 karl 1.13 ///
|
363 mike 1.11 void get(Array<Real32>& x) const;
|
364 karl 1.13 ///
|
365 mike 1.11 void get(Array<Real64>& x) const;
|
366 karl 1.13 ///
|
367 mike 1.11 void get(Array<Char16>& x) const;
|
368 karl 1.13 ///
|
369 mike 1.11 void get(Array<String>& x) const;
|
370 karl 1.13 ///
|
371 mike 1.11 void get(Array<CIMDateTime>& x) const;
|
372 kumpf 1.14 ///
|
373 kumpf 1.23 void get(Array<CIMObjectPath>& x) const;
|
374 mike 1.11
|
375 kumpf 1.27 /** Compare with another CIMValue object for equality.
376 @param x - CIMValue to compare with
377 @return True if they are identical in type, attribute and value.
378 */
379 Boolean equal(const CIMValue& x) const;
|
380 kumpf 1.20
|
381 mike 1.12 /** toString - Converts the CIMvalue to a string. Should only be
382 used for output purposes. To get an actual String value, use
383 get(String &).
|
384 kumpf 1.18 @return - String output for CIMValue.
|
385 karl 1.13 @exception - Throws exception CIMValueInvalidType if the CIMValue
386 has an invalid type. Normally this is a Pegasus internal error.
|
387 kumpf 1.18 <PRE>
388 Example:
389 String test;
390 CIMValue value(Boolean(true));
391 test = value.toString(); // puts "TRUE" into test
392 </PRE>
393 */
|
394 mike 1.11 String toString() const;
395
396 private:
397
|
398 kumpf 1.28 // ATTN-RK-P2-20020719: For debugging only; remove before API release.
399 // Use CIMValue(const String&) instead.
400 PEGASUS_EXPLICIT CIMValue(const char* x) {}
401
|
402 kumpf 1.18 CIMValueRep* _rep;
|
403 mike 1.11
404 friend class CIMMethodRep;
405 friend class CIMParameterRep;
406 friend class CIMPropertyRep;
407 friend class CIMQualifierRep;
408 friend class CIMQualifierDeclRep;
409 };
|
410 kumpf 1.18
|
411 karl 1.17 /** operator == compares two CIMValue objects for equality.
|
412 kumpf 1.27 @param x - First CIMValue to compare
413 @param y - Second CIMValue to compare
|
414 kumpf 1.18 @return True if they are identical in type, attribute and value.
|
415 karl 1.17 */
|
416 mike 1.11 PEGASUS_COMMON_LINKAGE Boolean operator==(const CIMValue& x, const CIMValue& y);
417
|
418 kumpf 1.27 /** operator != compares two CIMValue objects for inequality
|
419 karl 1.17 */
|
420 kumpf 1.18 PEGASUS_COMMON_LINKAGE Boolean operator!=(const CIMValue& x, const CIMValue& y);
|
421 mike 1.11
422 #define PEGASUS_ARRAY_T CIMValue
|
423 kumpf 1.24 # include <Pegasus/Common/ArrayInter.h>
|
424 mike 1.11 #undef PEGASUS_ARRAY_T
425
426 PEGASUS_NAMESPACE_END
427
428 #endif /* Pegasus_Value_h */
|