1 karl 1.7 //%2006////////////////////////////////////////////////////////////////////////
|
2 chuck 1.3 //
|
3 karl 1.5 // 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 chuck 1.3 // IBM Corp.; EMC Corporation, The Open Group.
|
7 karl 1.5 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
8 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
9 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
10 // EMC Corporation; VERITAS Software Corporation; The Open Group.
|
11 karl 1.7 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
12 // EMC Corporation; Symantec Corporation; The Open Group.
|
13 chuck 1.3 //
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.7 //
|
21 chuck 1.3 // 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 //%/////////////////////////////////////////////////////////////////////////////
33
|
34 humberto 1.1 #ifndef Pegasus_CQLFactory_h
35 #define Pegasus_CQLFactory_h
|
36 david.dillard 1.6
37 #include <Pegasus/CQL/Linkage.h>
|
38 chuck 1.3 #include <Pegasus/Common/ArrayInternal.h>
|
39 humberto 1.1 #include <Pegasus/CQL/CQLValue.h>
40 #include <Pegasus/CQL/CQLChainedIdentifier.h>
|
41 chuck 1.3 //#include <Pegasus/CQL/CQLSelectStatement.h>
|
42 humberto 1.1 #include <Pegasus/CQL/CQLPredicate.h>
43 #include <Pegasus/CQL/CQLSimplePredicate.h>
44 #include <Pegasus/CQL/CQLIdentifier.h>
|
45 chuck 1.3
|
46 humberto 1.1 #include <Pegasus/CQL/CQLTerm.h>
47 #include <Pegasus/CQL/CQLFactor.h>
|
48 chuck 1.3 //#include <Pegasus/CQL/CQLParserState.h>
|
49 humberto 1.1 #include <Pegasus/CQL/CQLExpression.h>
|
50 chuck 1.3 #include <Pegasus/CQL/CQLFunction.h>
51
52 #ifdef PEGASUS_USE_EXPERIMENTAL_INTERFACES
|
53 humberto 1.1
54 PEGASUS_NAMESPACE_BEGIN
55
|
56 chuck 1.3 typedef struct CQLObjectPtr {
57 void* _ptr;
58 } CQLOBJECTPTR;
59
60 /*
61 #ifndef PEGASUS_ARRAY_T
62 #define PEGASUS_ARRAY_T CQLObjectPtr
63 #include <Pegasus/Common/ArrayInter.h>
64 #undef PEGASUS_ARRAY_T
65 #endif
66 */
67
|
68 david.dillard 1.6 enum FactoryType { Identifier, ChainedIdentifier, Value, Function,
69 Factor, Term, Expression, SimplePredicate, Predicate };
|
70 humberto 1.1
|
71 humberto 1.4 /**
|
72 david.dillard 1.6 The CQLFactory class enables the user to construct and access complex
73 CQL objects from simple objects without having to call each constructor
74 or each getter in the CQL object tree.
|
75 humberto 1.4
76 Three uses:
|
77 david.dillard 1.6 makeObject - allows the caller to pass in a CQL object and a target
78 object type. This returns the target type built from the initial
79 object.
80
81 getObject - allows caller to pass in a CQL object and target query
82 object type. This returns the target type contained within the CQL
83 object passed in.
|
84 humberto 1.4
|
85 david.dillard 1.6 setObject - allows caller to pass in a CQLPredicate, and object to
86 set into the CQlPredicate and its type.
|
87 humberto 1.4 */
88
|
89 mike 1.8 class CQLFactory
|
90 humberto 1.1 {
91 public:
|
92 chuck 1.3 //CQLFactory();
93 ~CQLFactory();
|
94 humberto 1.4
95 /**
96 Makes a target type object from a CQLIdentifier
|
97 david.dillard 1.6
|
98 humberto 1.4 @param - obj. The CQLIdentifier to make the object from
99 @param - target. The target type of the object to be constructed.
|
100 david.dillard 1.6 @return - A CQL object of type target cast to a void*. Caller must
101 then cast to the appropriate type.
|
102 humberto 1.4 @throw - None.
103 <I><B>Experimental Interface</B></I><BR>
104 */
|
105 humberto 1.1 void* makeObject(CQLIdentifier* obj, FactoryType target);
|
106 humberto 1.4
107 /**
108 Makes a target type object from a CQLChainedIdentifier
|
109 david.dillard 1.6
|
110 humberto 1.4 @param - obj. The CQLChainedIdentifier to make the object from
111 @param - target. The target type of the object to be constructed.
|
112 david.dillard 1.6 @return - A CQL object of type target cast to a void*. Caller must
113 then cast to the appropriate type.
|
114 humberto 1.4 @throw - None.
115 <I><B>Experimental Interface</B></I><BR>
116 */
|
117 humberto 1.1 void* makeObject(CQLChainedIdentifier* obj, FactoryType target);
|
118 humberto 1.4
119 /**
120 Makes a target type object from a CQLValue
|
121 david.dillard 1.6
|
122 humberto 1.4 @param - obj. The CQLValue to make the object from
123 @param - target. The target type of the object to be constructed.
|
124 david.dillard 1.6 @return - A CQL object of type target cast to a void*. Caller must
125 then cast to the appropriate type.
|
126 humberto 1.4 @throw - None.
127 <I><B>Experimental Interface</B></I><BR>
128 */
|
129 humberto 1.1 void* makeObject(CQLValue* obj, FactoryType target);
|
130 humberto 1.4
131 /**
132 Makes a target type object from a CQLFactor
|
133 david.dillard 1.6
|
134 humberto 1.4 @param - obj. The CQLFactor to make the object from
135 @param - target. The target type of the object to be constructed.
|
136 david.dillard 1.6 @return - A CQL object of type target cast to a void*. Caller must
137 then cast to the appropriate type.
|
138 humberto 1.4 @throw - None.
139 <I><B>Experimental Interface</B></I><BR>
140 */
|
141 humberto 1.1 void* makeObject(CQLFactor* obj, FactoryType target);
|
142 humberto 1.4
143 /**
144 Makes a target type object from a CQLFunction
|
145 david.dillard 1.6
|
146 humberto 1.4 @param - obj. The CQLFunction to make the object from
147 @param - target. The target type of the object to be constructed.
|
148 david.dillard 1.6 @return - A CQL object of type target cast to a void*. Caller must
149 then cast to the appropriate type.
|
150 humberto 1.4 @throw - None.
151 <I><B>Experimental Interface</B></I><BR>
152 */
|
153 chuck 1.3 void* makeObject(CQLFunction* obj, FactoryType target);
|
154 humberto 1.4
155 /**
156 Makes a target type object from a CQLTerm
|
157 david.dillard 1.6
|
158 humberto 1.4 @param - obj. The CQLTerm to make the object from
159 @param - target. The target type of the object to be constructed.
|
160 david.dillard 1.6 @return - A CQL object of type target cast to a void*. Caller must
161 then cast to the appropriate type.
|
162 humberto 1.4 @throw - None.
163 <I><B>Experimental Interface</B></I><BR>
164 */
|
165 humberto 1.1 void* makeObject(CQLTerm* obj, FactoryType target);
|
166 humberto 1.4
167 /**
168 Makes a target type object from a CQLExpression
|
169 david.dillard 1.6
|
170 humberto 1.4 @param - obj. The CQLExpression to make the object from
171 @param - target. The target type of the object to be constructed.
|
172 david.dillard 1.6 @return - A CQL object of type target cast to a void*. Caller must
173 then cast to the appropriate type.
|
174 humberto 1.4 @throw - None.
175 <I><B>Experimental Interface</B></I><BR>
176 */
|
177 humberto 1.1 void* makeObject(CQLExpression* obj, FactoryType target);
|
178 humberto 1.4
179 /**
180 Makes a target type object from a CQLSimplePredicate
|
181 david.dillard 1.6
|
182 humberto 1.4 @param - obj. The CQLSimplePredicate to make the object from
183 @param - target. The target type of the object to be constructed.
|
184 david.dillard 1.6 @return - A CQL object of type target cast to a void*. Caller must
185 then cast to the appropriate type.
|
186 humberto 1.4 @throw - None.
187 <I><B>Experimental Interface</B></I><BR>
188 */
|
189 humberto 1.1 void* makeObject(CQLSimplePredicate* obj, FactoryType target);
|
190 david.dillard 1.6
|
191 humberto 1.4 /**
|
192 david.dillard 1.6 Returns an object of targetType contained within CQL object being
193 passed in.
194 This method is a general use method that internally calls one of the
195 specific getObject flavors.
196
|
197 humberto 1.4 @param - inObject. The object to extract the target type from.
198 @param - inObjectType. The target type of the object being passed in.
|
199 david.dillard 1.6 @param - targetType. The target type of the object to extract from the
200 CQL object passed in.
201 @return - A CQL object of type target cast to a void*. Caller must then
202 cast to the appropriate type.
|
203 humberto 1.4 @throw - None.
204 <I><B>Experimental Interface</B></I><BR>
205 */
|
206 karl 1.9 void* getObject(void* inObject, FactoryType inObjectType,
207 FactoryType targetType);
|
208 chuck 1.3
209 void* getObject(CQLChainedIdentifier* obj, FactoryType target);
210 void* getObject(CQLValue* obj, FactoryType target);
211 void* getObject(CQLFactor* obj, FactoryType target);
212 void* getObject(CQLTerm* obj, FactoryType target);
213 void* getObject(CQLExpression* obj, FactoryType target);
214 void* getObject(CQLSimplePredicate* obj, FactoryType target);
215 void* getObject(CQLPredicate* obj, FactoryType target);
|
216 david.dillard 1.6
|
217 humberto 1.4 /**
|
218 david.dillard 1.6 Sets an object of targetType into the CQLPredicate.
219 The caller may want to replace the CQLValue within the CQLPredicate.
220 This enables the caller to do this with one call.
221
|
222 humberto 1.4 @param - predicate. The CQLPredicate to set the target type object into.
223 @param - obj. The object to set into the CQLPredicate
224 @param - objType. The type of "obj"
225 @return - None.
226 @throw - None.
227 <I><B>Experimental Interface</B></I><BR>
228 */
|
229 chuck 1.3 void setObject(CQLPredicate* predicate, void* obj, FactoryType objType);
|
230 humberto 1.4
231
232 /**
|
233 david.dillard 1.6 Frees all memory allocated.
|
234 humberto 1.4
235 @param - None.
236 @return - None.
237 @throw - None.
238 <I><B>Experimental Interface</B></I><BR>
239 */
|
240 chuck 1.3 void cleanup();
|
241 david.dillard 1.6 private:
|
242 chuck 1.3 void cleanupArray(Array<CQLObjectPtr>& arr, FactoryType type);
243
244 Array<CQLObjectPtr> _makeObjectPredicates;
245 Array<CQLObjectPtr> _makeObjectSimplePredicates;
246 Array<CQLObjectPtr> _makeObjectExpressions;
247 Array<CQLObjectPtr> _makeObjectTerms;
248 Array<CQLObjectPtr> _makeObjectFactors;
249 Array<CQLObjectPtr> _makeObjectFunctions;
250 Array<CQLObjectPtr> _makeObjectValues;
251 Array<CQLObjectPtr> _makeObjectChainedIdentifiers;
252 Array<CQLObjectPtr> _makeObjectIdentifiers;
253
254 Array<CQLObjectPtr> _getObjectPredicates;
255 Array<CQLObjectPtr> _getObjectSimplePredicates;
256 Array<CQLObjectPtr> _getObjectExpressions;
257 Array<CQLObjectPtr> _getObjectTerms;
258 Array<CQLObjectPtr> _getObjectFactors;
259 Array<CQLObjectPtr> _getObjectFunctions;
260 Array<CQLObjectPtr> _getObjectValues;
261 Array<CQLObjectPtr> _getObjectChainedIdentifiers;
262 Array<CQLObjectPtr> _getObjectIdentifiers;
263 chuck 1.3
|
264 david.dillard 1.6 };
|
265 humberto 1.1 PEGASUS_NAMESPACE_END
266 #endif
|
267 chuck 1.3 #endif
|