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 Returns a CIMPropertyList containing the selected properties.
136 The list is NULL if the query selects all properties (SELECT * FROM...).
137 */
138 const CIMPropertyList getSelectPropertyList() const;
139
140 /** Appends a property name to the property name list. The user should
|
141 mike 1.2 not call this method; it should only be called by the parser.
142 */
|
143 chuck 1.11 void appendSelectPropertyName(const CIMName& x);
|
144 mike 1.2
145 /** Returns the number of unique property names from the where clause.
146 */
|
147 chuck 1.11 Uint32 getWherePropertyNameCount() const;
|
148 mike 1.2
149 /** Gets the i-th unique property appearing in the where clause.
150 */
|
151 chuck 1.11 const CIMName& getWherePropertyName(Uint32 i) const;
|
152 mike 1.2
|
153 kumpf 1.6 /**
154 Returns a CIMPropertyList containing the unique properties used in the
155 WHERE clause
156 */
157 const CIMPropertyList getWherePropertyList() const;
158
159 /** Appends a property name to the where property name list. The user
|
160 mike 1.2 should not call this method; it should only be called by the parser.
161
162 @param x name of the property.
163 @return false if a property with that name already exists.
164 */
|
165 kumpf 1.6 Boolean appendWherePropertyName(const CIMName& x);
|
166 mike 1.2
167 /** Appends an operation to the operation array. This method should only
168 be called by the parser itself.
169 */
|
170 chuck 1.11 void appendOperation(WQLOperation x);
|
171 mike 1.2
172 /** Appends an operand to the operation array. This method should only
173 be called by the parser itself.
174 */
|
175 chuck 1.11 void appendOperand(const WQLOperand& x);
|
176 mike 1.2
177 /** Returns true if this class has a where clause.
178 */
|
179 chuck 1.11 Boolean hasWhereClause() const;
|
180 mike 1.2
181 /** Evalautes the where clause using the symbol table to resolve symbols.
182 */
183 Boolean evaluateWhereClause(const WQLPropertySource* source) const;
184
|
185 schuur 1.9 /** Inspect an instance and remove properties not listed in Select projection.
186 */
|
187 chuck 1.11 void applyProjection(CIMInstance& inst) throw (Exception);
|
188 schuur 1.9 void applyProjection(CIMObject& inst);
189
|
190 mike 1.2 /** Prints out the members of this class.
191 */
192 void print() const;
193
|
194 schuur 1.9 static const WQLSelectStatement EMPTY;
|
195 chuck 1.11
196 Boolean evaluate(const CIMInstance& inCI);
197
198 void validate() throw (Exception);
199
200 CIMPropertyList getPropertyList(const CIMObjectPath& inClassName = CIMObjectPath());
201
202 Array<CIMObjectPath> getClassPathList();
203
|
204 mike 1.2 private:
205
|
206 chuck 1.11 WQLSelectStatementRep* _rep;
|
207 mike 1.2
|
208 chuck 1.11 //void f() const { }
|
209 schuur 1.8
210 friend class CMPI_Wql2Dnf;
|
211 mike 1.2 };
212
213 PEGASUS_NAMESPACE_END
214
215 #endif /* Pegasus_WQLSelectStatement_h */
|