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

  1 martin 1.10 //%LICENSE////////////////////////////////////////////////////////////////
  2 martin 1.11 //
  3 martin 1.10 // Licensed to The Open Group (TOG) under one or more contributor license
  4             // agreements.  Refer to the OpenPegasusNOTICE.txt file distributed with
  5             // this work for additional information regarding copyright ownership.
  6             // Each contributor licenses this file to you under the OpenPegasus Open
  7             // Source License; you may not use this file except in compliance with the
  8             // License.
  9 martin 1.11 //
 10 martin 1.10 // Permission is hereby granted, free of charge, to any person obtaining a
 11             // copy of this software and associated documentation files (the "Software"),
 12             // to deal in the Software without restriction, including without limitation
 13             // the rights to use, copy, modify, merge, publish, distribute, sublicense,
 14             // and/or sell copies of the Software, and to permit persons to whom the
 15             // Software is furnished to do so, subject to the following conditions:
 16 martin 1.11 //
 17 martin 1.10 // The above copyright notice and this permission notice shall be included
 18             // in all copies or substantial portions of the Software.
 19 martin 1.11 //
 20 martin 1.10 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 21 martin 1.11 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 22 martin 1.10 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 23             // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 24             // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 25             // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 26             // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 27 martin 1.11 //
 28 martin 1.10 //////////////////////////////////////////////////////////////////////////
 29 chuck  1.2  //
 30             //%/////////////////////////////////////////////////////////////////////////////
 31             
 32             #include <Pegasus/CQL/CQLExpression.h>
 33             #include <Pegasus/CQL/CQLExpressionRep.h>
 34             #include <Pegasus/CQL/CQLFactory.h>
 35             #include <Pegasus/Query/QueryCommon/QueryContext.h>
 36             #include <Pegasus/Common/Tracer.h>
 37             
 38             PEGASUS_NAMESPACE_BEGIN
 39             
 40             CQLExpressionRep::CQLExpressionRep(const CQLTerm& theTerm)
 41             {
 42 karl   1.9    PEG_METHOD_ENTER(TRC_CQL,
 43                   "CQLExpressionRep::CQLExpressionRep(const CQLTerm& theTerm)");
 44 chuck  1.2    _CQLTerms.append(theTerm);
 45               PEG_METHOD_EXIT();
 46             }
 47             
 48 kumpf  1.12 CQLExpressionRep::CQLExpressionRep(const CQLExpressionRep* rep)
 49 chuck  1.2  {
 50 karl   1.9    PEG_METHOD_ENTER(TRC_CQL,
 51                   "CQLExpressionRep::CQLExpressionRep(const CQLExpressionRep* rep)");
 52 chuck  1.2  
 53               _TermOperators = rep->_TermOperators;
 54               _CQLTerms = rep->_CQLTerms;
 55             
 56               PEG_METHOD_EXIT();
 57             }
 58             
 59             CQLExpressionRep::~CQLExpressionRep()
 60             {
 61             
 62             }
 63 karl   1.9  CQLValue CQLExpressionRep::resolveValue(const CIMInstance& CI,
 64                                                     const QueryContext& QueryCtx)
 65 chuck  1.2  {
 66               PEG_METHOD_ENTER(TRC_CQL,"CQLExpressionRep::resolveValue()");
 67             
 68               CQLValue returnVal = _CQLTerms[0].resolveValue(CI,QueryCtx);
 69 kumpf  1.12 
 70 chuck  1.4    /*
 71 karl   1.9      for(Uint32 i = 0; i < _TermOperators.size(); ++i)
 72 chuck  1.2      {
 73                   switch(_TermOperators[i])
 74 karl   1.9          {
 75                        case TERM_ADD:
 76 kumpf  1.12                returnVal = returnVal +
 77 karl   1.9                 _CQLTerms[i+1].resolveValue(CI,QueryCtx);
 78                        break;
 79                            case TERM_SUBTRACT:
 80 kumpf  1.12                returnVal = returnVal -
 81 karl   1.9                 _CQLTerms[i+1].resolveValue(CI,QueryCtx);
 82                            break;
 83                     default:
 84                         throw(1);
 85                     }
 86 chuck  1.2      }
 87 karl   1.9  */
 88 kumpf  1.12 
 89 chuck  1.2    PEG_METHOD_EXIT();
 90               return returnVal;
 91             }
 92             
 93 karl   1.9  void CQLExpressionRep::appendOperation(const TermOpType theTermOpType,
 94                                                    const CQLTerm& theTerm)
 95 chuck  1.2  {
 96 karl   1.9      PEG_METHOD_ENTER(TRC_CQL,"CQLExpressionRep::appendOperation()");
 97 kumpf  1.12 
 98 karl   1.9      _TermOperators.append(theTermOpType);
 99                 _CQLTerms.append(theTerm);
100 kumpf  1.12 
101 karl   1.9      PEG_METHOD_EXIT();
102 chuck  1.2  }
103             
104             String CQLExpressionRep::toString()const
105             {
106 karl   1.9      PEG_METHOD_ENTER(TRC_CQL,"CQLExpressionRep::toString()");
107 kumpf  1.12 
108 karl   1.9      String returnStr;
109 kumpf  1.12 
110 karl   1.9      if(_CQLTerms.size() > 0)
111                 {
112                     returnStr.append(_CQLTerms[0].toString());
113                     /* for(Uint32 i = 0; i < _TermOperators.size(); ++i)
114                       {
115 kumpf  1.12             returnStr.append(_TermOperators[i] ==
116 karl   1.9                  TERM_ADD ? String(" + ") : String(" - "));
117                     returnStr.append(_CQLTerms[i+1].toString());
118                       }
119                     */
120                 }
121 kumpf  1.12 
122 karl   1.9      PEG_METHOD_EXIT();
123                 return returnStr;
124                 }
125 chuck  1.2  
126             
127             Boolean CQLExpressionRep::isSimple()const
128             {
129                return (_CQLTerms.size() == 1);
130             }
131             
132             Boolean CQLExpressionRep::isSimpleValue()const
133             {
134               PEG_METHOD_ENTER(TRC_CQL,"CQLExpressionRep::isSimpleValue()");
135             
136 kumpf  1.12   if(_CQLTerms.size() == 1)
137 chuck  1.2      {
138                   PEG_METHOD_EXIT();
139                   return _CQLTerms[0].isSimpleValue();
140                 }
141 kumpf  1.12 
142 chuck  1.2    PEG_METHOD_EXIT();
143 kumpf  1.12 
144 chuck  1.2    return false;
145             }
146             
147             Array<CQLTerm> CQLExpressionRep::getTerms()const
148             {
149                return _CQLTerms;
150             }
151             
152             Array<TermOpType> CQLExpressionRep::getOperators()const
153             {
154                return _TermOperators;
155             }
156             
157 vijay.eli 1.7  void CQLExpressionRep::applyContext(const QueryContext& inContext,
158                                                    const CQLChainedIdentifier& inCid)
159 chuck     1.2  {
160                  PEG_METHOD_ENTER(TRC_CQL,"CQLExpressionRep::applyContext()");
161                
162                  for(Uint32 i = 0; i < _CQLTerms.size(); ++i)
163                  {
164                    _CQLTerms[i].applyContext(inContext, inCid);
165                  }
166                
167                  PEG_METHOD_EXIT();
168                }
169 humberto  1.5  /*
170 chuck     1.2  Boolean CQLExpressionRep::operator==(const CQLExpressionRep& rep)const
171                {
172                  PEG_METHOD_ENTER(TRC_CQL,"CQLExpressionRep::operator==()");
173                
174                  if(_isSimple != rep._isSimple)
175                    {
176                      PEG_METHOD_EXIT();
177                      return false;
178                    }
179                
180                  for(Uint32 i = 0; i < _TermOperators.size(); ++i)
181                    {
182                      if(_TermOperators[i] != rep._TermOperators[i])
183 karl      1.9      {
184                      PEG_METHOD_EXIT();
185                      return false;
186                    }
187 chuck     1.2      }
188                
189                  for(Uint32 i = 0; i < _CQLTerms.size(); ++i)
190                    {
191                      if(_CQLTerms[i] != rep._CQLTerms[i])
192 karl      1.9      {
193                      PEG_METHOD_EXIT();
194                      return false;
195                    }
196 chuck     1.2      }
197 kumpf     1.12 
198 chuck     1.2    PEG_METHOD_EXIT();
199                  return true;
200                }
201                
202                Boolean CQLExpressionRep::operator!=(const CQLExpressionRep& rep)const
203                {
204                  return (!operator==(rep));
205                }
206 humberto  1.5  */
207 chuck     1.2  PEGASUS_NAMESPACE_END
208                

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2