1 karl 1.12 //%2005////////////////////////////////////////////////////////////////////////
|
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 mike 1.2 //
12 // Permission is hereby granted, free of charge, to any person obtaining a copy
|
13 kumpf 1.4 // of this software and associated documentation files (the "Software"), to
14 // deal in the Software without restriction, including without limitation the
15 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
16 mike 1.2 // sell copies of the Software, and to permit persons to whom the Software is
17 // furnished to do so, subject to the following conditions:
18 //
|
19 kumpf 1.4 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
|
20 mike 1.2 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
21 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
22 kumpf 1.4 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
23 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
24 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
25 mike 1.2 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 //
28 //==============================================================================
29 //
30 // Author: Mike Brasher (mbrasher@bmc.com)
31 //
|
32 kumpf 1.6 // Modified By: Carol Ann Krug Graves, Hewlett-Packard Company
33 // (carolann_graves@hp.com)
|
34 mike 1.2 //
35 //%/////////////////////////////////////////////////////////////////////////////
36
37 #ifndef Pegasus_WQLSelectStatement_h
38 #define Pegasus_WQLSelectStatement_h
39
40 #include <Pegasus/Common/Config.h>
|
41 chuck 1.11 #include <Pegasus/WQL/Linkage.h>
|
42 kumpf 1.5 #include <Pegasus/Common/ArrayInternal.h>
|
43 kumpf 1.6 #include <Pegasus/Common/CIMName.h>
44 #include <Pegasus/Common/CIMPropertyList.h>
|
45 schuur 1.9 #include <Pegasus/Common/CIMInstance.h>
46 #include <Pegasus/Common/CIMObject.h>
|
47 mike 1.2 #include <Pegasus/WQL/WQLOperation.h>
48 #include <Pegasus/WQL/WQLOperand.h>
49 #include <Pegasus/WQL/WQLPropertySource.h>
|
50 chuck 1.11 #include <Pegasus/Query/QueryCommon/SelectStatement.h>
51 #include <Pegasus/Query/QueryCommon/QueryContext.h>
|
52 mike 1.2
53 PEGASUS_NAMESPACE_BEGIN
54
|
55 chuck 1.11
56 class PEGASUS_WQL_LINKAGE WQLSelectStatementRep;
57
|
58 mike 1.2 /** This class represents a compiled WQL1 select statement.
59
60 An instance of WQLSelectStatement is passed to WQLParser::parse() which
61 parses the WQL1 SELECT statement and initializes the WQLSelectStatement
62 instance. A WQL1 SELECT statement has the following form:
63
64 <pre>
65 SELECT <property>...
66 FROM <class name>
67 WHERE <where clause>
68 </pre>
69
70 There are methods for obtaining the various elements of the select
71 statement.
72
73 The components of the where clause are stored in two arrays: one for
74 operands and one for operators (these are placed in proper order by the
75 YACC parser). Evaluation is performed using a Boolean stack. See the
76 implementation of evaluateWhereClause() for details.
77 */
|
78 chuck 1.11 class PEGASUS_WQL_LINKAGE WQLSelectStatement: public SelectStatement
|
79 mike 1.2 {
80 public:
|
81 chuck 1.11
82
83 WQLSelectStatement(String& queryLang, String& query);
84
85 WQLSelectStatement(String& queryLang, String& query, QueryContext& inCtx);
|
86 mike 1.2
87 /** Default constructor.
88 */
89 WQLSelectStatement();
90
|
91 chuck 1.11 WQLSelectStatement(const WQLSelectStatement& statement);
92
|
93 mike 1.2 /** Destructor.
94 */
95 ~WQLSelectStatement();
96
|
97 chuck 1.11 WQLSelectStatement& operator=(const WQLSelectStatement& rhs);
98
|
99 mike 1.2 /** Clears all data members of this object.
100 */
101 void clear();
102
103 /** Accessor.
104 */
|
105 chuck 1.11 const CIMName& getClassName() const;
|
106 mike 1.2
107 /** Modifier. This method should not be called by the user (only by the
108 parser).
109 */
|
110 chuck 1.11 void setClassName(const CIMName& className);
|
111 mike 1.2
|
112 kumpf 1.6 /**
113 Returns true if the query selects all properties ("*")
114 */
115 Boolean getAllProperties() const;
116
117 /**
118 Used by the parser to indicate the query selects all properties ("*")
119 This method should not be called by the user (only by the parser).
120 */
121 void setAllProperties(const Boolean allProperties);
122
|
123 mike 1.2 /** Returns the number of property names which were indicated in the
124 selection list.
|
125 kumpf 1.6 This function should only be used if getAllProperties() returns false.
|
126 mike 1.2 */
|
127 chuck 1.11 Uint32 getSelectPropertyNameCount() const;
|
128 mike 1.2
129 /** Gets the i-th selected property name in the list.
|
130 kumpf 1.6 This function should only be used if getAllProperties() returns false.
|
131 mike 1.2 */
|
132 chuck 1.11 const CIMName& getSelectPropertyName(Uint32 i) const;
|
133 mike 1.2
|
134 kumpf 1.6 /**
|
135 carolann.graves 1.13 Returns the required properties from the SELECT clause for the specified
136 class.
137
138 @param inClassName name of the class; must be one of the classes from
139 the FROM clause
140
141 @return CIMPropertyList containing the required properties from the
142 SELECT clause for the specified class;
143 or a null CIMPropertyList if all properties of the specified
144 class are required
|
145 kumpf 1.6 */
|
146 carolann.graves 1.13 CIMPropertyList getSelectPropertyList
147 (const CIMObjectPath& inClassName = CIMObjectPath ());
|
148 kumpf 1.6
149 /** Appends a property name to the property name list. The user should
|
150 mike 1.2 not call this method; it should only be called by the parser.
151 */
|
152 chuck 1.11 void appendSelectPropertyName(const CIMName& x);
|
153 mike 1.2
154 /** Returns the number of unique property names from the where clause.
155 */
|
156 chuck 1.11 Uint32 getWherePropertyNameCount() const;
|
157 mike 1.2
158 /** Gets the i-th unique property appearing in the where clause.
159 */
|
160 chuck 1.11 const CIMName& getWherePropertyName(Uint32 i) const;
|
161 mike 1.2
|
162 kumpf 1.6 /**
|
163 carolann.graves 1.13 Returns the required properties from the WHERE clause for the specified
164 class.
165
166 @param inClassName name of the class; must be one of the classes from
167 the FROM clause
168
169 @return CIMPropertyList containing the required properties from the
170 WHERE clause for the specified class;
171 or a null CIMPropertyList if all properties of the specified
172 class are required
|
173 kumpf 1.6 */
|
174 carolann.graves 1.13 CIMPropertyList getWherePropertyList
175 (const CIMObjectPath& inClassName = CIMObjectPath ());
|
176 kumpf 1.6
177 /** Appends a property name to the where property name list. The user
|
178 mike 1.2 should not call this method; it should only be called by the parser.
179
180 @param x name of the property.
181 @return false if a property with that name already exists.
182 */
|
183 kumpf 1.6 Boolean appendWherePropertyName(const CIMName& x);
|
184 mike 1.2
185 /** Appends an operation to the operation array. This method should only
186 be called by the parser itself.
187 */
|
188 chuck 1.11 void appendOperation(WQLOperation x);
|
189 mike 1.2
190 /** Appends an operand to the operation array. This method should only
191 be called by the parser itself.
192 */
|
193 chuck 1.11 void appendOperand(const WQLOperand& x);
|
194 mike 1.2
195 /** Returns true if this class has a where clause.
196 */
|
197 chuck 1.11 Boolean hasWhereClause() const;
|
198 mike 1.2
199 /** Evalautes the where clause using the symbol table to resolve symbols.
200 */
201 Boolean evaluateWhereClause(const WQLPropertySource* source) const;
202
|
203 schuur 1.9 /** Inspect an instance and remove properties not listed in Select projection.
|
204 carolann.graves 1.13
205 @param allowMissing Boolean specifying whether missing project
206 properties are allowed
|
207 schuur 1.9 */
|
208 carolann.graves 1.13 void applyProjection(CIMInstance& inst,
209 Boolean allowMissing) throw (Exception);
210 void applyProjection(CIMObject& inst,
211 Boolean allowMissing);
|
212 schuur 1.9
|
213 mike 1.2 /** Prints out the members of this class.
214 */
215 void print() const;
216
|
217 schuur 1.9 static const WQLSelectStatement EMPTY;
|
218 chuck 1.11
219 Boolean evaluate(const CIMInstance& inCI);
220
221 void validate() throw (Exception);
222
223 CIMPropertyList getPropertyList(const CIMObjectPath& inClassName = CIMObjectPath());
224
225 Array<CIMObjectPath> getClassPathList();
226
|
227 mike 1.2 private:
228
|
229 chuck 1.11 WQLSelectStatementRep* _rep;
|
230 mike 1.2
|
231 chuck 1.11 //void f() const { }
|
232 schuur 1.8
233 friend class CMPI_Wql2Dnf;
|
234 mike 1.2 };
235
236 PEGASUS_NAMESPACE_END
237
238 #endif /* Pegasus_WQLSelectStatement_h */
|