1 karl 1.5 //%2005////////////////////////////////////////////////////////////////////////
|
2 chuck 1.2 //
|
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.2 // 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 chuck 1.2 //
12 // Permission is hereby granted, free of charge, to any person obtaining a copy
13 // 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 // 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 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
20 // 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 // 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 // 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 // Authors: David Rosckes (rosckes@us.ibm.com)
31 // Bert Rivero (hurivero@us.ibm.com)
32 chuck 1.2 // Chuck Carmack (carmack@us.ibm.com)
33 // Brian Lucier (lucier@us.ibm.com)
34 //
|
35 vijay.eli 1.6 // Modified By: Vijay Eli, IBM (vijayeli@in.ibm.com) bug#3590
|
36 aruran.ms 1.7 // Aruran, IBM (ashanmug@in.ibm.com) for Bug# 3591
|
37 chuck 1.2 //
38 //%/////////////////////////////////////////////////////////////////////////////
39
40 #include <Pegasus/CQL/CQLTerm.h>
41 #include <Pegasus/CQL/CQLTermRep.h>
42 #include <Pegasus/CQL/CQLFactory.h>
43 #include <Pegasus/Query/QueryCommon/QueryContext.h>
44 #include <Pegasus/Query/QueryCommon/QueryException.h>
45 #include <Pegasus/Common/Tracer.h>
46
47 PEGASUS_NAMESPACE_BEGIN
48
49 CQLTermRep::CQLTermRep(){}
50
51 CQLTermRep::CQLTermRep(const CQLFactor& theFactor)
52 {
53 PEG_METHOD_ENTER(TRC_CQL,"CQLTermRep:CQLTermRep()");
54
55 _Factors.append(theFactor);
56
57 PEG_METHOD_EXIT();
58 chuck 1.2 }
59
60 CQLTermRep::CQLTermRep(const CQLTermRep& rep){
61 _Factors = rep._Factors;
62 _FactorOperators = rep._FactorOperators;
63 }
64
65 CQLTermRep::~CQLTermRep(){
66 }
67
68 CQLValue CQLTermRep::resolveValue(const CIMInstance& CI, const QueryContext& QueryCtx)
69 {
70 PEG_METHOD_ENTER(TRC_CQL,"CQLTermRep:resolveValue()");
71 CQLValue returnVal = _Factors[0].resolveValue(CI,QueryCtx);
72
73 for(Uint32 i = 0; i < _FactorOperators.size(); ++i)
74 {
75 switch(_FactorOperators[i])
76 {/*
77 case mult:
78 returnVal = returnVal *
79 chuck 1.2 _Factors[i+1].resolveValue(CI,QueryCtx);
80 break;
81 case divide:
82 returnVal = returnVal /
83 _Factors[i+1].resolveValue(CI,QueryCtx);
84 break;
85 */
86 case concat:
87 returnVal = returnVal +
88 _Factors[i+1].resolveValue(CI,QueryCtx);
89 break;
90
91 default:
|
92 chuck 1.3 MessageLoaderParms mload(String("CQL.CQLTermRep.OPERATION_NOT_SUPPORTED"),
93 String("Operation is not supported."));
94 throw CQLRuntimeException(mload);
|
95 chuck 1.2 }
96 }
97
98 PEG_METHOD_EXIT();
99 return returnVal;
100 }
101
|
102 aruran.ms 1.7 void CQLTermRep::appendOperation(FactorOpType inFactorOpType, const CQLFactor& inFactor)
|
103 chuck 1.2 {
104 PEG_METHOD_ENTER(TRC_CQL,"CQLTermRep::appendOperation()");
105
106 _FactorOperators.append(inFactorOpType);
107 _Factors.append(inFactor);
108
109 PEG_METHOD_EXIT();
110 }
111
112 String CQLTermRep::toString()const
113 {
114 PEG_METHOD_ENTER(TRC_CQL,"CQLTermRep::toString()");
115
116 String returnStr;
117
118 returnStr.append(_Factors[0].toString());
119
120 for(Uint32 i = 0; i < _FactorOperators.size(); ++i)
121 {
|
122 humberto 1.4 /*
|
123 chuck 1.2 returnStr.append(_FactorOperators[i] ==
124 mult ? String(" * ") : divide ? String(" / ") : String(" concat "));
|
125 humberto 1.4 */
126 if(_FactorOperators[i] == concat)
127 returnStr.append(String(" || "));
|
128 chuck 1.2 returnStr.append(_Factors[i+1].toString());
129 }
130
131 PEG_METHOD_EXIT();
132 return returnStr;
133 }
134
135 Boolean CQLTermRep::isSimple()const
136 {
137 return (_Factors.size() == 1);
138 }
139
140 Boolean CQLTermRep::isSimpleValue()const
141 {
142 PEG_METHOD_ENTER(TRC_CQL,"CQLTermRep::isSimpleValue()");
143 if(_Factors.size() == 1)
144 {
145 PEG_METHOD_EXIT();
146 return _Factors[0].isSimpleValue();
147 }
148
149 chuck 1.2 PEG_METHOD_EXIT();
150 return false;
151 }
152
153 Array<CQLFactor> CQLTermRep::getFactors()const
154 {
155 return _Factors;
156 }
157
158 Array<FactorOpType> CQLTermRep::getOperators()const
159 {
160 return _FactorOperators;
161 }
162
|
163 vijay.eli 1.6 void CQLTermRep::applyContext(const QueryContext& inContext,
164 const CQLChainedIdentifier& inCid)
|
165 chuck 1.2 {
166 PEG_METHOD_ENTER(TRC_CQL,"CQLTermRep::applyContext()");
167
168 for(Uint32 i = 0; i < _Factors.size(); ++i)
169 {
170 _Factors[i].applyContext(inContext, inCid);
171 }
172
173 PEG_METHOD_EXIT();
174 }
|
175 humberto 1.4 /*
|
176 chuck 1.2 Boolean CQLTermRep::operator==(const CQLTermRep& rhs)const
177 {
178 PEG_METHOD_ENTER(TRC_CQL,"CQLTermRep::operator==()");
179
180 for(Uint32 i = 0; i < _FactorOperators.size(); ++i)
181 {
182 if(_FactorOperators[i] != rhs._FactorOperators[i])
183 {
184 PEG_METHOD_EXIT();
185 return false;
186 }
187 }
188
189 for(Uint32 i = 0; i < _Factors.size(); ++i)
190 {
191 if(_Factors[i] != rhs._Factors[i])
192 {
193 PEG_METHOD_EXIT();
194 return false;
195 }
196 }
197 chuck 1.2
198 PEG_METHOD_EXIT();
199 return true;
200 }
201
202 Boolean CQLTermRep::operator!=(const CQLTermRep& rhs)const
203 {
204 return (!operator==(rhs));
205 }
|
206 humberto 1.4 */
|
207 chuck 1.2 PEGASUS_NAMESPACE_END
|