1 martin 1.10 //%LICENSE////////////////////////////////////////////////////////////////
|
2 martin 1.11 //
|
3 martin 1.10 // Licensed to The Open Group (TOG) under one or more contributor license
4 // agreements. Refer to the OpenPegasusNOTICE.txt file distributed with
5 // this work for additional information regarding copyright ownership.
6 // Each contributor licenses this file to you under the OpenPegasus Open
7 // Source License; you may not use this file except in compliance with the
8 // License.
|
9 martin 1.11 //
|
10 martin 1.10 // Permission is hereby granted, free of charge, to any person obtaining a
11 // copy of this software and associated documentation files (the "Software"),
12 // to deal in the Software without restriction, including without limitation
13 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
14 // and/or sell copies of the Software, and to permit persons to whom the
15 // Software is furnished to do so, subject to the following conditions:
|
16 martin 1.11 //
|
17 martin 1.10 // The above copyright notice and this permission notice shall be included
18 // in all copies or substantial portions of the Software.
|
19 martin 1.11 //
|
20 martin 1.10 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
21 martin 1.11 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
22 martin 1.10 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23 // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
24 // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
25 // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
26 // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
27 martin 1.11 //
|
28 martin 1.10 //////////////////////////////////////////////////////////////////////////
|
29 chuck 1.1 //
30 //%/////////////////////////////////////////////////////////////////////////////
31
32 #ifndef Pegasus_WQLSelectStatementRep_h
33 #define Pegasus_WQLSelectStatementRep_h
34
35 #include <Pegasus/Common/Config.h>
36 #include <Pegasus/WQL/Linkage.h>
37 #include <Pegasus/Common/ArrayInternal.h>
38 #include <Pegasus/Common/CIMName.h>
39 #include <Pegasus/Common/CIMPropertyList.h>
40 #include <Pegasus/Common/CIMInstance.h>
41 #include <Pegasus/Common/CIMObject.h>
42 #include <Pegasus/WQL/WQLOperation.h>
43 #include <Pegasus/WQL/WQLOperand.h>
44 #include <Pegasus/WQL/WQLPropertySource.h>
45 #include <Pegasus/Query/QueryCommon/QueryContext.h>
46 #include <Pegasus/Query/QueryCommon/SelectStatementRep.h>
47
48 PEGASUS_NAMESPACE_BEGIN
49
|
50 mike 1.6 class WQLSelectStatementRep: public SelectStatementRep
|
51 chuck 1.1 {
52 public:
|
53 david.dillard 1.4
|
54 kumpf 1.9 WQLSelectStatementRep(
55 const String& queryLang,
56 const String& query);
57
58 WQLSelectStatementRep(
59 const String& queryLang,
60 const String& query,
61 const QueryContext& inCtx);
|
62 chuck 1.1
|
63 david.dillard 1.4 /** Default constructor.
|
64 chuck 1.1 */
65 WQLSelectStatementRep();
66
67 WQLSelectStatementRep(const WQLSelectStatementRep& rep);
68
69 /** Destructor.
70 */
71 ~WQLSelectStatementRep();
72
73 /** Clears all data members of this object.
74 */
75 void clear();
76
77 /** Accessor.
78 */
79 const CIMName& getClassName() const
80 {
|
81 karl 1.7 return _className;
|
82 chuck 1.1 }
83
84 /** Modifier. This method should not be called by the user (only by the
|
85 karl 1.7 parser).
|
86 chuck 1.1 */
87 void setClassName(const CIMName& className)
88 {
|
89 karl 1.7 _className = className;
|
90 chuck 1.1 }
91
|
92 david.dillard 1.4 /**
|
93 chuck 1.1 Returns true if the query selects all properties ("*")
94 */
95 Boolean getAllProperties() const;
96
|
97 david.dillard 1.4 /**
|
98 chuck 1.1 Used by the parser to indicate the query selects all properties ("*")
99 This method should not be called by the user (only by the parser).
100 */
101 void setAllProperties(const Boolean allProperties);
102
103 /** Returns the number of property names which were indicated in the
|
104 karl 1.7 selection list.
|
105 chuck 1.1 This function should only be used if getAllProperties() returns false.
106 */
107 Uint32 getSelectPropertyNameCount() const
108 {
|
109 karl 1.7 return _selectPropertyNames.size();
|
110 chuck 1.1 }
111
112 /** Gets the i-th selected property name in the list.
113 This function should only be used if getAllProperties() returns false.
114 */
115 const CIMName& getSelectPropertyName(Uint32 i) const
116 {
|
117 karl 1.7 return _selectPropertyNames[i];
|
118 chuck 1.1 }
119
|
120 david.dillard 1.4 /**
|
121 chuck 1.1 Returns a CIMPropertyList containing the selected properties.
122 The list is NULL if the query selects all properties (SELECT * FROM...).
123 */
|
124 kumpf 1.8 const CIMPropertyList getSelectPropertyList(
125 const CIMObjectPath& inClassName) const;
|
126 chuck 1.1
127 /** Appends a property name to the property name list. The user should
|
128 karl 1.7 not call this method; it should only be called by the parser.
|
129 chuck 1.1 */
130 void appendSelectPropertyName(const CIMName& x)
131 {
|
132 karl 1.7 _selectPropertyNames.append(x);
|
133 chuck 1.1 }
134
135 /** Returns the number of unique property names from the where clause.
136 */
137 Uint32 getWherePropertyNameCount() const
138 {
|
139 karl 1.7 return _wherePropertyNames.size();
|
140 chuck 1.1 }
141
142 /** Gets the i-th unique property appearing in the where clause.
143 */
144 const CIMName& getWherePropertyName(Uint32 i) const
145 {
|
146 karl 1.7 return _wherePropertyNames[i];
|
147 chuck 1.1 }
148
|
149 david.dillard 1.4 /**
150 Returns a CIMPropertyList containing the unique properties used in the
|
151 chuck 1.1 WHERE clause
152 */
|
153 kumpf 1.8 const CIMPropertyList getWherePropertyList(
154 const CIMObjectPath& inClassName) const;
|
155 chuck 1.1
|
156 david.dillard 1.4 /** Appends a property name to the where property name list. The user
|
157 karl 1.7 should not call this method; it should only be called by the parser.
|
158 chuck 1.1
|
159 karl 1.7 @param x name of the property.
160 @return false if a property with that name already exists.
|
161 chuck 1.1 */
162 Boolean appendWherePropertyName(const CIMName& x);
163
164 /** Appends an operation to the operation array. This method should only
|
165 karl 1.7 be called by the parser itself.
|
166 chuck 1.1 */
167 void appendOperation(WQLOperation x)
168 {
|
169 karl 1.7 _operations.append(x);
|
170 chuck 1.1 }
171
172 /** Appends an operand to the operation array. This method should only
|
173 karl 1.7 be called by the parser itself.
|
174 chuck 1.1 */
175 void appendOperand(const WQLOperand& x)
176 {
|
177 karl 1.7 _operands.append(x);
|
178 chuck 1.1 }
179
180 /** Returns true if this class has a where clause.
181 */
182 Boolean hasWhereClause() const
183 {
|
184 karl 1.7 return _operations.size() != 0;
|
185 chuck 1.1 }
186
187 /** Evalautes the where clause using the symbol table to resolve symbols.
188 */
189 Boolean evaluateWhereClause(const WQLPropertySource* source) const;
190
|
191 karl 1.7 /** Inspect an instance and remove properties not listed in Select
192 projection.
|
193 chuck 1.1 */
|
194 carolann.graves 1.3 void applyProjection(CIMInstance& inst,
|
195 david.dillard 1.4 Boolean allowMissing);
|
196 carolann.graves 1.3 void applyProjection(CIMObject& inst,
197 Boolean allowMissing);
|
198 david.dillard 1.4
|
199 chuck 1.1 /** Prints out the members of this class.
200 */
201 void print() const;
202
203 Boolean evaluate(const CIMInstance& inCI);
204
|
205 david.dillard 1.4 void validate();
|
206 chuck 1.1
207 CIMPropertyList getPropertyList(const CIMObjectPath& inClassName);
208
|
209 kumpf 1.8 Array<CIMObjectPath> getClassPathList() const;
|
210 chuck 1.1
211 private:
212
213 //
214 // The name of the target class. For example:
215 //
|
216 david.dillard 1.4 // SELECT *
|
217 chuck 1.1 // FROM TargetClass
218 // WHERE ...
219 //
220
221 CIMName _className;
222
223 //
224 // Indicates that all properties are selected (i.e. SELECT * FROM ...)
225 //
226 Boolean _allProperties;
227
228 //
229 // The list of property names being selected. For example, see "firstName",
230 // and "lastName" below.
231 //
|
232 david.dillard 1.4 // SELECT firstName, lastName
|
233 chuck 1.1 // FROM TargetClass
234 // WHERE ...
235 //
|
236 david.dillard 1.4 // NOTE: if the query selects all properties, this list is empty, and
|
237 chuck 1.1 // _allProperties is true
238 //
|
239 david.dillard 1.4 // NOTE: duplicate property names are not removed from the select list
240 // (e.g. SELECT firstName, firstName FROM...) results in a list of
|
241 chuck 1.1 // two properties
242 //
243
244 Array<CIMName> _selectPropertyNames;
245
246 //
247 // The unique list of property names appearing in the WHERE clause.
248 // Although a property may occur many times in the WHERE clause, it will
249 // only appear once in this list.
250 //
251
252 Array<CIMName> _wherePropertyNames;
253
254 //
255 // The list of operations encountered while parsing the WHERE clause.
256 // Consider this query:
257 //
258 // SELECT *
259 // FROM TargetClass
260 // WHERE count > 10 OR peak < 20 AND state = "OKAY"
261 //
262 chuck 1.1 // This would generate the following stream of WQLOperations:
263 //
264 // WQL_GT
265 // WQL_LT
266 // WQL_EQ
267 // WQL_AND
268 // WQL_OR
269 //
270
271 Array<WQLOperation> _operations;
272
|
273 david.dillard 1.4 //
|
274 chuck 1.1 // The list of operands encountered while parsing the WHERE clause. The
275 // query just above would generate the following stream of operands:
276 //
277 // count, 10, peak, 20, state, "OKAY"
278 //
279
280 Array<WQLOperand> _operands;
281
282 void f() const { }
|
283 david.dillard 1.4
|
284 chuck 1.1 friend class CMPI_Wql2Dnf;
285 };
286
287 PEGASUS_NAMESPACE_END
288
289 #endif /* Pegasus_WQLSelectStatementRep_h */
|