(file) Return to CMPI_SelectExpAccessor_CQL.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / ProviderManager2 / CMPI

  1 karl  1.5 //%2006////////////////////////////////////////////////////////////////////////
  2 konrad.r 1.1 //
  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              // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
  8              // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
  9 karl     1.2 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 10              // EMC Corporation; VERITAS Software Corporation; The Open Group.
 11 karl     1.5 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 12              // EMC Corporation; Symantec Corporation; The Open Group.
 13 konrad.r 1.1 //
 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:      Adrian Schuur, schuur@de.ibm.com
 33              //
 34 konrad.r 1.1 // Modified By:
 35              //
 36              //%/////////////////////////////////////////////////////////////////////////////
 37              
 38              #include "CMPI_Version.h"
 39              
 40              #include "CMPI_SelectExpAccessor_CQL.h"
 41              #include <Pegasus/Provider/CMPI/cmpidt.h>
 42              #include <Pegasus/Provider/CMPI/cmpimacs.h>
 43              
 44              #include <Pegasus/Common/String.h>
 45              #include <Pegasus/CQL/CQLParser.h>
 46              #include <Pegasus/CQL/CQLParserState.h>
 47              #include <Pegasus/CQL/CQLSelectStatement.h>
 48              #include <Pegasus/Repository/RepositoryQueryContext.h>
 49              #include <Pegasus/Common/CIMName.h>
 50              #include <Pegasus/Common/MessageLoader.h>
 51              #include <Pegasus/Repository/CIMRepository.h>
 52              #include <Pegasus/Common/CIMInstance.h>
 53              #include <Pegasus/Common/CIMObjectPath.h>
 54              #include <Pegasus/CQL/CQLExpression.h>
 55 konrad.r 1.1 #include <Pegasus/CQL/CQLSimplePredicate.h>
 56              #include <Pegasus/CQL/CQLPredicate.h>
 57              #include <Pegasus/CQL/CQLValue.h>
 58 konrad.r 1.3 #include <Pegasus/Query/QueryCommon/QueryChainedIdentifier.h>
 59 mike     1.6 
 60              PEGASUS_USING_STD;
 61              
 62              PEGASUS_NAMESPACE_BEGIN 
 63 konrad.r 1.1 
 64              CMPI_SelectExpAccessor_CQL::CMPI_SelectExpAccessor_CQL (CMPIAccessor * acc,
 65                                                                      void *parm,
 66                                                                      CQLSelectStatement *
 67                                                                      stmt,
 68                                                                      CIMObjectPath &
 69                                                                      objPath):
 70              accessor (acc),
 71              accParm (parm),
 72              _stmt (stmt),
 73              _objPath (objPath)
 74              {
 75                // Construct an _instance
 76                _constructInstance ();
 77              }
 78              
 79              void
 80              CMPI_SelectExpAccessor_CQL::_constructInstance ()
 81              {
 82              
 83                _instance = CIMInstance (_objPath.getClassName ().getString ());
 84 konrad.r 1.1 
 85                // Iterate throught the CQLPredicates
 86              
 87 konrad.r 1.3   Array < CQLChainedIdentifier > where_Array =
 88                  _stmt->getWhereChainedIdentifiers ();
 89 konrad.r 1.1 
 90 konrad.r 1.3   /* We will create an instance using the where_Array properties */
 91 konrad.r 1.1 
 92 konrad.r 1.3   for (Uint32 i = 0; i < where_Array.size (); i++)
 93 konrad.r 1.1     {
 94 konrad.r 1.3       CQLIdentifier identifier = where_Array[i].getLastIdentifier ();
 95                    String name = identifier.getName ().getString ();
 96 konrad.r 1.1 
 97 konrad.r 1.3       //cerr << "Calling accessor function with property: " << name << endl;
 98 konrad.r 1.1 
 99 konrad.r 1.3       CMPIAccessor *get = (CMPIAccessor *) accessor;
100                    CMPIData data = get (name.getCString (), accParm);
101 konrad.r 1.1 
102 konrad.r 1.3       // Only process good values.
103                    if ((data.state == CMPI_goodValue) || (data.state == CMPI_keyValue))
104                      {
105 konrad.r 1.1 
106                        if (data.type & CMPI_ARRAY)
107                          {
108 konrad.r 1.3               // Nothing yet
109 konrad.r 1.1             }
110              
111                        else if ((data.type & (CMPI_UINT | CMPI_SINT)) == CMPI_SINT)
112                          {
113                            switch (data.type)
114                              {
115                              case CMPI_sint32:
116                                _instance.
117                                  addProperty (CIMProperty
118                                               (CIMName (name),
119                                                Sint32 (data.value.sint32)));
120                                break;
121                              case CMPI_sint16:
122                                _instance.
123                                  addProperty (CIMProperty
124                                               (CIMName (name),
125                                                Sint16 (data.value.sint16)));
126                                break;
127                              case CMPI_sint8:
128                                _instance.
129                                  addProperty (CIMProperty
130 konrad.r 1.1                                  (CIMName (name),
131 dave.sudlik 1.4                                   Sint8 (data.value.sint8)));
132 konrad.r    1.1                   break;
133                                 case CMPI_sint64:
134                                   _instance.
135                                     addProperty (CIMProperty
136                                                  (CIMName (name),
137                                                   Sint64 (data.value.sint64)));
138                                   break;
139                                 default:
140                                   break;
141                                 }
142                             }
143                 
144                           else if (data.type == CMPI_chars)
145                             _instance.
146                               addProperty (CIMProperty
147                                            (CIMName (name), String (data.value.chars)));
148                           else if (data.type == CMPI_string)
149                             {
150                               CMPIStatus rc;
151                               _instance.
152                                 addProperty (CIMProperty
153 konrad.r    1.1                              (CIMName (name),
154                                               String (CMGetCharsPtr
155                                                       (data.value.string, &rc))));
156                             }
157                 
158                           else if ((data.type & (CMPI_UINT | CMPI_SINT)) == CMPI_UINT)
159                             {
160                               switch (data.type)
161                                 {
162                                 case CMPI_uint32:
163                                   _instance.
164                                     addProperty (CIMProperty
165                                                  (CIMName (name),
166                                                   Uint32 (data.value.uint32)));
167                                   break;
168                                 case CMPI_uint16:
169                                   _instance.
170                                     addProperty (CIMProperty
171                                                  (CIMName (name),
172                                                   Uint16 (data.value.uint16)));
173                                   break;
174 konrad.r    1.1                 case CMPI_uint8:
175                                   _instance.
176                                     addProperty (CIMProperty
177 dave.sudlik 1.4                                  (CIMName (name), Uint8 (data.value.uint8)));
178 konrad.r    1.1                   break;
179                                 case CMPI_uint64:
180                                   _instance.
181                                     addProperty (CIMProperty
182                                                  (CIMName (name),
183                                                   Uint64 (data.value.uint64)));
184                                   break;
185                                 default:;
186                                   break;
187                                 }
188                             }
189                 
190                           else
191                             switch (data.type)
192                               {
193                               case CMPI_boolean:
194                                 _instance.
195                                   addProperty (CIMProperty
196                                                (CIMName (name),
197                                                 Boolean (data.value.boolean)));
198                                 break;
199 konrad.r    1.1               case CMPI_real32:
200                                 _instance.
201                                   addProperty (CIMProperty
202                                                (CIMName (name), data.value.real32));
203                                 break;
204                               case CMPI_real64:
205                                 _instance.
206                                   addProperty (CIMProperty
207                                                (CIMName (name), data.value.real64));
208                                 break;
209                               default:
210                                 break;
211                               }
212                         }
213                     }
214                 
215                 }
216                 
217                 PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2