(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 mike  1.11 #include <Pegasus/Common/CIMDateTime.h>
 43 kumpf 1.18 #include <Pegasus/Common/Exception.h>
 44 mike  1.11 #include <Pegasus/Common/Array.h>
 45 kumpf 1.29 #include <Pegasus/Common/Linkage.h>
 46 mike  1.11 
 47            PEGASUS_NAMESPACE_BEGIN
 48            
 49 kumpf 1.18 class CIMValueRep;
 50            
 51 mike  1.11 /**
 52                The CIMValue class represents a value of any of the CIM data types
 53 kumpf 1.34     (see \Ref{CIMType} for a list of valid CIM data types). This class
 54 mike  1.11     encapsulates a union which holds the current value. The class also
 55                has a type field indicating the type of that value.
 56            */
 57            class PEGASUS_COMMON_LINKAGE CIMValue
 58            {
 59            public:
 60 kumpf 1.34     /** Constructor - Creates an NULL CIMValue object set to null and 
 61                    with type CIMType:none and !arraytype.
 62 karl  1.15     */
 63 mike  1.11     CIMValue();
 64            
 65 kumpf 1.34     /** Constructor - Creates a NULL CIMValue object with the type and
 66 kumpf 1.32         array indicator set as specified.
 67                    @exception TypeMismatchException If the given type is not valid for a
 68                    CIMValue object.
 69 karl  1.15     */
 70                CIMValue(CIMType type, Boolean isArray, Uint32 arraySize = 0);
 71            
 72 kumpf 1.34     /// Constructor.
 73 kumpf 1.18     CIMValue(Boolean x);
 74 mike  1.11 
 75 kumpf 1.34     /// Constructor.
 76 kumpf 1.18     CIMValue(Uint8 x);
 77 mike  1.11 
 78 kumpf 1.34     /// Constructor.
 79 kumpf 1.18     CIMValue(Sint8 x);
 80 mike  1.11 
 81 kumpf 1.34     /// Constructor.
 82 kumpf 1.18     CIMValue(Uint16 x);
 83 mike  1.11 
 84 kumpf 1.34     /// Constructor.
 85 kumpf 1.18     CIMValue(Sint16 x);
 86 mike  1.11 
 87 kumpf 1.34     /// Constructor.
 88 kumpf 1.18     CIMValue(Uint32 x);
 89 mike  1.11 
 90 kumpf 1.34     /// Constructor.
 91 kumpf 1.18     CIMValue(Sint32 x);
 92 mike  1.11 
 93 kumpf 1.34     /// Constructor.
 94 kumpf 1.18     CIMValue(Uint64 x);
 95 mike  1.11 
 96 kumpf 1.34     /// Constructor.
 97 kumpf 1.18     CIMValue(Sint64 x);
 98 mike  1.11 
 99 kumpf 1.34     /// Constructor.
100 kumpf 1.18     CIMValue(Real32 x);
101 mike  1.11 
102 kumpf 1.34     /// Constructor.
103 kumpf 1.18     CIMValue(Real64 x);
104 mike  1.11 
105 kumpf 1.34     /// Constructor.
106 kumpf 1.18     CIMValue(const Char16& x);
107 mike  1.11 
108 kumpf 1.34     /// Constructor.
109 kumpf 1.18     CIMValue(const String& x);
110 mike  1.11 
111 kumpf 1.34     /// Constructor.
112 kumpf 1.18     CIMValue(const CIMDateTime& x);
113 mike  1.11 
114 kumpf 1.34     /// Constructor.
115 kumpf 1.23     CIMValue(const CIMObjectPath& x);
116 mike  1.11 
117 kumpf 1.34     /// 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 mike  1.11     CIMValue(const CIMValue& x);
164            
165 kumpf 1.34     /// Destructor.
166 mike  1.11     ~CIMValue();
167            
168                /// Operator =
169 kumpf 1.18     CIMValue& operator=(const CIMValue& x);
170 mike  1.11 
171 kumpf 1.34     /** Assigns one CIMValue object to another CIMValue object.
172                    @param x - CIMValue object to be used for assignment.
173 karl  1.13     */
174 mike  1.11     void assign(const CIMValue& x);
175            
176 kumpf 1.34     /** Clears the attributes and value of the CIMValue object.
177 karl  1.13     */
178 mike  1.11     void clear();
179            
180 kumpf 1.34     /** Compares the types of two CIMValues. This
181 karl  1.13         compares the type field and the array indicators.
182 kumpf 1.18         @return true if both are of the same type and both are either arrays
183 kumpf 1.34         or not, false otherwise.
184 karl  1.13         <pre>
185                        CIMValue a(Boolean(true);
186                        CIMValue b = a;
187                        if b.typeCompatible(a)
188                            ...
189                    </pre>
190 mike  1.11     */
191 kumpf 1.18     Boolean typeCompatible(const CIMValue& x) const;
192 mike  1.11 
193 kumpf 1.34     /** Determines if the value is an array.
194                    @return true if the value is an array, false otherwise.
195 mike  1.11     */
196 kumpf 1.18     Boolean isArray() const;
197 mike  1.11 
198 kumpf 1.34     /** Determines whether the CIMvalue object is Null. 
199 kumpf 1.18         Null is the specific condition where no value has
200 kumpf 1.34         yet been set. If a CIMValue object is Null, any get on that 
201                    object will create an exception.
202                    @return true if the CIMValue object is Null, false otherwise.
203 mike  1.12     */
204 kumpf 1.18     Boolean isNull() const;
205 mike  1.12 
206 kumpf 1.34     /** Gets the size of an Array CIMValue.
207                    @return The number of entries in the array.
208 mike  1.11     */
209                Uint32 getArraySize() const;
210            
211 kumpf 1.34     /** Gets the CIMType attribute for the CIMValue.
212                    @return the CIMType value.
213 karl  1.13     */
214 kumpf 1.18     CIMType getType() const;
215 mike  1.11 
216 kumpf 1.34     /** Sets the CIMValue a NULL, but with valid CIMType and array 
217                    characteristics.
218                    @param type - CIMType for this CIMValue.
219                    @param isArray - Boolean indicating whether this is an array CIMValue.
220                    @param arraySize - Optional parameter indicating the array size.
221 karl  1.15         <pre>
222 kumpf 1.34             CIMValue value;             
223                        value.setNullValue(CIMType::BOOLEAN, false); 
224 karl  1.15         </pre>
225 karl  1.13     */
226 mike  1.11     void setNullValue(CIMType type, Boolean isArray, Uint32 arraySize = 0);
227            
228 kumpf 1.34     /** Sets the type, Array attribute and puts the value provided
229                    into the value of the target CIMValue. 
230 karl  1.13         <pre>
231                        CIMValue x;
232                        x.set(Uint16(9));
233                    </pre>
234                */    
235 mike  1.11     void set(Boolean x);
236            
237 kumpf 1.34     /// 
238 mike  1.11     void set(Uint8 x);
239 karl  1.13     ///
240 mike  1.11     void set(Sint8 x);
241 karl  1.13     ///
242 mike  1.11     void set(Uint16 x);
243 karl  1.13     ///
244 mike  1.11     void set(Sint16 x);
245 karl  1.13     ///
246 mike  1.11     void set(Uint32 x);
247 karl  1.13     ///
248 mike  1.11     void set(Sint32 x);
249 karl  1.13     ///
250 mike  1.11     void set(Uint64 x);
251 karl  1.13     ///
252 mike  1.11     void set(Sint64 x);
253 karl  1.13     ///
254 mike  1.11     void set(Real32 x);
255 karl  1.13     ///
256 mike  1.11     void set(Real64 x);
257 karl  1.13     ///
258 mike  1.11     void set(const Char16& x);
259 karl  1.13     ///
260 mike  1.11     void set(const String& x);
261 karl  1.13     ///
262 mike  1.11     void set(const CIMDateTime& x);
263 karl  1.13     ///
264 kumpf 1.23     void set(const CIMObjectPath& x);
265 karl  1.13     ///
266 mike  1.11     void set(const Array<Boolean>& x);
267 karl  1.13     ///
268 mike  1.11     void set(const Array<Uint8>& x);
269 karl  1.13     ///
270 mike  1.11     void set(const Array<Sint8>& x);
271 karl  1.13     ///
272 mike  1.11     void set(const Array<Uint16>& x);
273 karl  1.13     ///
274 mike  1.11     void set(const Array<Sint16>& x);
275 karl  1.13     ///
276 mike  1.11     void set(const Array<Uint32>& x);
277 karl  1.13     ///
278 mike  1.11     void set(const Array<Sint32>& x);
279 karl  1.13     ///
280 mike  1.11     void set(const Array<Uint64>& x);
281 karl  1.13     ///
282 mike  1.11     void set(const Array<Sint64>& x);
283 karl  1.13     ///
284 mike  1.11     void set(const Array<Real32>& x);
285 karl  1.13     ///
286 mike  1.11     void set(const Array<Real64>& x);
287 karl  1.13     ///
288 mike  1.11     void set(const Array<Char16>& x);
289 karl  1.13     ///
290 mike  1.11     void set(const Array<String>& x);
291 karl  1.13     ///
292 mike  1.11     void set(const Array<CIMDateTime>& x);
293 kumpf 1.14     ///
294 kumpf 1.23     void set(const Array<CIMObjectPath>& x);
295 mike  1.11 
296 kumpf 1.34     /** Gets the value of a CIMValue.
297 kumpf 1.31         Note: Before using get, the caller should use getType () and isNull ()
298                    to ensure that the value is not null, and is of the correct type.
299            
300 kumpf 1.34         @param Variable in which to return the value.
301 kumpf 1.31         @exception TypeMismatchException If the CIMValue type is not compatible
302 kumpf 1.34                    with the type of the output parameter.
303                    <pre>
304                        Uint32 v;
305                        CIMValue value(CIMValue::UINT32, UINT32(99));
306                        value.get(v);
307                    </pre>
308 kumpf 1.31 
309                    <pre>
310 kumpf 1.34             Uint32 v;
311                        CIMValue value = property.getValue ();
312                        if ((value.getType () == CIMTYPE_UINT32) && (!value.isNull ()))
313                            value.get (v);
314 kumpf 1.31         </pre>
315 karl  1.13     */
316 mike  1.11     void get(Boolean& x) const;
317 karl  1.13     ///
318 mike  1.11     void get(Uint8& x) const;
319 karl  1.13     ///
320 mike  1.11     void get(Sint8& x) const;
321 karl  1.13     ///
322 mike  1.11     void get(Uint16& x) const;
323 karl  1.13     ///
324 mike  1.11     void get(Sint16& x) const;
325 karl  1.13     ///
326 mike  1.11     void get(Uint32& x) const;
327 karl  1.13     ///
328 mike  1.11     void get(Sint32& x) const;
329 karl  1.13     ///
330 mike  1.11     void get(Uint64& x) const;
331 karl  1.13     ///
332 mike  1.11     void get(Sint64& x) const;
333 karl  1.13     ///
334 mike  1.11     void get(Real32& x) const;
335 karl  1.13     ///
336 mike  1.11     void get(Real64& x) const;
337 karl  1.13     ///
338 mike  1.11     void get(Char16& x) const;
339 karl  1.13     ///
340 mike  1.11     void get(String& x) const;
341 karl  1.13     ///
342 mike  1.11     void get(CIMDateTime& x) const;
343 karl  1.13     ///
344 kumpf 1.23     void get(CIMObjectPath& x) const;
345 karl  1.13     ///
346 mike  1.11     void get(Array<Boolean>& x) const;
347 karl  1.13     ///
348 mike  1.11     void get(Array<Uint8>& x) const;
349 karl  1.13     //////
350 mike  1.11     void get(Array<Sint8>& x) const;
351 karl  1.13     ///
352 mike  1.11     void get(Array<Uint16>& x) const;
353 karl  1.13     ///
354 mike  1.11     void get(Array<Sint16>& x) const;
355 karl  1.13     ///
356 mike  1.11     void get(Array<Uint32>& x) const;
357 karl  1.13     ///
358 mike  1.11     void get(Array<Sint32>& x) const;
359 karl  1.13     ///
360 mike  1.11     void get(Array<Uint64>& x) const;
361 karl  1.13     ///
362 mike  1.11     void get(Array<Sint64>& x) const;
363 karl  1.13     ///
364 mike  1.11     void get(Array<Real32>& x) const;
365 karl  1.13     ///
366 mike  1.11     void get(Array<Real64>& x) const;
367 karl  1.13     ///
368 mike  1.11     void get(Array<Char16>& x) const;
369 karl  1.13     ///
370 mike  1.11     void get(Array<String>& x) const;
371 karl  1.13     ///
372 mike  1.11     void get(Array<CIMDateTime>& x) const; 
373 kumpf 1.14     ///
374 kumpf 1.23     void get(Array<CIMObjectPath>& x) const; 
375 mike  1.11 
376 kumpf 1.34     /** Compares with another CIMValue object for equality.
377                    @param x - CIMValue to compare with.
378                    @return true if they are identical in type, attribute and value,
379                    false otherwise.
380 kumpf 1.27     */
381                Boolean equal(const CIMValue& x) const;
382 kumpf 1.20 
383 kumpf 1.34     /** Converts the CIMvalue to a string.  Should only be
384                    used for output purposes.  To get an actual String value, use
385                    get(String &).
386                    @return  String output for CIMValue.
387 kumpf 1.18         <PRE>
388                        String test;
389                        CIMValue value(Boolean(true));
390                        test = value.toString();  // puts "TRUE" into test
391                    </PRE>
392                    */
393 mike  1.11     String toString() const;
394            
395            private:
396            
397 a.arora 1.37     CIMValueRep* _rep;
398 mike    1.11 
399                  friend class CIMMethodRep;
400                  friend class CIMParameterRep;
401                  friend class CIMPropertyRep;
402                  friend class CIMQualifierRep;
403                  friend class CIMQualifierDeclRep;
404              };
405 kumpf   1.18 
406 karl    1.17 /** operator == compares two CIMValue objects for equality.
407 kumpf   1.34     @param x - First CIMValue to compare
408                  @param y - Second CIMValue to compare
409                  @return true if they are identical in type, attribute and value,
410                  false otherwise.
411 karl    1.17 */
412 mike    1.11 PEGASUS_COMMON_LINKAGE Boolean operator==(const CIMValue& x, const CIMValue& y);
413              
414 kumpf   1.34 /** operator != compares two CIMValue objects for inequality.
415                  @param x - First CIMValue to compare
416                  @param y - Second CIMValue to compare
417                  @return true if they are NOT identical in type, attribute or value,
418                  false otherwise.
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 */

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2