1 chuck 1.2 //%2003////////////////////////////////////////////////////////////////////////
2 //
3 // 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 //
8 // Permission is hereby granted, free of charge, to any person obtaining a copy
9 // 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 // 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 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
16 // 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 // 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 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 chuck 1.2 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 //
24 //==============================================================================
25 //
26 // Author: Dave Rosckes (rosckes@us.ibm.com)
27 //
28 // Modified By:
29 //
30 //%/////////////////////////////////////////////////////////////////////////////
31
32 #ifndef PEGASUS_CQLVALUE_H
33 #define PEGASUS_CQLVALUE_H
34
35
36 #include <Pegasus/Common/Config.h>
37
38 #include <Pegasus/Common/CIMInstance.h>
39 #include <Pegasus/Common/ArrayInternal.h>
40 #include <Pegasus/Common/String.h>
41 #include <Pegasus/Query/QueryCommon/QueryContext.h>
42 #include <Pegasus/Common/CIMObjectPath.h>
43 chuck 1.2 #include <Pegasus/CQL/CQLChainedIdentifier.h>
44
45 #include <Pegasus/CQL/Linkage.h>
46
47 #ifdef PEGASUS_USE_EXPERIMENTAL_INTERFACES
48
49 PEGASUS_NAMESPACE_BEGIN
50 class PEGASUS_CQL_LINKAGE CQLFactory;
51 class PEGASUS_CQL_LINKAGE CQLValueRep;
52
53 /** The CQLValue class encapulates a value
54 that is a CQL value. The possible CQLValue
55 types are the following:
56
57 Sint64
58 Uint64
59 String
60 CIMDateTime
61 CIMReference
62 CQLIdentifier
63
64 chuck 1.2
65 This class can resolve an identifier to a primitive
66 value such as Sint64, Uint64 or String, CIMDateTime,
67 and CIMReference.
68
69 This class overloads and performs type checking
70 on the following operators:
71 <, >, =, >=. <=. <>
72
73
74 NOTE: the CQLValue class assumes a symbolic constant
75 is fully qualified.
76
77 */
78
79 class PEGASUS_CQL_LINKAGE CQLValue
80 {
81 public:
82
83 enum NumericType { Hex, Binary, Decimal, Real};
84 enum CQLValueType { Null_type, Sint64_type, Uint64_type, Real_type, String_type,
85 chuck 1.2 CIMDateTime_type, CIMReference_type, CQLIdentifier_type,
86 CIMObject_type, Boolean_type};
87
88 /**
89 Contructs CQLTermRep default object.
90
91 @param - None.
92 @return - None.
93 @throw - None.
94 <I><B>Experimental Interface</B></I><BR>
95 */
96 CQLValue();
97
98 /**
99 Contructs CQLTermRep default object.
100
101 @param - None.
102 @return - None.
103 @throw - None.
104 <I><B>Experimental Interface</B></I><BR>
105 */
106 chuck 1.2 ~CQLValue()
107
108 /**
109 Contructs CQLTermRep default object.
110
111 @param - None.
112 @return - None.
113 @throw - None.
114 <I><B>Experimental Interface</B></I><BR>
115 */;
116 CQLValue(const CQLValue& val);
117
118 /**
119 Contructs CQLTermRep default object.
120
121 @param - None.
122 @return - None.
123 @throw - None.
124 <I><B>Experimental Interface</B></I><BR>
125 */
126 CQLValue(String inString, NumericType inValueType,
127 chuck 1.2 Boolean inSign = true);
128
129 /** Initializes object as a CQLIdentifier.
130 */
131 /**
132 Contructs CQLTermRep default object.
133
134 @param - None.
135 @return - None.
136 @throw - None.
137 <I><B>Experimental Interface</B></I><BR>
138 */
139 CQLValue(CQLChainedIdentifier inCQLIdent);
140
141 /** Initializes object as a CIMObjectPath.
142 */
143 /**
144 Contructs CQLTermRep default object.
145
146 @param - None.
147 @return - None.
148 chuck 1.2 @throw - None.
149 <I><B>Experimental Interface</B></I><BR>
150 */
151 CQLValue(CIMObjectPath inObjPath);
152
153 /** Initializes object as a CIMDateTime.
154 */
155 /**
156 Contructs CQLTermRep default object.
157
158 @param - None.
159 @return - None.
160 @throw - None.
161 <I><B>Experimental Interface</B></I><BR>
162 */
163 CQLValue(CIMDateTime inDateTime);
164
165 /** Initializes object as a literal string (non-numeric).
166 */
167 /**
168 Contructs CQLTermRep default object.
169 chuck 1.2
170 @param - None.
171 @return - None.
172 @throw - None.
173 <I><B>Experimental Interface</B></I><BR>
174 */
175 CQLValue(String inString);
176
177 /**
178 Contructs CQLTermRep default object.
179
180 @param - None.
181 @return - None.
182 @throw - None.
183 <I><B>Experimental Interface</B></I><BR>
184 */
185 CQLValue(Sint64 inSint);
186
187 /**
188 Contructs CQLTermRep default object.
189
190 chuck 1.2 @param - None.
191 @return - None.
192 @throw - None.
193 <I><B>Experimental Interface</B></I><BR>
194 */
195 CQLValue(Uint64 inUint);
196
197 /**
198 Contructs CQLTermRep default object.
199
200 @param - None.
201 @return - None.
202 @throw - None.
203 <I><B>Experimental Interface</B></I><BR>
204 */
205 CQLValue(Real64 inReal);
206
207 /**
208 Contructs CQLTermRep default object.
209
210 @param - None.
211 chuck 1.2 @return - None.
212 @throw - None.
213 <I><B>Experimental Interface</B></I><BR>
214 */
215 CQLValue(CIMInstance inInstance);
216
217 /**
218 Contructs CQLTermRep default object.
219
220 @param - None.
221 @return - None.
222 @throw - None.
223 <I><B>Experimental Interface</B></I><BR>
224 */
225 CQLValue(Boolean inBool);
226
227 /**
228 Contructs CQLTermRep default object.
229
230 @param - None.
231 @return - None.
232 chuck 1.2 @throw - None.
233 <I><B>Experimental Interface</B></I><BR>
234 */
235 CQLValue(CIMClass inClass);
236
237 /**
238 Contructs CQLTermRep default object.
239
240 @param - None.
241 @return - None.
242 @throw - None.
243 <I><B>Experimental Interface</B></I><BR>
244 */
245 CQLValue(CQLValueRep rhs);
246
247 /**
248 Contructs CQLTermRep default object.
249
250 @param - None.
251 @return - None.
252 @throw - None.
253 chuck 1.2 <I><B>Experimental Interface</B></I><BR>
254 */
255 CQLValue(CIMObject inObject);
256
257 /**
258 Contructs CQLTermRep default object.
259
260 @param - None.
261 @return - None.
262 @throw - None.
263 <I><B>Experimental Interface</B></I><BR>
264 */
265 CQLValue(CIMValue inVal);
266
267 /** This method is used to ask an identifier to resolve itself to
268 a number or string (primitive value).
269
270 Resolves:
271 - symbolic constants
272 - indexing an array
273 - decoding identifier
274 chuck 1.2 * URI reference
275 * embedded object (e.g. myclass.embeddedobject.prop1)
276 and this is recursive
277 - class aliasing
278 */
279 /**
280 Contructs CQLTermRep default object.
281
282 @param - None.
283 @return - None.
284 @throw - None.
285 <I><B>Experimental Interface</B></I><BR>
286 */
287 void resolve(const CIMInstance& CI,const QueryContext& inQueryCtx);
288
289 CQLValue& operator=(const CQLValue& rhs);
290
291 /** operator == compares two CQLValue objects for equality and
292 performs type checking.
293 @param x - First CQLValue to compare
294 @param y - Second CQLValue to compare
295 chuck 1.2 @return true if they are identical in type, attribute and value,
296 false otherwise.
297 */
298
299 Boolean operator==(const CQLValue& x);
300
301 /** operator == compares two CQLValue objects for inequality and
302 performs type checking.
303 @param x - First CQLValue to compare
304 @param y - Second CQLValue to compare
305 @return true if they are NOT identical in type, attribute and value,
306 false otherwise.
307 */
308
309 Boolean operator!=(const CQLValue& x);
310
311 /** operator <= compares two CQLValue objects to see if x is less than or
312 equal to y and performs type checking.
313 @param x - First CQLValue to compare
314 @param y - Second CQLValue to compare
315 @return true if x is less than or equal to y,
316 chuck 1.2 false otherwise.
317 */
318
319 Boolean operator<=(const CQLValue& x);
320
321 /** operator >= compares two CQLValue objects to see if x is greater than or
322 equal to y and performs type checking.
323 @param x - First CQLValue to compare
324 @param y - Second CQLValue to compare
325 @return true if x is greater than or equal to y,
326 false otherwise.
327 */
328
329 Boolean operator>=(const CQLValue& x);
330
331 /** The overload operator (<) compares CQLValue obects and
332 performs type checking.
333 <pre>
334 CQLValue val1 = "def";
335 CQLValue val2 = "a";
336 assert (val2 < val1);
337 chuck 1.2 </pre>
338 */
339
340 Boolean operator<(const CQLValue& val1);
341
342 /** The overload operator (>) compares CQLValue obects and
343 performs type checking.
344 <pre>
345 CQLValue val1 = "def";
346 CQLValue val2 = "a";
347 assert (val2 < val1);
348 </pre>
349 */
350
351 Boolean operator>(const CQLValue& val1);
352
353 /** This overload operator (+) concatenates or adds the value of
354 CQLValue objects and performs type checking and Uint64 handling.
355 For example,
356 <pre>
357 CQLValue t1 = "abc"; // it's a string type
358 chuck 1.2 CQLValue t2 = "def"; // it's another string type
359 CQLValue t3 = t1 + t2;
360 assert(t3 == "abcdef");
361 </pre>
362 */
363
364 CQLValue operator+(const CQLValue& x);
365
366
367
368 /** Accessor for getting the type of the CQLValue.
369
370 TODO: do we need this method?
371 */
372
373 CQLValueType getValueType();
374
375 /** Clears this object and sets its type to NULL_VALUE
376 */
377
378 void setNull();
379 chuck 1.2
380 /** Returns whether the value has been resolved to a primitive.
381 */
382
383 Boolean isResolved();
384
385 /** Returns whether the CQLValue is null.
386 */
387
388 Boolean isNull();
389
390 /** Tests to see if this "isa" the input string.
391 */
392
393 Boolean isa(const CQLChainedIdentifier& cid, QueryContext& QueryCtx);
394
395 /** Tests to see if this "like" the input string.
396 Both sides of the LIKE comparison must have a String type:
397 the result is a Boolean type.
398
399 The LIKE comparison allows a string to be tested by pattern-matching,
400 chuck 1.2 using special characters n the right-hand-side string.
401 See the DMTF CQL Specification for details.
402
403 For Basic Query, the left-hand expression (this) may be restricted to
404 chain, and
405 the right-hand expression may be restricted to be a literal-string.
406 */
407
408 Boolean like(const CQLValue& inVal);
409 /*
410 void invert();
411 */
412 CQLChainedIdentifier getChainedIdentifier()const;
413 Uint64 getUint()const;
414 Sint64 getSint()const;
415 Real64 getReal()const;
416 String getString()const;
417 Boolean getBool()const;
418 CIMDateTime getDateTime()const;
419 CIMObjectPath getReference()const;
420 CIMObject getObject()const;
421 chuck 1.2 String toString()const;
422 void applyContext(QueryContext& _ctx,
423 CQLChainedIdentifier& inCid);
424 friend class CQLFactory;
425
426 private:
427
428
429 CQLValueRep *_rep;
430 };
431
432 /*
433 #ifndef PEGASUS_ARRAY_T
434 #define PEGASUS_ARRAY_T CQLValue
435 #include <Pegasus/Common/ArrayInter.h>
436 #undef PEGASUS_ARRAY_T
437 #endif
438 */
439
440 PEGASUS_NAMESPACE_END
441 #endif
442 chuck 1.2 #endif /* CQLVALUE_H */
|