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

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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2