1 chuck 1.2 //%2003////////////////////////////////////////////////////////////////////////
2 //
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 //
8 // Permission is hereby granted, free of charge, to any person obtaining a copy
9 // of this software and associated documentation files (the "Software"), to
10 // deal in the Software without restriction, including without limitation the
11 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12 // sell copies of the Software, and to permit persons to whom the Software is
13 // furnished to do so, subject to the following conditions:
14 //
15 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
16 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
17 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
18 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
19 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
21 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 chuck 1.2 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 //
24 //==============================================================================
25 //
26 // Authors: David Rosckes (rosckes@us.ibm.com)
27 // Bert Rivero (hurivero@us.ibm.com)
28 // Chuck Carmack (carmack@us.ibm.com)
29 // Brian Lucier (lucier@us.ibm.com)
30 //
31 // Modified By:
32 //
33 //%/////////////////////////////////////////////////////////////////////////////
34
35 #ifndef Pegasus_CQLSelectStatement_h
36 #define Pegasus_CQLSelectStatement_h
37
38 #include <Pegasus/Common/Config.h>
39 #include <Pegasus/Common/AutoPtr.h>
40 #include <Pegasus/Query/QueryCommon/SelectStatement.h>
41 #include <Pegasus/CQL/CQLChainedIdentifier.h>
42 #include <Pegasus/CQL/CQLPredicate.h>
43 chuck 1.2 #include <Pegasus/CQL/CQLIdentifier.h>
44 #include <Pegasus/CQL/Linkage.h>
45
46
47 #ifdef PEGASUS_USE_EXPERIMENTAL_INTERFACES
48
49 PEGASUS_NAMESPACE_BEGIN
50
51 class PEGASUS_CQL_LINKAGE CQLSelectStatementRep;
52
53 /**
54 This class is derived from the SelectStatement base class.
55 The purpose of this class is to perform the select statement operations for
56 CIM Query Language (CQL).
57
58 Notes on CQLSelectStatement class:
59
60 (A) Contains a CQLPredicate for the WHERE clause
61 (B) Contains an array of CQLIdentifiers for the SELECT projection
62 (C) Contains an array of classpaths from the FROM clause
63
64 chuck 1.2
65 */
66 class PEGASUS_CQL_LINKAGE CQLSelectStatement : public SelectStatement
67 {
68 public:
69 CQLSelectStatement();
70
71 /** This is the constructor for the CQLSelectStatement object.
72 The ctor requires 3 parameters:
73 query language (qlang) which is CQL,
74 the query itself,
75 and the name of the CIM namespace.
76 */
77 CQLSelectStatement(
78 /** The query language is needed so the
79 base class can retrieve the query language.
80 The class member variable where this data
81 is stored is located in the base SelectStatement
82 class.
83 */
84 String& inQlang,
85 chuck 1.2 /** input parameter containing the query string.
86 */
87 String& inQuery,
88
89 QueryContext& inCtx);
90
91 CQLSelectStatement(String& inQLang, String& inQuery);
92
93 CQLSelectStatement(const CQLSelectStatement& statement);
94
95 ~CQLSelectStatement();
96
97 CQLSelectStatement& operator=(const CQLSelectStatement& rhs);
98
99 void setQueryContext(QueryContext& inCtx);
100
101 /** Implements the evaluate method from the
102 base SelectStatement class.
103
104 */
105 Boolean evaluate(
106 chuck 1.2 /** The CIM instance that will be evaluated.
107 The CIMInstance object is not modified by this method.
108 */
109 const CIMInstance& inCI);
110
111 /** Implements the applyProjection method from the
112 base SelectStatement class.
113 */
114 void applyProjection(
115 /** Input the CIMInstance object in which to apply the
116 projection.
117 */
118 CIMInstance& inCI) throw(Exception);
119
120 /** Implements the validatedProperties method from the
121 base SelectStatement class.
122 */
123 void validate() throw(Exception);
124
125 /** Returns an array of CIMObjectPath objects that are the
126 class paths from the select statement in the FROM list.
127 chuck 1.2 */
128 Array<CIMObjectPath> getClassPathList();
129
130 /** Returns the required properties from the combined SELECT and WHERE
131 clauses for the classname passed in.
132
133 If all the properties for the input classname are required, a null
134 CIMPropertyList is returned.
135 */
136 CIMPropertyList getPropertyList(
137 /** The input parameter className is one of the
138 classes from the FROM list.
139 */
140 const CIMObjectPath& inClassName = CIMObjectPath());
141
142 CIMPropertyList getSelectPropertyList(
143 const CIMObjectPath& inClassName = CIMObjectPath());
144
145 CIMPropertyList getWherePropertyList(
146 const CIMObjectPath& inClassName = CIMObjectPath());
147
148 chuck 1.2 Array<CQLChainedIdentifier> getSelectChainedIdentifiers();
149
150 Array<CQLChainedIdentifier> getWhereChainedIdentifiers();
151
152 /** Modifier. This method should not be called by the user (only by the
153 parser).
154 Appends a CQLIdentifier to an array of CIMObjectPaths from the FROM
155 statement.
156 */
157 void appendClassPath(
158 /**
159 */
160 const CQLIdentifier& inIdentifier);
161
162 /** Sets a predicate into this object. This method should only
163 be called by Bison.
164 */
165 void setPredicate(const CQLPredicate& inPredicate);
166
167 /** Gets the top-level predicate contained by this object */
168 CQLPredicate getPredicate() const;
169 chuck 1.2
170 /** This method calls QueryContext::insertClassPathAlias() to insert a
171 classpath-alias pair
172 into the hash table. The record is keyed by the class alias.
173
174 This method is used by Bison.
175
176 TODO: think about exceptions such as duplicate key.
177 */
178 void insertClassPathAlias(
179 /** The CQLIdentifier object that contains the class path.
180 */
181 const CQLIdentifier& inIdentifier,
182 /** The alias for the class.
183 */
184 String inAlias);
185
186 /** Appends a CQL chained identifier to the CQL identifier list. The user
187 should
188 not call this method; it should only be called by the Bison.
189 */
190 chuck 1.2 void appendSelectIdentifier(const CQLChainedIdentifier& x);
191
192 /**
193 Applies the class contexts from the FROM list to the identifiers
194 in the statement.
195 */
196 void applyContext();
197
198 /**
199 Normalizes the WHERE clause to disjunction of conjunctions.
200 */
201 void normalizeToDOC();
202
203 void setHasWhereClause();
204
205 Boolean hasWhereClause();
206
207 String toString();
208
209 void clear();
210
211 chuck 1.2 private:
212 CQLSelectStatementRep* _rep;
213
214 };
215
216 PEGASUS_NAMESPACE_END
217 #endif
218 #endif
|