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 #include <Pegasus/CQL/CQLTerm.h>
36 #include <Pegasus/CQL/CQLTermRep.h>
37 #include <Pegasus/CQL/CQLFactory.h>
38 #include <Pegasus/Query/QueryCommon/QueryContext.h>
39 #include <Pegasus/Query/QueryCommon/QueryException.h>
40 #include <Pegasus/Common/Tracer.h>
41
42 PEGASUS_NAMESPACE_BEGIN
43 chuck 1.2
44 CQLTermRep::CQLTermRep(){}
45
46 CQLTermRep::CQLTermRep(const CQLFactor& theFactor)
47 {
48 PEG_METHOD_ENTER(TRC_CQL,"CQLTermRep:CQLTermRep()");
49
50 _Factors.append(theFactor);
51
52 PEG_METHOD_EXIT();
53 }
54
55 CQLTermRep::CQLTermRep(const CQLTermRep& rep){
56 _Factors = rep._Factors;
57 _FactorOperators = rep._FactorOperators;
58 }
59
60 CQLTermRep::~CQLTermRep(){
61 }
62
63 CQLValue CQLTermRep::resolveValue(const CIMInstance& CI, const QueryContext& QueryCtx)
64 chuck 1.2 {
65 PEG_METHOD_ENTER(TRC_CQL,"CQLTermRep:resolveValue()");
66 CQLValue returnVal = _Factors[0].resolveValue(CI,QueryCtx);
67
68 for(Uint32 i = 0; i < _FactorOperators.size(); ++i)
69 {
70 switch(_FactorOperators[i])
71 {/*
72 case mult:
73 returnVal = returnVal *
74 _Factors[i+1].resolveValue(CI,QueryCtx);
75 break;
76 case divide:
77 returnVal = returnVal /
78 _Factors[i+1].resolveValue(CI,QueryCtx);
79 break;
80 */
81 case concat:
82 returnVal = returnVal +
83 _Factors[i+1].resolveValue(CI,QueryCtx);
84 break;
85 chuck 1.2
86 default:
|
123 chuck 1.2 returnStr.append(_Factors[i+1].toString());
124 }
125
126 PEG_METHOD_EXIT();
127 return returnStr;
128 }
129
130 Boolean CQLTermRep::isSimple()const
131 {
132 return (_Factors.size() == 1);
133 }
134
135 Boolean CQLTermRep::isSimpleValue()const
136 {
137 PEG_METHOD_ENTER(TRC_CQL,"CQLTermRep::isSimpleValue()");
138 if(_Factors.size() == 1)
139 {
140 PEG_METHOD_EXIT();
141 return _Factors[0].isSimpleValue();
142 }
143
144 chuck 1.2 PEG_METHOD_EXIT();
145 return false;
146 }
147
148 Array<CQLFactor> CQLTermRep::getFactors()const
149 {
150 return _Factors;
151 }
152
153 Array<FactorOpType> CQLTermRep::getOperators()const
154 {
155 return _FactorOperators;
156 }
157
158 void CQLTermRep::applyContext(QueryContext& inContext,
159 CQLChainedIdentifier& inCid)
160 {
161 PEG_METHOD_ENTER(TRC_CQL,"CQLTermRep::applyContext()");
162
163 for(Uint32 i = 0; i < _Factors.size(); ++i)
164 {
165 chuck 1.2 _Factors[i].applyContext(inContext, inCid);
166 }
167
168 PEG_METHOD_EXIT();
169 }
|