1 karl 1.4 //%2005////////////////////////////////////////////////////////////////////////
|
2 chuck 1.2 //
|
3 karl 1.4 // 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 chuck 1.2 // IBM Corp.; EMC Corporation, The Open Group.
|
7 karl 1.4 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
8 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
9 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
10 // EMC Corporation; VERITAS Software Corporation; The Open Group.
|
11 chuck 1.2 //
12 // Permission is hereby granted, free of charge, to any person obtaining a copy
13 // of this software and associated documentation files (the "Software"), to
14 // deal in the Software without restriction, including without limitation the
15 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
16 // sell copies of the Software, and to permit persons to whom the Software is
17 // furnished to do so, subject to the following conditions:
18 //
19 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
20 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
21 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
22 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
23 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
24 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
25 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 //
28 //==============================================================================
29 //
30 // Author: Dave Rosckes (rosckes@us.ibm.com)
31 //
32 chuck 1.2 // Modified By:
33 //
34 //%/////////////////////////////////////////////////////////////////////////////
35
36 #ifndef PEGASUS_CQLVALUE_H
37 #define PEGASUS_CQLVALUE_H
38
39
40 #include <Pegasus/Common/Config.h>
41
42 #include <Pegasus/Common/CIMInstance.h>
43 #include <Pegasus/Common/ArrayInternal.h>
44 #include <Pegasus/Common/String.h>
45 #include <Pegasus/Query/QueryCommon/QueryContext.h>
46 #include <Pegasus/Common/CIMObjectPath.h>
47 #include <Pegasus/CQL/CQLChainedIdentifier.h>
48
49 #include <Pegasus/CQL/Linkage.h>
50
51 #ifdef PEGASUS_USE_EXPERIMENTAL_INTERFACES
52
53 chuck 1.2 PEGASUS_NAMESPACE_BEGIN
54 class PEGASUS_CQL_LINKAGE CQLFactory;
55 class PEGASUS_CQL_LINKAGE CQLValueRep;
56
57 /** The CQLValue class encapulates a value
58 that is a CQL value. The possible CQLValue
59 types are the following:
60
61 Sint64
62 Uint64
63 String
64 CIMDateTime
65 CIMReference
66 CQLIdentifier
67
68
69 This class can resolve an identifier to a primitive
70 value such as Sint64, Uint64 or String, CIMDateTime,
71 and CIMReference.
72
73 This class overloads and performs type checking
74 chuck 1.2 on the following operators:
75 <, >, =, >=. <=. <>
76
77
78 NOTE: the CQLValue class assumes a symbolic constant
79 is fully qualified.
80
81 */
82
83 class PEGASUS_CQL_LINKAGE CQLValue
84 {
85 public:
86
87 enum NumericType { Hex, Binary, Decimal, Real};
88 enum CQLValueType { Null_type, Sint64_type, Uint64_type, Real_type, String_type,
89 CIMDateTime_type, CIMReference_type, CQLIdentifier_type,
90 CIMObject_type, Boolean_type};
91
92 /**
|
93 david 1.3 Contructs CQLValue default object.
|
94 chuck 1.2
95 @param - None.
96 @return - None.
97 @throw - None.
98 <I><B>Experimental Interface</B></I><BR>
99 */
100 CQLValue();
101
102 /**
|
103 david 1.3 Destroys CQLValue object.
|
104 chuck 1.2
105 @param - None.
106 @return - None.
107 @throw - None.
108 <I><B>Experimental Interface</B></I><BR>
109 */
110 ~CQLValue()
111
112 /**
|
113 david 1.3 Contructs CQLValue object (Copy-Constructor).
|
114 chuck 1.2
115 @param - None.
116 @return - None.
117 @throw - None.
118 <I><B>Experimental Interface</B></I><BR>
119 */;
120 CQLValue(const CQLValue& val);
121
122 /**
|
123 david 1.3 Contructs CQLValue object given a string and a numbericType
|
124 chuck 1.2
|
125 david 1.3 @param - inString - the string representation of a number
126 @param - inValueType - the NumericType
|
127 chuck 1.2 @return - None.
128 @throw - None.
129 <I><B>Experimental Interface</B></I><BR>
130 */
131 CQLValue(String inString, NumericType inValueType,
132 Boolean inSign = true);
133
|
134 david 1.3 /**
135 Contructs CQLValue object via CQLChainedIdentifier.
|
136 chuck 1.2
|
137 david 1.3 @param - inCQLIdent - The CQLChained Identifer used to create the object
|
138 chuck 1.2 @return - None.
139 @throw - None.
140 <I><B>Experimental Interface</B></I><BR>
141 */
142 CQLValue(CQLChainedIdentifier inCQLIdent);
143
|
144 david 1.3 /**
145 Initializes object as a CIMObjectPath.
146
147 @param - inObjPath - CIMObjectPath use to construct object.
|
148 chuck 1.2 @return - None.
149 @throw - None.
150 <I><B>Experimental Interface</B></I><BR>
151 */
152 CQLValue(CIMObjectPath inObjPath);
153
|
154 david 1.3 /**
155 Initializes object as a CIMDateTime.
156
157 @param - inDateTime - used to construct object.
|
158 chuck 1.2 @return - None.
159 @throw - None.
160 <I><B>Experimental Interface</B></I><BR>
161 */
162 CQLValue(CIMDateTime inDateTime);
163
|
164 david 1.3 /**
165 Initializes object as a literal string (non-numeric).
166
167 @param - inString - String used to construct object.
|
168 chuck 1.2 @return - None.
169 @throw - None.
170 <I><B>Experimental Interface</B></I><BR>
171 */
172 CQLValue(String inString);
173
174 /**
|
175 david 1.3 Initializes object as an Sint64.
|
176 chuck 1.2
|
177 david 1.3 @param - inSint - Sint64 used to contruct object.
|
178 chuck 1.2 @return - None.
179 @throw - None.
180 <I><B>Experimental Interface</B></I><BR>
181 */
182 CQLValue(Sint64 inSint);
183
184 /**
|
185 david 1.3 Initializes object as a Uint64
|
186 chuck 1.2
|
187 david 1.3 @param - inUint - Uint64 used to construct object.
|
188 chuck 1.2 @return - None.
189 @throw - None.
190 <I><B>Experimental Interface</B></I><BR>
191 */
192 CQLValue(Uint64 inUint);
193
194 /**
|
195 david 1.3 Initializes object as a Real64
|
196 chuck 1.2
|
197 david 1.3 @param - inReal - Real64 used to construct object.
|
198 chuck 1.2 @return - None.
199 @throw - None.
200 <I><B>Experimental Interface</B></I><BR>
201 */
202 CQLValue(Real64 inReal);
203
204 /**
|
205 david 1.3 Initializes object as a CIMInstance
|
206 chuck 1.2
|
207 david 1.3 @param - inInstance - CIMInstance used to construct object.
|
208 chuck 1.2 @return - None.
209 @throw - None.
210 <I><B>Experimental Interface</B></I><BR>
211 */
212 CQLValue(CIMInstance inInstance);
213
214 /**
|
215 david 1.3 Initializes object as a Boolean
|
216 chuck 1.2
|
217 david 1.3 @param - inBool - inBool used to construct object.
|
218 chuck 1.2 @return - None.
219 @throw - None.
220 <I><B>Experimental Interface</B></I><BR>
221 */
222 CQLValue(Boolean inBool);
223
224 /**
|
225 david 1.3 Initializes object as a inClass
|
226 chuck 1.2
|
227 david 1.3 @param - inClass - CIMClass used to construct object.
|
228 chuck 1.2 @return - None.
229 @throw - None.
230 <I><B>Experimental Interface</B></I><BR>
231 */
232 CQLValue(CIMClass inClass);
233
234 /**
|
235 david 1.3 Initializes object as a CQLValueRep
|
236 chuck 1.2
|
237 david 1.3 @param - rhs - CQLValueRep used to construct object.
|
238 chuck 1.2 @return - None.
239 @throw - None.
240 <I><B>Experimental Interface</B></I><BR>
241 */
242 CQLValue(CQLValueRep rhs);
243
244 /**
|
245 david 1.3 Initializes object as a CIMObject
|
246 chuck 1.2
|
247 david 1.3 @param - inObject - CIMObject used to construct object.
|
248 chuck 1.2 @return - None.
249 @throw - None.
250 <I><B>Experimental Interface</B></I><BR>
251 */
252 CQLValue(CIMObject inObject);
253
254 /**
|
255 david 1.3 Initializes object as a CIMValue
|
256 chuck 1.2
|
257 david 1.3 @param - inVal - CIMValue used to construct object.
|
258 chuck 1.2 @return - None.
259 @throw - None.
260 <I><B>Experimental Interface</B></I><BR>
261 */
262 CQLValue(CIMValue inVal);
263
264 /** This method is used to ask an identifier to resolve itself to
|
265 david 1.3 a primitive value.
|
266 chuck 1.2
267 Resolves:
268 - symbolic constants
269 - indexing an array
270 - decoding identifier
271 * embedded object (e.g. myclass.embeddedobject.prop1)
272 and this is recursive
273 - class aliasing
|
274 david 1.3
275 @param - CI - CIMInstance where information is retrieved.
276 @param - inQueryCtx - QueryContext contains query data.
277 @return - None.
278 @throw - CQLRuntimeException.
279 <I><B>Experimental Interface</B></I><BR>
|
280 chuck 1.2 */
|
281 david 1.3 void resolve(const CIMInstance& CI,const QueryContext& inQueryCtx);
282
|
283 chuck 1.2 /**
|
284 david 1.3 Assignment operator.
|
285 chuck 1.2
|
286 david 1.3 @param - rhs - right hand side of operator.
287 @return - CQLValue.
|
288 chuck 1.2 @throw - None.
289 <I><B>Experimental Interface</B></I><BR>
290 */
291 CQLValue& operator=(const CQLValue& rhs);
292
|
293 david 1.3 /**
294 operator == compares two CQLValue objects for equality and
|
295 chuck 1.2 performs type checking.
|
296 david 1.3
297 @param - rhs - right hand side of operator.
298 @return - Boolean.
299 @throw - None.
300 <I><B>Experimental Interface</B></I><BR>
|
301 chuck 1.2 */
|
302 david 1.3
|
303 chuck 1.2
304 Boolean operator==(const CQLValue& x);
305
|
306 david 1.3 /**
307 operator != compares two CQLValue objects for inequality and
|
308 chuck 1.2 performs type checking.
|
309 david 1.3
310 @param - x - right hand side of operator.
311 @return - Boolean.
312 @throw - None.
313 <I><B>Experimental Interface</B></I><BR>
|
314 chuck 1.2 */
315 Boolean operator!=(const CQLValue& x);
316
|
317 david 1.3 /**
318 operator <= compares two CQLValue objects to see if leftside is less than or
319 equal to right side and performs type checking.
320
321 @param - x - right hand side of operator.
322 @return - Boolean.
323 @throw - None.
324 <I><B>Experimental Interface</B></I><BR>
|
325 chuck 1.2 */
326 Boolean operator<=(const CQLValue& x);
327
|
328 david 1.3 /**
329 operator >= compares two CQLValue objects to see if leftside is greater than or
330 equal to rightside and performs type checking.
331
332 @param - x - right hand side of operator.
333 @return - Boolean.
334 @throw - None.
335 <I><B>Experimental Interface</B></I><BR>
|
336 chuck 1.2 */
337
338 Boolean operator>=(const CQLValue& x);
339
|
340 david 1.3 /**
341 The overload operator < compares CQLValue obects and
|
342 chuck 1.2 performs type checking.
|
343 david 1.3
344 @param - val1 - right hand side of operator.
345 @return - Boolean.
346 @throw - None.
347 <I><B>Experimental Interface</B></I><BR>
|
348 chuck 1.2 */
349 Boolean operator<(const CQLValue& val1);
350
|
351 david 1.3 /**
352 The overload operator > compares CQLValue obects and
|
353 chuck 1.2 performs type checking.
|
354 david 1.3
355 @param - val1 - right hand side of operator.
356 @return - Boolean.
357 @throw - None.
358 <I><B>Experimental Interface</B></I><BR>
|
359 chuck 1.2 */
360 Boolean operator>(const CQLValue& val1);
361
|
362 david 1.3 /** This overload operator (+) concatenates the value of
363 CQLValue objects and performs type checking.
364 (Currently supports only CQLValue of String type.)
365
366 @param - x - right hand side of operator.
367 @return - Boolean.
368 @throw - None.
369 <I><B>Experimental Interface</B></I><BR>
|
370 chuck 1.2 */
|
371 david 1.3 CQLValue operator+(const CQLValue& x);
|
372 chuck 1.2
|
373 david 1.3 /**
374 Accessor for getting the type of the CQLValue.
375
376 @param - None.
377 @return - CQLValueType.
378 @throw - None.
379 <I><B>Experimental Interface</B></I><BR>
380 */
|
381 chuck 1.2 CQLValueType getValueType();
382
|
383 david 1.3 /**
384 Clears this object and sets its type to NULL_VALUE
385
386 @param - None.
387 @return - None.
388 @throw - None.
389 <I><B>Experimental Interface</B></I><BR>
390 */
|
391 chuck 1.2 void setNull();
392
|
393 david 1.3 /**
394 Returns whether the value has been resolved to a primitive.
395
396 @param - None.
397 @return - true when value is a primitive.
398 @throw - None.
399 <I><B>Experimental Interface</B></I><BR>
400 */
|
401 chuck 1.2 Boolean isResolved();
402
|
403 david 1.3 /**
404 Returns whether the CQLValue is null.
405
406 @param - None.
407 @return - true if CQLValue primitive value is NULL.
408 @throw - None.
409 <I><B>Experimental Interface</B></I><BR>
410 */
|
411 chuck 1.2 Boolean isNull();
412
|
413 david 1.3 /** This will test to determine if the CQLValue isa String contained in the cid,
414 that identifies a class. The CQLValue must be of a type Instance or Class; Also
415 the cid must contain a String that is a valid class name.
416
417 @param - cid - Contains the class name.
418 @param - QueryCtx - contains query related data.
419 @return - true CQLValue isa class identified by cid.
420 @throw - None.
421 <I><B>Experimental Interface</B></I><BR>
422 */
|
423 chuck 1.2
424 Boolean isa(const CQLChainedIdentifier& cid, QueryContext& QueryCtx);
425
426 /** Tests to see if this "like" the input string.
427 Both sides of the LIKE comparison must have a String type:
428 the result is a Boolean type.
429
430 The LIKE comparison allows a string to be tested by pattern-matching,
431 using special characters n the right-hand-side string.
432 See the DMTF CQL Specification for details.
433
434 For Basic Query, the left-hand expression (this) may be restricted to
435 chain, and
436 the right-hand expression may be restricted to be a literal-string.
|
437 david 1.3
438 @param - inVal - CQLValue to be compared.
439 @return - true CQLValue is like the passed in CQLValue.
440 @throw - None.
441 <I><B>Experimental Interface</B></I><BR>
|
442 chuck 1.2 */
443 Boolean like(const CQLValue& inVal);
|
444 david 1.3
445 /**
446 Get the ChainedIdentifier. Primitive from CQLValue
447
448 @param - None.
449 @return - ChainedIdentifier.
450 @throw - CQLRuntimeException.
451 <I><B>Experimental Interface</B></I><BR>
|
452 chuck 1.2 */
453 CQLChainedIdentifier getChainedIdentifier()const;
|
454 david 1.3
455 /**
456 Get the Uint64. Primitive from CQLValue
457
458 @param - None.
459 @return - Uint64.
460 @throw - CQLRuntimeException.
461 <I><B>Experimental Interface</B></I><BR>
462 */
|
463 chuck 1.2 Uint64 getUint()const;
|
464 david 1.3
465 /**
466 Get the Sint64. Primitive from CQLValue.
467
468 @param - None.
469 @return - Sint64.
470 @throw - CQLRuntimeException.
471 <I><B>Experimental Interface</B></I><BR>
472 */
|
473 chuck 1.2 Sint64 getSint()const;
|
474 david 1.3
475 /**
476 Get the Real64. Primitive from CQLValue.
477
478 @param - None.
479 @return - Real64.
480 @throw - CQLRuntimeException.
481 <I><B>Experimental Interface</B></I><BR>
482 */
|
483 chuck 1.2 Real64 getReal()const;
|
484 david 1.3
485 /**
486 Get the String. Primitive from CQLValue
487
488 @param - None.
489 @return - String.
490 @throw - CQLRuntimeException.
491 <I><B>Experimental Interface</B></I><BR>
492 */
|
493 chuck 1.2 String getString()const;
|
494 david 1.3
495 /**
496 Get the Boolean. Primitive from CQLValue
497
498 @param - None.
499 @return - Boolean
500 @throw - CQLRuntimeException.
501 <I><B>Experimental Interface</B></I><BR>
502 */
|
503 chuck 1.2 Boolean getBool()const;
|
504 david 1.3
505 /**
506 Get the CIMDateTime. Primitive from CQLValue.
507
508 @param - None.
509 @return - CIMDateTime
510 @throw - CQLRuntimeException.
511 <I><B>Experimental Interface</B></I><BR>
512 */
|
513 chuck 1.2 CIMDateTime getDateTime()const;
|
514 david 1.3
515 /**
516 Get the CIMObjectPath. Primitive from CQLValue.
517
518 @param - None.
519 @return - Reference.
520 @throw - CQLRuntimeException.
521 <I><B>Experimental Interface</B></I><BR>
522 */
|
523 chuck 1.2 CIMObjectPath getReference()const;
|
524 david 1.3
525 /**
526 Get the CIMObject. Primitive from CQLValue.
527
528 @param - None.
529 @return - CIMObject.
530 @throw - CQLRuntimeException.
531 <I><B>Experimental Interface</B></I><BR>
532 */
|
533 chuck 1.2 CIMObject getObject()const;
|
534 david 1.3
535 /**
536 Return String representation of object.
537
538 @param - None.
539 @return - String
540 @throw - None.
541 <I><B>Experimental Interface</B></I><BR>
542 */
|
543 chuck 1.2 String toString()const;
|
544 david 1.3
545 /**
546 Apply scope and class to CQLValue's chainedIdentifier.
547
548 @param - None.
549 @return - None.
550 @throw - None.
551 <I><B>Experimental Interface</B></I><BR>
552 */
|
553 chuck 1.2 void applyContext(QueryContext& _ctx,
554 CQLChainedIdentifier& inCid);
|
555 david 1.3
|
556 chuck 1.2 friend class CQLFactory;
557
558 private:
559
560
561 CQLValueRep *_rep;
562 };
563
564 /*
565 #ifndef PEGASUS_ARRAY_T
566 #define PEGASUS_ARRAY_T CQLValue
567 #include <Pegasus/Common/ArrayInter.h>
568 #undef PEGASUS_ARRAY_T
569 #endif
570 */
571
572 PEGASUS_NAMESPACE_END
573 #endif
574 #endif /* CQLVALUE_H */
|