1 karl 1.5 //%2006////////////////////////////////////////////////////////////////////////
|
2 chuck 1.1 //
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 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
8 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
|
9 karl 1.2 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
10 // EMC Corporation; VERITAS Software Corporation; The Open Group.
|
11 karl 1.5 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
12 // EMC Corporation; Symantec Corporation; The Open Group.
|
13 chuck 1.1 //
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.5 //
|
21 chuck 1.1 // 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 // Author: Mike Brasher (mbrasher@bmc.com)
33 //
34 // Modified By: Carol Ann Krug Graves, Hewlett-Packard Company
|
35 david.dillard 1.4 // (carolann_graves@hp.com)
36 // David Dillard, VERITAS Software Corp.
37 // (david.dillard@veritas.com)
|
38 chuck 1.1 //
39 //%/////////////////////////////////////////////////////////////////////////////
40
41 #ifndef Pegasus_WQLSelectStatementRep_h
42 #define Pegasus_WQLSelectStatementRep_h
43
44 #include <Pegasus/Common/Config.h>
45 #include <Pegasus/WQL/Linkage.h>
46 #include <Pegasus/Common/ArrayInternal.h>
47 #include <Pegasus/Common/CIMName.h>
48 #include <Pegasus/Common/CIMPropertyList.h>
49 #include <Pegasus/Common/CIMInstance.h>
50 #include <Pegasus/Common/CIMObject.h>
51 #include <Pegasus/WQL/WQLOperation.h>
52 #include <Pegasus/WQL/WQLOperand.h>
53 #include <Pegasus/WQL/WQLPropertySource.h>
54 #include <Pegasus/Query/QueryCommon/QueryContext.h>
55 #include <Pegasus/Query/QueryCommon/SelectStatementRep.h>
56
57 PEGASUS_NAMESPACE_BEGIN
58
|
59 mike 1.6 class WQLSelectStatementRep: public SelectStatementRep
|
60 chuck 1.1 {
61 public:
|
62 david.dillard 1.4
|
63 chuck 1.1
64 WQLSelectStatementRep(String& queryLang, String& query);
65
66 WQLSelectStatementRep(String& queryLang, String& query, QueryContext& inCtx);
67
|
68 david.dillard 1.4 /** Default constructor.
|
69 chuck 1.1 */
70 WQLSelectStatementRep();
71
72 WQLSelectStatementRep(const WQLSelectStatementRep& rep);
73
74 /** Destructor.
75 */
76 ~WQLSelectStatementRep();
77
78 /** Clears all data members of this object.
79 */
80 void clear();
81
82 /** Accessor.
83 */
84 const CIMName& getClassName() const
85 {
86 return _className;
87 }
88
89 /** Modifier. This method should not be called by the user (only by the
90 chuck 1.1 parser).
91 */
92 void setClassName(const CIMName& className)
93 {
94 _className = className;
95 }
96
|
97 david.dillard 1.4 /**
|
98 chuck 1.1 Returns true if the query selects all properties ("*")
99 */
100 Boolean getAllProperties() const;
101
|
102 david.dillard 1.4 /**
|
103 chuck 1.1 Used by the parser to indicate the query selects all properties ("*")
104 This method should not be called by the user (only by the parser).
105 */
106 void setAllProperties(const Boolean allProperties);
107
108 /** Returns the number of property names which were indicated in the
109 selection list.
110 This function should only be used if getAllProperties() returns false.
111 */
112 Uint32 getSelectPropertyNameCount() const
113 {
114 return _selectPropertyNames.size();
115 }
116
117 /** Gets the i-th selected property name in the list.
118 This function should only be used if getAllProperties() returns false.
119 */
120 const CIMName& getSelectPropertyName(Uint32 i) const
121 {
122 return _selectPropertyNames[i];
123 }
124 chuck 1.1
|
125 david.dillard 1.4 /**
|
126 chuck 1.1 Returns a CIMPropertyList containing the selected properties.
127 The list is NULL if the query selects all properties (SELECT * FROM...).
128 */
|
129 carolann.graves 1.3 const CIMPropertyList getSelectPropertyList
130 (const CIMObjectPath& inClassName) const;
|
131 chuck 1.1
132 /** Appends a property name to the property name list. The user should
133 not call this method; it should only be called by the parser.
134 */
135 void appendSelectPropertyName(const CIMName& x)
136 {
137 _selectPropertyNames.append(x);
138 }
139
140 /** Returns the number of unique property names from the where clause.
141 */
142 Uint32 getWherePropertyNameCount() const
143 {
144 return _wherePropertyNames.size();
145 }
146
147 /** Gets the i-th unique property appearing in the where clause.
148 */
149 const CIMName& getWherePropertyName(Uint32 i) const
150 {
151 return _wherePropertyNames[i];
152 chuck 1.1 }
153
|
154 david.dillard 1.4 /**
155 Returns a CIMPropertyList containing the unique properties used in the
|
156 chuck 1.1 WHERE clause
157 */
|
158 carolann.graves 1.3 const CIMPropertyList getWherePropertyList
159 (const CIMObjectPath& inClassName) const;
|
160 chuck 1.1
|
161 david.dillard 1.4 /** Appends a property name to the where property name list. The user
|
162 chuck 1.1 should not call this method; it should only be called by the parser.
163
164 @param x name of the property.
165 @return false if a property with that name already exists.
166 */
167 Boolean appendWherePropertyName(const CIMName& x);
168
169 /** Appends an operation to the operation array. This method should only
170 be called by the parser itself.
171 */
172 void appendOperation(WQLOperation x)
173 {
174 _operations.append(x);
175 }
176
177 /** Appends an operand to the operation array. This method should only
178 be called by the parser itself.
179 */
180 void appendOperand(const WQLOperand& x)
181 {
182 _operands.append(x);
183 chuck 1.1 }
184
185 /** Returns true if this class has a where clause.
186 */
187 Boolean hasWhereClause() const
188 {
189 return _operations.size() != 0;
190 }
191
192 /** Evalautes the where clause using the symbol table to resolve symbols.
193 */
194 Boolean evaluateWhereClause(const WQLPropertySource* source) const;
195
196 /** Inspect an instance and remove properties not listed in Select projection.
197 */
|
198 carolann.graves 1.3 void applyProjection(CIMInstance& inst,
|
199 david.dillard 1.4 Boolean allowMissing);
|
200 carolann.graves 1.3 void applyProjection(CIMObject& inst,
201 Boolean allowMissing);
|
202 david.dillard 1.4
|
203 chuck 1.1 /** Prints out the members of this class.
204 */
205 void print() const;
206
207 //static const WQLSelectStatement EMPTY;
208
209 Boolean evaluate(const CIMInstance& inCI);
210
|
211 david.dillard 1.4 void validate();
|
212 chuck 1.1
213 CIMPropertyList getPropertyList(const CIMObjectPath& inClassName);
214
215 Array<CIMObjectPath> getClassPathList();
216
217 private:
218
219 //
220 // The name of the target class. For example:
221 //
|
222 david.dillard 1.4 // SELECT *
|
223 chuck 1.1 // FROM TargetClass
224 // WHERE ...
225 //
226
227 CIMName _className;
228
229 //
230 // Indicates that all properties are selected (i.e. SELECT * FROM ...)
231 //
232 Boolean _allProperties;
233
234 //
235 // The list of property names being selected. For example, see "firstName",
236 // and "lastName" below.
237 //
|
238 david.dillard 1.4 // SELECT firstName, lastName
|
239 chuck 1.1 // FROM TargetClass
240 // WHERE ...
241 //
|
242 david.dillard 1.4 // NOTE: if the query selects all properties, this list is empty, and
|
243 chuck 1.1 // _allProperties is true
244 //
|
245 david.dillard 1.4 // NOTE: duplicate property names are not removed from the select list
246 // (e.g. SELECT firstName, firstName FROM...) results in a list of
|
247 chuck 1.1 // two properties
248 //
249
250 Array<CIMName> _selectPropertyNames;
251
252 //
253 // The unique list of property names appearing in the WHERE clause.
254 // Although a property may occur many times in the WHERE clause, it will
255 // only appear once in this list.
256 //
257
258 Array<CIMName> _wherePropertyNames;
259
260 //
261 // The list of operations encountered while parsing the WHERE clause.
262 // Consider this query:
263 //
264 // SELECT *
265 // FROM TargetClass
266 // WHERE count > 10 OR peak < 20 AND state = "OKAY"
267 //
268 chuck 1.1 // This would generate the following stream of WQLOperations:
269 //
270 // WQL_GT
271 // WQL_LT
272 // WQL_EQ
273 // WQL_AND
274 // WQL_OR
275 //
276
277 Array<WQLOperation> _operations;
278
|
279 david.dillard 1.4 //
|
280 chuck 1.1 // The list of operands encountered while parsing the WHERE clause. The
281 // query just above would generate the following stream of operands:
282 //
283 // count, 10, peak, 20, state, "OKAY"
284 //
285
286 Array<WQLOperand> _operands;
287
288 void f() const { }
|
289 david.dillard 1.4
|
290 chuck 1.1 friend class CMPI_Wql2Dnf;
291 };
292
293 PEGASUS_NAMESPACE_END
294
295 #endif /* Pegasus_WQLSelectStatementRep_h */
|