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

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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2