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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2