1 karl 1.15 //%2006////////////////////////////////////////////////////////////////////////
|
2 mike 1.2 //
|
3 karl 1.10 // 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 karl 1.7 // IBM Corp.; EMC Corporation, The Open Group.
|
7 karl 1.10 // 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.12 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
10 // EMC Corporation; VERITAS Software Corporation; The Open Group.
|
11 karl 1.15 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
12 // EMC Corporation; Symantec Corporation; The Open Group.
|
13 mike 1.2 //
14 // Permission is hereby granted, free of charge, to any person obtaining a copy
|
15 kumpf 1.4 // 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 mike 1.2 // 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.15 //
|
21 kumpf 1.4 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
|
22 mike 1.2 // 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 kumpf 1.4 // 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 mike 1.2 // 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 //
33 //%/////////////////////////////////////////////////////////////////////////////
34
35 #ifndef Pegasus_WQLSelectStatement_h
36 #define Pegasus_WQLSelectStatement_h
37
38 #include <Pegasus/Common/Config.h>
|
39 chuck 1.11 #include <Pegasus/WQL/Linkage.h>
|
40 kumpf 1.5 #include <Pegasus/Common/ArrayInternal.h>
|
41 kumpf 1.6 #include <Pegasus/Common/CIMName.h>
42 #include <Pegasus/Common/CIMPropertyList.h>
|
43 schuur 1.9 #include <Pegasus/Common/CIMInstance.h>
44 #include <Pegasus/Common/CIMObject.h>
|
45 mike 1.2 #include <Pegasus/WQL/WQLOperation.h>
46 #include <Pegasus/WQL/WQLOperand.h>
47 #include <Pegasus/WQL/WQLPropertySource.h>
|
48 chuck 1.11 #include <Pegasus/Query/QueryCommon/SelectStatement.h>
49 #include <Pegasus/Query/QueryCommon/QueryContext.h>
|
50 mike 1.2
51 PEGASUS_NAMESPACE_BEGIN
52
|
53 chuck 1.11
|
54 mike 1.16 class WQLSelectStatementRep;
|
55 chuck 1.11
|
56 david.dillard 1.14 /** This class represents a compiled WQL1 select statement.
|
57 mike 1.2
58 An instance of WQLSelectStatement is passed to WQLParser::parse() which
59 parses the WQL1 SELECT statement and initializes the WQLSelectStatement
60 instance. A WQL1 SELECT statement has the following form:
61
62 <pre>
|
63 karl 1.17 SELECT <property>...
64 FROM <class name>
65 WHERE <where clause>
|
66 mike 1.2 </pre>
67
68 There are methods for obtaining the various elements of the select
69 statement.
|
70 david.dillard 1.14
|
71 mike 1.2 The components of the where clause are stored in two arrays: one for
72 operands and one for operators (these are placed in proper order by the
73 YACC parser). Evaluation is performed using a Boolean stack. See the
74 implementation of evaluateWhereClause() for details.
75 */
|
76 chuck 1.11 class PEGASUS_WQL_LINKAGE WQLSelectStatement: public SelectStatement
|
77 mike 1.2 {
78 public:
|
79 david.dillard 1.14
|
80 chuck 1.11
81 WQLSelectStatement(String& queryLang, String& query);
82
83 WQLSelectStatement(String& queryLang, String& query, QueryContext& inCtx);
|
84 mike 1.2
|
85 david.dillard 1.14 /** Default constructor.
|
86 mike 1.2 */
87 WQLSelectStatement();
88
|
89 chuck 1.11 WQLSelectStatement(const WQLSelectStatement& statement);
90
|
91 mike 1.2 /** Destructor.
92 */
93 ~WQLSelectStatement();
94
|
95 chuck 1.11 WQLSelectStatement& operator=(const WQLSelectStatement& rhs);
96
|
97 mike 1.2 /** Clears all data members of this object.
98 */
99 void clear();
100
101 /** Accessor.
102 */
|
103 chuck 1.11 const CIMName& getClassName() const;
|
104 mike 1.2
105 /** Modifier. This method should not be called by the user (only by the
|
106 karl 1.17 parser).
|
107 mike 1.2 */
|
108 chuck 1.11 void setClassName(const CIMName& className);
|
109 mike 1.2
|
110 david.dillard 1.14 /**
|
111 kumpf 1.6 Returns true if the query selects all properties ("*")
112 */
113 Boolean getAllProperties() const;
114
|
115 david.dillard 1.14 /**
|
116 kumpf 1.6 Used by the parser to indicate the query selects all properties ("*")
117 This method should not be called by the user (only by the parser).
118 */
119 void setAllProperties(const Boolean allProperties);
120
|
121 mike 1.2 /** Returns the number of property names which were indicated in the
|
122 karl 1.17 selection list.
|
123 kumpf 1.6 This function should only be used if getAllProperties() returns false.
|
124 mike 1.2 */
|
125 chuck 1.11 Uint32 getSelectPropertyNameCount() const;
|
126 mike 1.2
127 /** Gets the i-th selected property name in the list.
|
128 kumpf 1.6 This function should only be used if getAllProperties() returns false.
|
129 mike 1.2 */
|
130 chuck 1.11 const CIMName& getSelectPropertyName(Uint32 i) const;
|
131 mike 1.2
|
132 david.dillard 1.14 /**
|
133 carolann.graves 1.13 Returns the required properties from the SELECT clause for the specified
134 class.
135
136 @param inClassName name of the class; must be one of the classes from
137 the FROM clause
138
139 @return CIMPropertyList containing the required properties from the
140 SELECT clause for the specified class;
141 or a null CIMPropertyList if all properties of the specified
142 class are required
|
143 kumpf 1.6 */
|
144 kumpf 1.18 CIMPropertyList getSelectPropertyList(
145 const CIMObjectPath& inClassName = CIMObjectPath());
|
146 kumpf 1.6
147 /** Appends a property name to the property name list. The user should
|
148 karl 1.17 not call this method; it should only be called by the parser.
|
149 mike 1.2 */
|
150 chuck 1.11 void appendSelectPropertyName(const CIMName& x);
|
151 mike 1.2
152 /** Returns the number of unique property names from the where clause.
153 */
|
154 chuck 1.11 Uint32 getWherePropertyNameCount() const;
|
155 mike 1.2
156 /** Gets the i-th unique property appearing in the where clause.
157 */
|
158 chuck 1.11 const CIMName& getWherePropertyName(Uint32 i) const;
|
159 mike 1.2
|
160 david.dillard 1.14 /**
|
161 carolann.graves 1.13 Returns the required properties from the WHERE clause for the specified
162 class.
163
164 @param inClassName name of the class; must be one of the classes from
165 the FROM clause
166
167 @return CIMPropertyList containing the required properties from the
168 WHERE clause for the specified class;
169 or a null CIMPropertyList if all properties of the specified
170 class are required
|
171 kumpf 1.6 */
|
172 kumpf 1.18 CIMPropertyList getWherePropertyList(
173 const CIMObjectPath& inClassName = CIMObjectPath());
|
174 kumpf 1.6
|
175 david.dillard 1.14 /** Appends a property name to the where property name list. The user
|
176 karl 1.17 should not call this method; it should only be called by the parser.
177
178 @param x name of the property.
179 @return false if a property with that name already exists.
|
180 mike 1.2 */
|
181 kumpf 1.6 Boolean appendWherePropertyName(const CIMName& x);
|
182 mike 1.2
183 /** Appends an operation to the operation array. This method should only
|
184 karl 1.17 be called by the parser itself.
|
185 mike 1.2 */
|
186 chuck 1.11 void appendOperation(WQLOperation x);
|
187 mike 1.2
188 /** Appends an operand to the operation array. This method should only
|
189 karl 1.17 be called by the parser itself.
|
190 mike 1.2 */
|
191 chuck 1.11 void appendOperand(const WQLOperand& x);
|
192 mike 1.2
193 /** Returns true if this class has a where clause.
194 */
|
195 chuck 1.11 Boolean hasWhereClause() const;
|
196 mike 1.2
197 /** Evalautes the where clause using the symbol table to resolve symbols.
198 */
199 Boolean evaluateWhereClause(const WQLPropertySource* source) const;
200
|
201 karl 1.17 /** Inspect an instance and remove properties not listed in Select
202 projection.
|
203 carolann.graves 1.13
204 @param allowMissing Boolean specifying whether missing project
205 properties are allowed
|
206 david.dillard 1.14 @exception Exception
|
207 schuur 1.9 */
|
208 kumpf 1.18 void applyProjection(
209 CIMInstance& inst,
|
210 david.dillard 1.14 Boolean allowMissing);
|
211 kumpf 1.18 void applyProjection(
212 CIMObject& inst,
|
213 carolann.graves 1.13 Boolean allowMissing);
|
214 david.dillard 1.14
|
215 mike 1.2 /** Prints out the members of this class.
216 */
217 void print() const;
218
|
219 schuur 1.9 static const WQLSelectStatement EMPTY;
|
220 chuck 1.11
221 Boolean evaluate(const CIMInstance& inCI);
222
|
223 david.dillard 1.14 void validate();
|
224 chuck 1.11
|
225 karl 1.17 CIMPropertyList getPropertyList(
226 const CIMObjectPath& inClassName = CIMObjectPath());
|
227 chuck 1.11
|
228 kumpf 1.18 Array<CIMObjectPath> getClassPathList() const;
|
229 chuck 1.11
|
230 mike 1.2 private:
231
|
232 chuck 1.11 WQLSelectStatementRep* _rep;
|
233 mike 1.2
|
234 chuck 1.11 //void f() const { }
|
235 david.dillard 1.14
|
236 schuur 1.8 friend class CMPI_Wql2Dnf;
|
237 mike 1.2 };
238
239 PEGASUS_NAMESPACE_END
240
241 #endif /* Pegasus_WQLSelectStatement_h */
|