1 karl 1.9 //%2006////////////////////////////////////////////////////////////////////////
|
2 chuck 1.2 //
|
3 karl 1.6 // 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.6 // 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 karl 1.9 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
12 // EMC Corporation; Symantec Corporation; The Open Group.
|
13 chuck 1.2 //
14 // Permission is hereby granted, free of charge, to any person obtaining a copy
15 // of this software and associated documentation files (the "Software"), to
16 // deal in the Software without restriction, including without limitation the
17 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
18 // sell copies of the Software, and to permit persons to whom the Software is
19 // furnished to do so, subject to the following conditions:
|
20 karl 1.9 //
|
21 chuck 1.2 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
22 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
23 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
24 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
25 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
26 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
27 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 //
30 //==============================================================================
31 //
32 // Authors: David Rosckes (rosckes@us.ibm.com)
33 // Bert Rivero (hurivero@us.ibm.com)
34 // Chuck Carmack (carmack@us.ibm.com)
35 // Brian Lucier (lucier@us.ibm.com)
36 //
|
37 david.dillard 1.7 // Modified By: David Dillard, VERITAS Software Corp.
38 // (david.dillard@veritas.com)
|
39 vijay.eli 1.8 // Vijay Eli, IBM (vijayeli@in.ibm.com) bug#3590
|
40 chuck 1.2 //
41 //%/////////////////////////////////////////////////////////////////////////////
42
43 #ifndef Pegasus_CQLPredicate_h
44 #define Pegasus_CQLPredicate_h
45
|
46 david.dillard 1.7 #ifdef PEGASUS_USE_EXPERIMENTAL_INTERFACES
47
48 #include <Pegasus/CQL/Linkage.h>
|
49 chuck 1.2 #include <Pegasus/CQL/CQLSimplePredicate.h>
50 #include <Pegasus/Common/ArrayInternal.h>
51
52 PEGASUS_NAMESPACE_BEGIN
53
|
54 david.dillard 1.7 enum BooleanOpType { AND, OR };
|
55 chuck 1.2
56 /*
57 #ifndef PEGASUS_ARRAY_T
58 #define PEGASUS_ARRAY_T BooleanOpType
59 #include <Pegasus/Common/ArrayInter.h>
60 #undef PEGASUS_ARRAY_T
61 #endif
62 */
63
|
64 mike 1.10 class CQLPredicateRep;
65 class CQLFactory;
66 class QueryContext;
|
67 chuck 1.2
|
68 david.dillard 1.7 /**
|
69 humberto 1.4 The CQLPredicate class contains an expression that produces a boolean
70 result.
|
71 david.dillard 1.7
|
72 humberto 1.4 <PRE>
73 The CQLPredicate is non-simple if it contains only CQLPredicate objects.
74 Example: a CQLPredicate representing (a=1 OR b=2) would contain
75 two CQLPredicates, one representing (a=1), and the other
|
76 david.dillard 1.7 representing (b=2). These CQLPredicates would in turn be simple.
|
77 humberto 1.4
78 The CQLPredicate is simple if it contains a single CQLSimplePredicate,
79 representing an arithmetic or string expression.
80 Examples: a = 2
81 (a-b)/ 3 = c
82 a || b = 'abc'
83 </PRE>
84 */
|
85 chuck 1.2 class PEGASUS_CQL_LINKAGE CQLPredicate
86 {
87 public:
|
88 humberto 1.3 /**
89 Default constructor
90
91 @param - None.
92 @return - None.
93 @throws - None.
94 <I><B>Experimental Interface</B></I><BR>
95 */
|
96 chuck 1.2 CQLPredicate();
|
97 humberto 1.3
98 /**
99 Constructor. Using this constructor sets isSimple() to true.
|
100 david.dillard 1.7
|
101 humberto 1.3 @param - inSimplePredicate.
|
102 david.dillard 1.7 @param - inVerted. Defaults to false. This is a logical NOT of
103 this predicate
|
104 humberto 1.3 @return - None.
105 @throws - None.
106 <I><B>Experimental Interface</B></I><BR>
|
107 david.dillard 1.7 */
|
108 chuck 1.2 CQLPredicate(const CQLSimplePredicate & inSimplePredicate, Boolean inVerted = false);
109
|
110 humberto 1.3 /**
111 Constructor. Using this constructor sets isSimple() to false.
|
112 david.dillard 1.7
|
113 humberto 1.3 @param - inPredicate.
114 @param - inVerted. Defaults to false. This is a logical NOT of this predicate
115 @return - None.
116 @throws - None.
117 <I><B>Experimental Interface</B></I><BR>
118 */
|
119 chuck 1.2 CQLPredicate(const CQLPredicate & inPredicate, Boolean inVerted = false);
120
|
121 humberto 1.3 /**
122 Destructor
|
123 david.dillard 1.7
|
124 humberto 1.3 @param - None.
125 @return - None.
126 @throws - None.
127 <I><B>Experimental Interface</B></I><BR>
128 */
|
129 chuck 1.2 ~CQLPredicate();
|
130 humberto 1.4
|
131 david.dillard 1.7 /**
|
132 humberto 1.4 Evaluates this predicate, using a CIMInstance as a property source.
133
134 <PRE>
135 The CQLPredicate is non-simple if it contains only CQLPredicate objects.
136 A non-simple CQLPredicate is evaluated by in turn evaluating the
137 contained CQLPredicates and boolean operator.
138
|
139 chuck 1.2 For the evaluate method on each CQLPredicate. the CQLPredicate is
|
140 humberto 1.4 evaluated to TRUE/FALSE and the result of the evaluation is then
|
141 david.dillard 1.7 applied to the appropriate boolean operator.
142
|
143 humberto 1.4 The result of the evaluation is then inverted if the _invert member
144 variable is set to TRUE and then returned to the caller.
145
146 The CQLPredicate is simple if it contains only a single CQLSimplePredicate.
|
147 david.dillard 1.7 A simple CQLPredicate is evaluated by calling evaluate on
|
148 humberto 1.4 the CQLSimplePredicate.
149 </PRE>
150
151 @param - CI. Instance to evaluate query against.
152 @param - QueryCtx. Query Context
153 @return - Boolean.
154 @throws - None.
|
155 david.dillard 1.7 <I><B>Experimental Interface</B></I><BR>
|
156 humberto 1.4 */
|
157 chuck 1.2 Boolean evaluate(CIMInstance CI, QueryContext& QueryCtx);
158
|
159 humberto 1.3 /**
|
160 david.dillard 1.7 Returns true if this predicate has been inverted (NOT), false otherwise
|
161 humberto 1.3
162 @param - None.
163 @return - Boolean.
164 @throws - None.
165 <I><B>Experimental Interface</B></I><BR>
166 */
|
167 chuck 1.2 Boolean getInverted()const;
168
|
169 humberto 1.3 /**
170 Sets the inverted flag. Logically NOTting this predicate.
|
171 david.dillard 1.7
|
172 humberto 1.3 @param - None.
173 @return - None.
174 @throws - None.
175 <I><B>Experimental Interface</B></I><BR>
176 */
|
177 humberto 1.5 void setInverted(Boolean invert);
|
178 chuck 1.2
|
179 humberto 1.3 /**
|
180 david.dillard 1.7 Appends a predicate to the predicate array. This method should only
|
181 humberto 1.3 be called by Bison.
182
183 @param - inPredicate.
184 @return - None.
185 @throws - None.
186 <I><B>Experimental Interface</B></I><BR>
187 */
188 void appendPredicate(const CQLPredicate& inPredicate);
|
189 chuck 1.2
|
190 humberto 1.3 /**
191 Appends a predicate to the predicate array. This method should only
192 be called by Bison.
|
193 humberto 1.4
|
194 humberto 1.3 @param - inPredicate.
195 @param - inBooleanOperator
196 @return - None.
197 @throws - None.
198 <I><B>Experimental Interface</B></I><BR>
199 */
|
200 chuck 1.2 void appendPredicate(const CQLPredicate& inPredicate, BooleanOpType inBooleanOperator);
|
201 david.dillard 1.7
|
202 humberto 1.3 /**
203 Gets the CQLPredicates contained within this CQLPredicate.
|
204 humberto 1.4
|
205 humberto 1.3 @param - None.
|
206 david.dillard 1.7 @return - Array<CQLPredicate>.
|
207 humberto 1.3 @throws - None.
208 <I><B>Experimental Interface</B></I><BR>
209 */
|
210 chuck 1.2 Array<CQLPredicate> getPredicates()const;
|
211 david.dillard 1.7
|
212 humberto 1.3 /**
213 Gets the CQLSimplePredicate contained within this CQLPredicate. Only valid
214 if this isSimple() = true.
|
215 humberto 1.4
|
216 humberto 1.3 @param - None.
217 @return - CQLSimplePredicate.
218 @throws - None.
219 <I><B>Experimental Interface</B></I><BR>
220 */
|
221 chuck 1.2 CQLSimplePredicate getSimplePredicate()const;
|
222 david.dillard 1.7
|
223 humberto 1.3 /**
224 Gets the Operators for this CQLPredicate.
225 Given P1 AND P2 OR P3, this would return [AND][OR]
|
226 david.dillard 1.7
|
227 humberto 1.3 @param - None.
228 @return - Array<BooleanOpType>.
229 @throws - None.
230 <I><B>Experimental Interface</B></I><BR>
231 */
|
232 chuck 1.2 Array<BooleanOpType> getOperators()const;
|
233 david.dillard 1.7
|
234 humberto 1.3 /**
235 This method normalizes the CQLChainedIdentifier so that properties that require
236 scoping are scoped.
|
237 humberto 1.4
|
238 humberto 1.3 @param - queryContext.
239 @return - None.
240 @throws - None.
241 <I><B>Experimental Interface</B></I><BR>
242 */
|
243 vijay.eli 1.8 void applyContext(const QueryContext& queryContext);
|
244 chuck 1.2
|
245 humberto 1.3 /**
|
246 humberto 1.4 Returns true if this CQLPredicate contains no CQLPredicates,
247 ie. only has one CQLSimplePredicate.
248
|
249 humberto 1.3 @param - None.
250 @return - Boolean.
251 @throws - None.
252 <I><B>Experimental Interface</B></I><BR>
253 */
|
254 chuck 1.2 Boolean isSimple()const;
255
|
256 humberto 1.3 /**
|
257 humberto 1.4 Returns true if this CQLPredicate is simple and the contained
258 CQLSimplePredicate is a simple value (isSimpleValue( ) returns
259 true).
|
260 david.dillard 1.7
|
261 humberto 1.3 @param - None.
262 @return - Boolean.
263 @throws - None.
264 <I><B>Experimental Interface</B></I><BR>
265 */
|
266 chuck 1.2 Boolean isSimpleValue()const;
267
|
268 humberto 1.4 /**
269 Returns this predicate in string form.
|
270 david.dillard 1.7
|
271 humberto 1.4 @param - None.
272 @return - string form of predicate.
273 @throws - None.
274 <I><B>Experimental Interface</B></I><BR>
275 */
|
276 chuck 1.2 String toString()const;
277
|
278 humberto 1.3 /**
279 Operator=
|
280 humberto 1.4
|
281 humberto 1.3 @param - rhs. Right hand side of assignment operator.
282 @return - CQLPredicate&.
283 @throws - None.
284 <I><B>Experimental Interface</B></I><BR>
285 */
|
286 chuck 1.2 CQLPredicate& operator=(const CQLPredicate& rhs);
287
288 friend class CQLFactory;
289 private:
|
290 david.dillard 1.7 CQLPredicateRep* _rep;
|
291 chuck 1.2
292 };
293
294 /*
295 #ifndef PEGASUS_ARRAY_T
296 #define PEGASUS_ARRAY_T CQLPredicate
297 #include <Pegasus/Common/ArrayInter.h>
298 #undef PEGASUS_ARRAY_T
299 #endif
300 */
301
302 PEGASUS_NAMESPACE_END
303 #endif
|
304 david.dillard 1.7 #endif
|