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

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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2