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

  1 mike  1.10 //%/////////////////////////////////////////////////////////////////////////////
  2            //
  3            // Copyright (c) 2000, 2001 The Open group, BMC Software, Tivoli Systems, IBM
  4            //
  5            // Permission is hereby granted, free of charge, to any person obtaining a copy
  6            // of this software and associated documentation files (the "Software"), to 
  7            // deal in the Software without restriction, including without limitation the 
  8            // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 
  9            // sell copies of the Software, and to permit persons to whom the Software is
 10            // furnished to do so, subject to the following conditions:
 11            // 
 12            // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN 
 13            // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
 14            // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
 15            // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 
 16            // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 
 17            // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 
 18            // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 19            // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 20            //
 21            //==============================================================================
 22 mike  1.10 //
 23            // Author: Mike Brasher (mbrasher@bmc.com)
 24            //
 25            // Modified By:
 26            //
 27            //%/////////////////////////////////////////////////////////////////////////////
 28            
 29            #ifndef Pegasus_Value_h
 30            #define Pegasus_Value_h
 31            
 32            #include <Pegasus/Common/String.h>
 33            #include <Pegasus/Common/Config.h>
 34            #include <Pegasus/Common/CIMType.h>
 35            #include <Pegasus/Common/CIMDateTime.h>
 36            #include <Pegasus/Common/Union.h>
 37            #include <Pegasus/Common/Array.h>
 38            
 39            PEGASUS_NAMESPACE_BEGIN
 40            
 41            /**
 42                The CIMValue class represents a value of any of the CIM data types
 43 mike  1.10     (see CIMType.h for a list of valid CIM data types). This class
 44                encapsulates a union which holds the current value. The class also
 45                has a type field indicating the type of that value.
 46            */
 47            class PEGASUS_COMMON_LINKAGE CIMValue
 48            {
 49            public:
 50                ///	Constructor
 51                CIMValue();
 52            
 53                ///	Constructor
 54                CIMValue(Boolean x) { _init(); set(x); }
 55            
 56                ///	Constructor
 57                CIMValue(Uint8 x) { _init(); set(x); }
 58            
 59                ///	Constructor
 60                CIMValue(Sint8 x) { _init(); set(x); }
 61            
 62                ///	Constructor
 63                CIMValue(Uint16 x) { _init(); set(x); }
 64 mike  1.10 
 65                ///	Constructor
 66                CIMValue(Sint16 x) { _init(); set(x); }
 67            
 68                ///	Constructor
 69                CIMValue(Uint32 x) { _init(); set(x); }
 70            
 71                ///	Constructor
 72                CIMValue(Sint32 x) { _init(); set(x); }
 73            
 74                ///	Constructor
 75                CIMValue(Uint64 x) { _init(); set(x); }
 76            
 77                ///	Constructor
 78                CIMValue(Sint64 x) { _init(); set(x); }
 79            
 80                ///	Constructor
 81                CIMValue(Real32 x) { _init(); set(x); }
 82            
 83                ///	Constructor
 84                CIMValue(Real64 x) { _init(); set(x); }
 85 mike  1.10 
 86                ///	Constructor
 87                CIMValue(const Char16& x) { _init(); set(x); }
 88            
 89                ///	Constructor
 90                CIMValue(const String& x) { _init(); set(x); }
 91            
 92                ///	Constructor
 93                CIMValue(const char* x) { _init(); set(x); }
 94            
 95                ///	Constructor
 96                CIMValue(const CIMDateTime& x) { _init(); set(x); }
 97            
 98                ///	Constructor
 99                CIMValue(const CIMReference& x) { _init(); set(x); }
100            
101                ///	Constructor
102                CIMValue(const Array<Boolean>& x) { _init(); set(x); }
103            
104                ///	Constructor
105                CIMValue(const Array<Uint8>& x) { _init(); set(x); }
106 mike  1.10 
107                ///	Constructor
108                CIMValue(const Array<Sint8>& x) { _init(); set(x); }
109            
110                ///	Constructor
111                CIMValue(const Array<Uint16>& x) { _init(); set(x); }
112            
113                ///	Constructor
114                CIMValue(const Array<Sint16>& x) { _init(); set(x); }
115            
116                ///	Constructor
117                CIMValue(const Array<Uint32>& x) { _init(); set(x); }
118            
119                ///	Constructor
120                CIMValue(const Array<Sint32>& x) { _init(); set(x); }
121            
122                ///	Constructor
123                CIMValue(const Array<Uint64>& x) { _init(); set(x); }
124            
125                ///	Constructor
126                CIMValue(const Array<Sint64>& x) { _init(); set(x); }
127 mike  1.10 
128                ///	Constructor
129                CIMValue(const Array<Real32>& x) { _init(); set(x); }
130            
131                ///	Constructor
132                CIMValue(const Array<Real64>& x) { _init(); set(x); }
133            
134                ///	Constructor
135                CIMValue(const Array<Char16>& x) { _init(); set(x); }
136            
137                ///	Constructor
138                CIMValue(const Array<String>& x) { _init(); set(x); }
139            
140                ///	Constructor
141                CIMValue(const Array<CIMDateTime>& x) { _init(); set(x); }
142            
143                ///	Constructor
144                CIMValue(const CIMValue& x);
145            
146                ///	Destrustructor
147                ~CIMValue();
148 mike  1.10 
149                /// Operator =
150                CIMValue& operator=(const CIMValue& x) 
151                { 
152            	assign(x); return *this; 
153                }
154            
155                /// CIMMethod assign
156                void assign(const CIMValue& x);
157            
158                /// CIMMethod clear
159                void clear();
160            
161                /** CIMMethod typeCompatible - Compares the types of two values.
162            	@return true if compatible.
163                */
164                Boolean typeCompatible(const CIMValue& x) const
165                {
166            	return _type == x._type && _isArray == x._isArray;
167                }
168            
169 mike  1.10     /** CIMMethod isArray - Determines if the value is an array
170            	@return TRUE if the value is an array
171                */
172                Boolean isArray() const { return _isArray; }
173            
174                /** CIMMethod getArraySize
175            	@return The number of entries in the array
176                */
177                Uint32 getArraySize() const;
178            
179                CIMType getType() const 
180                { 
181            	return CIMType(_type); 
182                }
183            
184                /// method setNullvalue - ATTN:
185                void setNullValue(CIMType type, Boolean isArray, Uint32 arraySize = 0);
186            
187                /// method set - ATTN:
188                void set(Boolean x);
189            
190 mike  1.10     /// CIMMethod Set
191                void set(Uint8 x);
192            
193                void set(Sint8 x);
194            
195                void set(Uint16 x);
196            
197                void set(Sint16 x);
198            
199                void set(Uint32 x);
200            
201                void set(Sint32 x);
202            
203                void set(Uint64 x);
204            
205                void set(Sint64 x);
206            
207                void set(Real32 x);
208            
209                void set(Real64 x);
210            
211 mike  1.10     void set(const Char16& x);
212            
213                void set(const String& x);
214            
215                void set(const char* x);
216            
217                void set(const CIMDateTime& x);
218            
219                void set(const CIMReference& x);
220            
221                void set(const Array<Boolean>& x);
222            
223                void set(const Array<Uint8>& x);
224            
225                void set(const Array<Sint8>& x);
226            
227                void set(const Array<Uint16>& x);
228            
229                void set(const Array<Sint16>& x);
230            
231                void set(const Array<Uint32>& x);
232 mike  1.10 
233                void set(const Array<Sint32>& x);
234            
235                void set(const Array<Uint64>& x);
236            
237                void set(const Array<Sint64>& x);
238            
239                void set(const Array<Real32>& x);
240            
241                void set(const Array<Real64>& x);
242            
243                void set(const Array<Char16>& x);
244            
245                void set(const Array<String>& x);
246            
247                void set(const Array<CIMDateTime>& x);
248            
249                /// CIMMethod get - ATTN
250                void get(Boolean& x) const;
251            
252                void get(Uint8& x) const;
253 mike  1.10 
254                void get(Sint8& x) const;
255            
256                void get(Uint16& x) const;
257            
258                void get(Sint16& x) const;
259            
260                void get(Uint32& x) const;
261            
262                void get(Sint32& x) const;
263            
264                void get(Uint64& x) const;
265            
266                void get(Sint64& x) const;
267            
268                void get(Real32& x) const;
269            
270                void get(Real64& x) const;
271            
272                void get(Char16& x) const;
273            
274 mike  1.10     void get(String& x) const;
275            
276                void get(CIMDateTime& x) const;
277            
278                void get(CIMReference& x) const;
279            
280                void get(Array<Boolean>& x) const;
281            
282                void get(Array<Uint8>& x) const;
283            
284                void get(Array<Sint8>& x) const;
285            
286                void get(Array<Uint16>& x) const;
287            
288                void get(Array<Sint16>& x) const;
289            
290                void get(Array<Uint32>& x) const;
291            
292                void get(Array<Sint32>& x) const;
293            
294                void get(Array<Uint64>& x) const;
295 mike  1.10 
296                void get(Array<Sint64>& x) const;
297            
298                void get(Array<Real32>& x) const;
299            
300                void get(Array<Real64>& x) const;
301            
302                void get(Array<Char16>& x) const;
303            
304                void get(Array<String>& x) const;
305            
306                void get(Array<CIMDateTime>& x) const; 
307            
308                /** CIMMethod toXML
309                
310                */
311                void toXml(Array<Sint8>& out) const;
312            
313                /** CIMMethod print - Format and print the Value to std output
314                	stream
315            	@return None
316 mike  1.10 	<PRE>
317            	Example:
318            	    CIMValue value(Boolean(true));
319            	    value.print();	  // Prints "true"
320            	</PRE> 
321                */
322                void print(PEGASUS_STD(ostream) &o=PEGASUS_STD(cout)) const;
323            
324                /** toString - Converts the CIMvalue to a string
325            	@return - String output for CIMValue.
326            	<PRE>
327            	Example:
328            	    String test;
329            	    CIMValue value(Boolean(true));
330            	    test = value.toString();	  // puts "true" into test
331            	</PRE>
332            	*/
333                String toString() const;
334            
335            private:
336            
337 mike  1.10     void _init();
338            
339                CIMType _type;
340                Boolean _isArray;
341                Union _u;
342            
343                friend class CIMMethodRep;
344                friend class CIMParameterRep;
345                friend class CIMPropertyRep;
346                friend class CIMQualifierRep;
347                friend class CIMQualifierDeclRep;
348                PEGASUS_COMMON_LINKAGE friend Boolean operator==(
349            	const CIMValue& x, 
350            	const CIMValue& y);
351            };
352            
353            PEGASUS_COMMON_LINKAGE Boolean operator==(const CIMValue& x, const CIMValue& y);
354            
355            inline Boolean operator!=(const CIMValue& x, const CIMValue& y)
356            {
357                return !operator==(x, y);
358 mike  1.10 }
359            
360            #define PEGASUS_ARRAY_T CIMValue
361            # include "ArrayInter.h"
362            #undef PEGASUS_ARRAY_T
363            
364            PEGASUS_NAMESPACE_END
365            
366            #endif /* Pegasus_Value_h */

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2