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

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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2