(file) Return to CQLTermRep.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / CQL

  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:
 87 chuck 1.3            MessageLoaderParms mload(String("CQL.CQLTermRep.OPERATION_NOT_SUPPORTED"),
 88                                               String("Operation is not supported."));
 89                      throw CQLRuntimeException(mload);
 90 chuck 1.2       }
 91              }
 92           
 93              PEG_METHOD_EXIT();
 94              return returnVal;
 95           }
 96           
 97           void CQLTermRep::appendOperation(FactorOpType inFactorOpType, CQLFactor inFactor)
 98           {
 99             PEG_METHOD_ENTER(TRC_CQL,"CQLTermRep::appendOperation()");
100           
101             _FactorOperators.append(inFactorOpType);
102             _Factors.append(inFactor);
103           
104             PEG_METHOD_EXIT();
105           }
106           
107           String CQLTermRep::toString()const
108           {
109             PEG_METHOD_ENTER(TRC_CQL,"CQLTermRep::toString()");
110           
111 chuck 1.2   String returnStr;
112           
113             returnStr.append(_Factors[0].toString());
114             
115             for(Uint32 i = 0; i < _FactorOperators.size(); ++i)
116               {
117 humberto 1.4 	   /*
118 chuck    1.2       returnStr.append(_FactorOperators[i] == 
119              		       mult ? String(" * ") : divide ? String(" / ") : String(" concat "));
120 humberto 1.4 		*/
121              		if(_FactorOperators[i] == concat)
122              			returnStr.append(String(" || "));
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              }
170 humberto 1.4 /*
171 chuck    1.2 Boolean CQLTermRep::operator==(const CQLTermRep& rhs)const
172              {
173                PEG_METHOD_ENTER(TRC_CQL,"CQLTermRep::operator==()");
174                
175                for(Uint32 i = 0; i < _FactorOperators.size(); ++i)
176                  {
177                    if(_FactorOperators[i] != rhs._FactorOperators[i])
178              	{
179              	  PEG_METHOD_EXIT();
180              	  return false;
181              	}
182                  }
183                
184                for(Uint32 i = 0; i < _Factors.size(); ++i)
185                  {
186                    if(_Factors[i] != rhs._Factors[i])
187              	{
188              	  PEG_METHOD_EXIT();
189              	  return false;
190              	}
191                  }
192 chuck    1.2   
193                PEG_METHOD_EXIT();
194                return true;
195              }
196              
197              Boolean CQLTermRep::operator!=(const CQLTermRep& rhs)const
198              {
199                return (!operator==(rhs));
200              }
201 humberto 1.4 */
202 chuck    1.2 PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2