1 martin 1.12 //%LICENSE////////////////////////////////////////////////////////////////
|
2 martin 1.13 //
|
3 martin 1.12 // Licensed to The Open Group (TOG) under one or more contributor license
4 // agreements. Refer to the OpenPegasusNOTICE.txt file distributed with
5 // this work for additional information regarding copyright ownership.
6 // Each contributor licenses this file to you under the OpenPegasus Open
7 // Source License; you may not use this file except in compliance with the
8 // License.
|
9 martin 1.13 //
|
10 martin 1.12 // Permission is hereby granted, free of charge, to any person obtaining a
11 // copy of this software and associated documentation files (the "Software"),
12 // to deal in the Software without restriction, including without limitation
13 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
14 // and/or sell copies of the Software, and to permit persons to whom the
15 // Software is furnished to do so, subject to the following conditions:
|
16 martin 1.13 //
|
17 martin 1.12 // The above copyright notice and this permission notice shall be included
18 // in all copies or substantial portions of the Software.
|
19 martin 1.13 //
|
20 martin 1.12 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
21 martin 1.13 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
22 martin 1.12 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23 // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
24 // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
25 // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
26 // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
27 martin 1.13 //
|
28 martin 1.12 //////////////////////////////////////////////////////////////////////////
|
29 chuck 1.4 //
30 //%/////////////////////////////////////////////////////////////////////////////
31
|
32 humberto 1.1 #include "CQLFactorRep.h"
33 #include <Pegasus/CQL/CQLExpression.h>
34 #include <Pegasus/CQL/CQLFunction.h>
35 #include <Pegasus/CQL/CQLFactory.h>
36 #include <Pegasus/CQL/CQLValue.h>
|
37 chuck 1.4 #include <Pegasus/Query/QueryCommon/QueryContext.h>
38 #include <Pegasus/Common/Tracer.h>
|
39 kumpf 1.14
|
40 humberto 1.1 PEGASUS_NAMESPACE_BEGIN
|
41 chuck 1.4
|
42 humberto 1.7 CQLFactorRep::CQLFactorRep():
43 _CQLExp(),
|
44 karl 1.11 _CQLVal(),
45 _CQLFunct(),
46 _invert(false),
|
47 kumpf 1.14 _simpleValue(false),
|
48 karl 1.11 _containedType(VALUE)
|
49 humberto 1.7 {
50
51 }
52
|
53 humberto 1.5 CQLFactorRep::CQLFactorRep(const CQLFactorRep* rep):
|
54 karl 1.11 _CQLExp(rep->_CQLExp),
55 _CQLVal(rep->_CQLVal),
56 _CQLFunct(rep->_CQLFunct),
57 _invert(rep->_invert),
58 _simpleValue(rep->_simpleValue),
59 _containedType(rep->_containedType)
|
60 kumpf 1.14
|
61 humberto 1.1 {
|
62 karl 1.11 PEG_METHOD_ENTER(TRC_CQL,
63 "CQLFactorRep::CQLFactorRep(const CQLFactorRep* rep)");
|
64 chuck 1.4
65 PEG_METHOD_EXIT();
|
66 humberto 1.1 }
67
|
68 humberto 1.5 CQLFactorRep::CQLFactorRep(const CQLValue& inCQLVal):
|
69 karl 1.11 _CQLExp(),
70 _CQLVal(inCQLVal),
71 _CQLFunct(),
72 _invert(false),
73 _simpleValue(true),
74 _containedType(VALUE)
|
75 humberto 1.5
|
76 humberto 1.1 {
|
77 karl 1.11 PEG_METHOD_ENTER(TRC_CQL,
78 "CQLFactorRep::CQLFactorRep(const CQLValue& inCQLVal)");
|
79 chuck 1.4
80 PEG_METHOD_EXIT();
|
81 humberto 1.1 }
82
|
83 humberto 1.5 CQLFactorRep::CQLFactorRep(const CQLExpression& inCQLExp):
|
84 karl 1.11 _CQLExp(inCQLExp),
85 _CQLVal(),
86 _CQLFunct(),
87 _invert(false),
88 _simpleValue(false),
89 _containedType(EXPRESSION)
|
90 humberto 1.1 {
|
91 karl 1.11 PEG_METHOD_ENTER(TRC_CQL,
92 "CQLFactorRep::CQLFactorRep(const CQLExpression& inCQLExp)");
|
93 chuck 1.4
94 PEG_METHOD_EXIT();
|
95 humberto 1.1 }
96
|
97 humberto 1.5 CQLFactorRep::CQLFactorRep(const CQLFunction& inCQLFunc):
|
98 karl 1.11 _CQLExp(),
99 _CQLVal(),
100 _CQLFunct(inCQLFunc),
101 _invert(false),
102 _simpleValue(false),
103 _containedType(FUNCTION)
|
104 humberto 1.1 {
|
105 karl 1.11 PEG_METHOD_ENTER(TRC_CQL,
106 "CQLFactorRep::CQLFactorRep(const CQLFunction& inCQLFunc)");
|
107 chuck 1.4
|
108 karl 1.11 PEG_METHOD_EXIT();
|
109 humberto 1.1 }
110
|
111 chuck 1.4 CQLValue CQLFactorRep::getValue()const
|
112 humberto 1.1 {
|
113 karl 1.11 return _CQLVal;
|
114 humberto 1.1 }
115
|
116 karl 1.11 CQLValue CQLFactorRep::resolveValue(const CIMInstance& CI,
117 const QueryContext& QueryCtx)
|
118 humberto 1.1 {
|
119 karl 1.11 PEG_METHOD_ENTER(TRC_CQL,"CQLFactorRep::resolveValue()");
|
120 kumpf 1.14
|
121 karl 1.11 if(_containedType == EXPRESSION)
122 {
123 PEG_METHOD_EXIT();
124 return _CQLExp.resolveValue(CI,QueryCtx);
125 }
126 else if (_containedType == FUNCTION)
|
127 chuck 1.4 {
|
128 karl 1.11 PEG_METHOD_EXIT();
129 return _CQLFunct.resolveValue(CI,QueryCtx);
|
130 chuck 1.4 }
|
131 karl 1.11 else if (_containedType == VALUE)
|
132 chuck 1.4 {
|
133 karl 1.11 _CQLVal.resolve(CI,QueryCtx);
134 PEG_METHOD_EXIT();
135 return _CQLVal;
|
136 chuck 1.4 }
|
137 karl 1.11 else
|
138 chuck 1.4 {
|
139 karl 1.11 MessageLoaderParms msg("CQL.CQLFactorRep.FACTOR_HAS_NO_TYPE",
140 "The CQLFactor was constructed without a type.");
141 throw CQLRuntimeException(msg);
|
142 chuck 1.4 }
|
143 humberto 1.1 }
144
|
145 chuck 1.4 Boolean CQLFactorRep::isSimple()const
|
146 humberto 1.1 {
147 return _simpleValue;
148 }
149
|
150 chuck 1.4 Boolean CQLFactorRep::isSimpleValue()const
151 {
152 return _simpleValue;
153 }
154
155 CQLFunction CQLFactorRep::getCQLFunction()const
|
156 humberto 1.1 {
157 return _CQLFunct;
158 }
159
|
160 chuck 1.4 CQLExpression CQLFactorRep::getCQLExpression()const
|
161 humberto 1.1 {
162 return _CQLExp;
163 }
164
|
165 chuck 1.4 String CQLFactorRep::toString()const
|
166 humberto 1.1 {
|
167 karl 1.11 PEG_METHOD_ENTER(TRC_CQL,"CQLFactorRep::toString()");
|
168 kumpf 1.14
|
169 karl 1.11 if(_containedType == VALUE)
|
170 chuck 1.4 {
|
171 karl 1.11 PEG_METHOD_EXIT();
172 return _CQLVal.toString();
|
173 chuck 1.4 }
|
174 kumpf 1.14
|
175 karl 1.11 if(_containedType == FUNCTION)
|
176 chuck 1.4 {
|
177 karl 1.11 PEG_METHOD_EXIT();
178 return _CQLFunct.toString();
|
179 chuck 1.4 }
|
180 karl 1.11 if (_containedType == EXPRESSION)
|
181 chuck 1.4 {
|
182 karl 1.11 PEG_METHOD_EXIT();
183 return _CQLExp.toString();
|
184 chuck 1.4 }
|
185 karl 1.11 return String("");
|
186 humberto 1.1 }
187
|
188 vijay.eli 1.9 void CQLFactorRep::applyContext(const QueryContext& inContext,
189 const CQLChainedIdentifier& inCid)
|
190 humberto 1.1 {
|
191 karl 1.11 PEG_METHOD_ENTER(TRC_CQL,"CQLFactorRep::applyContext()");
|
192 kumpf 1.14
|
193 karl 1.11 if(_containedType == FUNCTION)
194 {
195 _CQLFunct.applyContext(inContext);
196 }
197 else if(_containedType == EXPRESSION)
|
198 chuck 1.4 {
|
199 karl 1.11 _CQLExp.applyContext(inContext);
|
200 chuck 1.4 }
|
201 karl 1.11 else if(_containedType == VALUE)
|
202 chuck 1.4 {
|
203 karl 1.11 _CQLVal.applyContext(inContext,inCid);
|
204 chuck 1.4 }
|
205 karl 1.11 else
|
206 chuck 1.4 {
|
207 karl 1.11 MessageLoaderParms msg("CQL.CQLFactorRep.FACTOR_HAS_NO_TYPE",
208 "The CQLFactor was constructed without a type.");
209 throw CQLRuntimeException(msg);
|
210 chuck 1.4 }
|
211 kumpf 1.14
|
212 karl 1.11 PEG_METHOD_EXIT();
213 return;
|
214 chuck 1.4 }
|
215 humberto 1.5 /*
|
216 chuck 1.4 Boolean CQLFactorRep::operator==(const CQLFactorRep& rep)const
217 {
|
218 karl 1.11 PEG_METHOD_ENTER(TRC_CQL,"CQLFactorRep::operator==()");
|
219 kumpf 1.14
|
220 karl 1.11 if(_CQLExp != rep._CQLExp)
|
221 chuck 1.4 {
|
222 karl 1.11 PEG_METHOD_EXIT();
223 return false;
|
224 chuck 1.4 }
|
225 karl 1.11 if(CQLValue(_CQLVal) != rep._CQLVal) // Why?
|
226 chuck 1.4 {
|
227 karl 1.11 PEG_METHOD_EXIT();
228 return false;
|
229 chuck 1.4 }
|
230 karl 1.11 if(_CQLFunct != rep._CQLFunct)
|
231 chuck 1.4 {
|
232 karl 1.11 PEG_METHOD_EXIT();
233 return false;
|
234 chuck 1.4 }
|
235 karl 1.11 if(_invert != rep._invert)
|
236 chuck 1.4 {
|
237 karl 1.11 PEG_METHOD_EXIT();
238 return false;
|
239 chuck 1.4 }
|
240 karl 1.11 if(_simpleValue != rep._simpleValue)
|
241 chuck 1.4 {
|
242 karl 1.11 PEG_METHOD_EXIT();
243 return false;
|
244 chuck 1.4 }
|
245 karl 1.11 if(_containedType != rep._containedType)
|
246 chuck 1.4 {
|
247 karl 1.11 PEG_METHOD_EXIT();
248 return false;
|
249 chuck 1.4 }
|
250 kumpf 1.14
|
251 karl 1.11 PEG_METHOD_EXIT();
252 return true;
|
253 humberto 1.1 }
254
|
255 chuck 1.4 Boolean CQLFactorRep::operator!=(const CQLFactorRep& rep)const
256 {
257 return (!operator==(rep));
|
258 humberto 1.1 }
|
259 humberto 1.5 */
|
260 humberto 1.1 PEGASUS_NAMESPACE_END
|