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

  1 martin 1.27 //%LICENSE////////////////////////////////////////////////////////////////
  2             // 
  3             // 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             // 
 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             // 
 17             // The above copyright notice and this permission notice shall be included
 18             // in all copies or substantial portions of the Software.
 19             // 
 20             // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 21             // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 
 22 martin 1.27 // 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             // 
 28             //////////////////////////////////////////////////////////////////////////
 29 schuur 1.1  //
 30             //%/////////////////////////////////////////////////////////////////////////////
 31             
 32 schuur 1.5  #include "CMPI_Version.h"
 33 schuur 1.3  
 34 schuur 1.1  #include "CMPI_ObjectPath.h"
 35             
 36             #include "CMPI_Ftabs.h"
 37             #include "CMPI_Value.h"
 38             #include "CMPI_String.h"
 39 ms.aruran 1.24 #include <Pegasus/Common/Tracer.h>
 40 schuur    1.1  
 41                PEGASUS_USING_STD;
 42                PEGASUS_NAMESPACE_BEGIN
 43                
 44 venkat.puvvada 1.23 extern "C"
 45                     {
 46                         static CMPIStatus refRelease(CMPIObjectPath* eRef)
 47                         {
 48                             CIMObjectPath* ref = (CIMObjectPath*)eRef->hdl;
 49                             if (ref)
 50                             {
 51                                 delete ref;
 52                                 (reinterpret_cast<CMPI_Object*>(eRef))->unlinkAndDelete();
 53                                 CMReturn(CMPI_RC_OK);
 54                             }
 55                             CMReturn(CMPI_RC_ERR_INVALID_HANDLE);
 56                         }
 57                     
 58                         static CMPIStatus refReleaseNop(CMPIObjectPath* eRef)
 59                         {
 60                             CMReturn(CMPI_RC_OK);
 61                         }
 62                     
 63                         static CMPIObjectPath* refClone(const CMPIObjectPath* eRef, CMPIStatus* rc)
 64                         {
 65 venkat.puvvada 1.23         CIMObjectPath *ref=(CIMObjectPath*)eRef->hdl;
 66                             if (!ref)
 67                             {
 68 ms.aruran      1.24             PEG_TRACE_CSTRING(
 69                                     TRC_CMPIPROVIDERINTERFACE,
 70                                     Tracer::LEVEL2,
 71                                     "Received invalid handle in CMPIObjectPath:refClone");
 72 venkat.puvvada 1.23             CMSetStatus(rc, CMPI_RC_ERR_INVALID_HANDLE);
 73                                 return NULL;
 74                             }
 75                             CIMObjectPath *nRef = new CIMObjectPath(
 76                                 ref->getHost(),
 77                                 ref->getNameSpace(),
 78                                 ref->getClassName());
 79                     
 80                             Array<CIMKeyBinding> kb = ref->getKeyBindings();
 81                             nRef->setKeyBindings(kb);
 82                             CMPI_Object* obj = new CMPI_Object(nRef);
 83                             obj->unlink();
 84                             CMPIObjectPath* neRef = reinterpret_cast<CMPIObjectPath*>(obj);
 85                             CMSetStatus(rc, CMPI_RC_OK);
 86                             return neRef;
 87                         }
 88                     
 89                         static CMPIStatus refSetNameSpace(CMPIObjectPath* eRef, const char *ns)
 90                         {
 91                             CIMObjectPath* ref = (CIMObjectPath*)eRef->hdl;
 92                             if (!ref)
 93 venkat.puvvada 1.23         {
 94 ms.aruran      1.24             PEG_TRACE_CSTRING(
 95                                     TRC_CMPIPROVIDERINTERFACE,
 96 marek          1.26                 Tracer::LEVEL1,
 97 ms.aruran      1.24                 "Received invalid handle in CMPIObjectPath:refSetNameSpace");
 98 venkat.puvvada 1.23             CMReturn(CMPI_RC_ERR_INVALID_HANDLE);
 99                             }
100                             if (!ns)
101                             {
102 ms.aruran      1.24             PEG_TRACE_CSTRING(
103                                     TRC_CMPIPROVIDERINTERFACE,
104 marek          1.26                 Tracer::LEVEL1,
105 ms.aruran      1.24                 "Received invalid Parameter in \
106                                     CMPIObjectPath:refSetNameSpace");
107 venkat.puvvada 1.23             CMReturn(CMPI_RC_ERR_INVALID_PARAMETER);
108                             }
109                             ref->setNameSpace(String(ns));
110                             CMReturn(CMPI_RC_OK);
111                         }
112                     
113                         static CMPIString* refGetNameSpace(
114                             const CMPIObjectPath* eRef,
115                             CMPIStatus* rc)
116                         {
117                             CIMObjectPath* ref = (CIMObjectPath*)eRef->hdl;
118                             if (!ref)
119                             {
120 ms.aruran      1.24             PEG_TRACE_CSTRING(
121                                     TRC_CMPIPROVIDERINTERFACE,
122 marek          1.26                 Tracer::LEVEL1,
123 ms.aruran      1.24                 "Received invalid handle in CMPIObjectPath:refGetNameSpace");
124 venkat.puvvada 1.23             CMSetStatus(rc, CMPI_RC_ERR_INVALID_HANDLE);
125                                 return NULL;
126                             }
127                             const CIMNamespaceName &ns = ref->getNameSpace();
128                             CMPIString *eNs = (CMPIString*)string2CMPIString(ns.getString());
129                             CMSetStatus(rc, CMPI_RC_OK);
130                             return eNs;
131                         }
132                     
133                         static CMPIStatus refSetHostname(CMPIObjectPath* eRef, const char *hn)
134                         {
135                             CIMObjectPath* ref = (CIMObjectPath*)eRef->hdl;
136                             if (!ref)
137                             {
138 ms.aruran      1.24             PEG_TRACE_CSTRING(
139                                     TRC_CMPIPROVIDERINTERFACE,
140 marek          1.26                 Tracer::LEVEL1,
141 ms.aruran      1.24                 "Received invalid handle in CMPIObjectPath:refSetHostName");
142 venkat.puvvada 1.23             CMReturn(CMPI_RC_ERR_INVALID_HANDLE);
143                             }
144                             if (!hn)
145                             {
146 ms.aruran      1.24             PEG_TRACE((
147                                     TRC_CMPIPROVIDERINTERFACE,
148 marek          1.26                 Tracer::LEVEL1,
149 ms.aruran      1.24                 "Received invalid parameter %s in \
150 kamal.locahana 1.25                 CMPIObjectPath:refSetHostName", hn));
151 venkat.puvvada 1.23             CMReturn(CMPI_RC_ERR_INVALID_PARAMETER);
152                             }
153                             ref->setHost(String(hn));
154                             CMReturn(CMPI_RC_OK);
155                         }
156                     
157                         static CMPIString* refGetHostname(
158                             const CMPIObjectPath* eRef,
159                             CMPIStatus* rc)
160                         {
161                             CIMObjectPath* ref = (CIMObjectPath*)eRef->hdl;
162                             if (!ref)
163                             {
164 ms.aruran      1.24             PEG_TRACE_CSTRING(
165                                     TRC_CMPIPROVIDERINTERFACE,
166 marek          1.26                 Tracer::LEVEL1,
167 ms.aruran      1.24                 "Received invalid handle in CMPIObjectPath:refGetHostName");
168 venkat.puvvada 1.23             CMSetStatus(rc, CMPI_RC_ERR_INVALID_HANDLE);
169                                 return NULL;
170                             }
171                             const String &hn = ref->getHost();
172                             CMPIString *eHn = (CMPIString*)string2CMPIString(hn);
173                             CMSetStatus(rc, CMPI_RC_OK);
174                             return eHn;
175                         }
176                     
177                         static CMPIStatus refSetClassName(CMPIObjectPath* eRef, const char *cn)
178                         {
179                             CIMObjectPath* ref = (CIMObjectPath*)eRef->hdl;
180                             if (!ref)
181                             {
182 ms.aruran      1.24             PEG_TRACE_CSTRING(
183                                     TRC_CMPIPROVIDERINTERFACE,
184 marek          1.26                 Tracer::LEVEL1,
185 ms.aruran      1.24                 "Received invalid handle in CMPIObjectPath:refSetClassName");
186 venkat.puvvada 1.23             CMReturn(CMPI_RC_ERR_INVALID_HANDLE);
187                             }
188                             if (!cn)
189                             {
190 ms.aruran      1.24             PEG_TRACE((
191                                     TRC_CMPIPROVIDERINTERFACE,
192 marek          1.26                 Tracer::LEVEL1,
193 ms.aruran      1.24                 "Received invalid parameter %s in \
194 kamal.locahana 1.25                 CMPIObjectPath:refSetClassName", cn));
195 venkat.puvvada 1.23             CMReturn(CMPI_RC_ERR_INVALID_PARAMETER);
196                             }
197                             ref->setClassName(String(cn));
198                             CMReturn(CMPI_RC_OK);
199                         }
200                     
201                         static CMPIString* refGetClassName(
202                             const CMPIObjectPath* eRef,
203                             CMPIStatus* rc)
204                         {
205                             CIMObjectPath* ref = (CIMObjectPath*)eRef->hdl;
206                             if (!ref)
207                             {
208 ms.aruran      1.24             PEG_TRACE_CSTRING(
209                                     TRC_CMPIPROVIDERINTERFACE,
210 marek          1.26                 Tracer::LEVEL1,
211 ms.aruran      1.24                 "Received invalid handle in CMPIObjectPath:refGetClassName");
212 venkat.puvvada 1.23             CMSetStatus(rc, CMPI_RC_ERR_INVALID_HANDLE);
213                                 return NULL;
214                             }
215                             const CIMName &cn = ref->getClassName();
216                             CMPIString* eCn = (CMPIString*)string2CMPIString(cn.getString());
217                             CMSetStatus(rc, CMPI_RC_OK);
218                             return eCn;
219                         }
220                     
221                     
222                         static long locateKey(const Array<CIMKeyBinding> &kb, const CIMName &eName)
223                         {
224                             for (unsigned long i=0,s=kb.size(); i<s; i++)
225                             {
226                                 const String &n = kb[i].getName().getString();
227                                 if (String::equalNoCase(n,eName.getString()))
228                                 {
229                                     return i;
230                                 }
231                             }
232                             return -1;
233 venkat.puvvada 1.23     }
234                     
235                         static CMPIStatus refAddKey(
236                             CMPIObjectPath* eRef,
237                             const char *name,
238                             const CMPIValue* data,
239                             const CMPIType type)
240                         {
241                             CIMObjectPath* ref = (CIMObjectPath*)eRef->hdl;
242                             if (!ref)
243                             {
244 ms.aruran      1.24             PEG_TRACE_CSTRING(
245                                     TRC_CMPIPROVIDERINTERFACE,
246 marek          1.26                 Tracer::LEVEL1,
247 ms.aruran      1.24                 "Received invalid handle in CMPIObjectPath:refAddKey");
248 venkat.puvvada 1.23             CMReturn(CMPI_RC_ERR_INVALID_HANDLE);
249                             }
250                             if (!name)
251                             {
252 ms.aruran      1.24             PEG_TRACE((
253                                     TRC_CMPIPROVIDERINTERFACE,
254 marek          1.26                 Tracer::LEVEL1,
255 ms.aruran      1.24                 "Received invalid parameter %s in \
256 kamal.locahana 1.25                 CMPIObjectPath:refAddKey", name));
257 venkat.puvvada 1.23             CMReturn(CMPI_RC_ERR_INVALID_PARAMETER);
258                             }
259                             Array<CIMKeyBinding> keyBindings = ref->getKeyBindings();
260                             CIMName key(name);
261                             CMPIrc rc;
262                     
263                             long i = locateKey(keyBindings,key);
264                             if (i >= 0)
265                             {
266                                 keyBindings.remove(i);
267                             }
268                     
269                             CIMValue val = value2CIMValue(data,type,&rc);
270                             keyBindings.append(CIMKeyBinding(key,val));
271                             ref->setKeyBindings(Array<CIMKeyBinding>(keyBindings));
272                             CMReturn(CMPI_RC_OK);
273                         }
274                     
275                         static CMPIData refGetKey(
276                             const CMPIObjectPath* eRef,
277                             const char *name,
278 venkat.puvvada 1.23         CMPIStatus* rc)
279                         {
280                             CIMObjectPath* ref = (CIMObjectPath*)eRef->hdl;
281                             CMPIData data = {0, CMPI_nullValue | CMPI_notFound, {0}};
282                     
283                             if (!ref)
284                             {
285 ms.aruran      1.24             PEG_TRACE_CSTRING(
286                                     TRC_CMPIPROVIDERINTERFACE,
287 marek          1.26                 Tracer::LEVEL1,
288 ms.aruran      1.24                 "Received invalid handle in CMPIObjectPath:refGetKey");
289 venkat.puvvada 1.23             CMSetStatus(rc, CMPI_RC_ERR_INVALID_HANDLE);
290                                 return data;
291                             }
292                             if (!name)
293                             {
294 ms.aruran      1.24             PEG_TRACE((
295                                     TRC_CMPIPROVIDERINTERFACE,
296 marek          1.26                 Tracer::LEVEL1,
297 ms.aruran      1.24                 "Received invalid parameter %s in \
298 kamal.locahana 1.25                 CMPIObjectPath:refGetKey", name));
299 venkat.puvvada 1.23             CMSetStatus(rc, CMPI_RC_ERR_INVALID_PARAMETER);
300                                 return data;
301                             }
302                             const CIMName eName(name);
303                             const Array<CIMKeyBinding> &akb = ref->getKeyBindings();
304                             CMSetStatus(rc, CMPI_RC_OK);
305                     
306                             long i = locateKey(akb,eName);
307                             if (i >= 0)
308                             {
309                                 key2CMPIData(akb[i].getValue(),akb[i].getType(),&data);
310                                 return data;
311                             }
312                             CMSetStatus(rc, CMPI_RC_ERR_NOT_FOUND);
313                             return data;
314                         }
315                     
316                         static CMPIData refGetKeyAt(
317                             const CMPIObjectPath* eRef,
318                             unsigned pos,
319                             CMPIString** name,
320 venkat.puvvada 1.23         CMPIStatus* rc)
321                         {
322                             CIMObjectPath* ref = (CIMObjectPath*)eRef->hdl;
323                             CMPIData data = {0, CMPI_nullValue | CMPI_notFound, {0}};
324                     
325                             if (!ref)
326                             {
327 ms.aruran      1.24             PEG_TRACE_CSTRING(
328                                     TRC_CMPIPROVIDERINTERFACE,
329 marek          1.26                 Tracer::LEVEL1,
330 ms.aruran      1.24                 "Received invalid handle in CMPIObjectPath:refGetKeyAt");
331 venkat.puvvada 1.23             CMSetStatus(rc, CMPI_RC_ERR_INVALID_HANDLE);
332                                 return data;
333                             }
334                     
335                             const Array<CIMKeyBinding> &akb = ref->getKeyBindings();
336                             CMSetStatus(rc, CMPI_RC_OK);
337                     
338                             if (pos >= akb.size())
339                             {
340 ms.aruran      1.24             PEG_TRACE_CSTRING(
341                                     TRC_CMPIPROVIDERINTERFACE,
342 marek          1.26                 Tracer::LEVEL1,
343 ms.aruran      1.24                 "Property Not Found - CMPIObjectPath:refGetKeyAt");
344 venkat.puvvada 1.23             CMSetStatus(rc, CMPI_RC_ERR_NO_SUCH_PROPERTY);
345                                 return data;
346                             }
347                     
348                             key2CMPIData(akb[pos].getValue(),akb[pos].getType(),&data);
349                     
350                             if (name)
351                             {
352                                 const String &n = akb[pos].getName().getString();
353                                 *name = (CMPIString*)string2CMPIString(n);
354                             }
355                             return data;
356                         }
357                     
358                         static CMPICount refGetKeyCount(const CMPIObjectPath* eRef, CMPIStatus* rc)
359                         {
360                             CIMObjectPath* ref = (CIMObjectPath*)eRef->hdl;
361                             if (!ref)
362                             {
363 ms.aruran      1.24             PEG_TRACE_CSTRING(
364                                     TRC_CMPIPROVIDERINTERFACE,
365 marek          1.26                 Tracer::LEVEL1,
366 ms.aruran      1.24                 "Received invalid handle in CMPIObjectPath:refGetKeyCount");
367 venkat.puvvada 1.23             CMSetStatus(rc, CMPI_RC_ERR_INVALID_HANDLE);
368                                 return 0;
369                             }
370                             const Array<CIMKeyBinding> &akb = ref->getKeyBindings();
371                             CMSetStatus(rc, CMPI_RC_OK);
372                             return akb.size();
373                         }
374                     
375                         static CMPIStatus refSetNameSpaceFromObjectPath(
376                             CMPIObjectPath* eRef,
377                             const CMPIObjectPath* eSrc)
378                         {
379                             CIMObjectPath* ref = (CIMObjectPath*)eRef->hdl;
380                             CIMObjectPath* src = (CIMObjectPath*)eSrc->hdl;
381                             if (!ref || !src)
382                             {
383 ms.aruran      1.24             PEG_TRACE_CSTRING(
384                                     TRC_CMPIPROVIDERINTERFACE,
385 marek          1.26                 Tracer::LEVEL1,
386 ms.aruran      1.24                 "Received invalid handle in \
387                                     CMPIObjectPath:refSetNameSpaceFromObjectPath");
388 venkat.puvvada 1.23             CMReturn(CMPI_RC_ERR_INVALID_HANDLE);
389                             }
390                             ref->setNameSpace(src->getNameSpace());
391                             CMReturn(CMPI_RC_OK);
392                         }
393                     
394                         static CMPIStatus refSetHostAndNameSpaceFromObjectPath(
395                             CMPIObjectPath* eRef,
396                             const CMPIObjectPath* eSrc)
397                         {
398                             CIMObjectPath* ref = (CIMObjectPath*)eRef->hdl;
399                             CIMObjectPath* src = (CIMObjectPath*)eSrc->hdl;
400                             if (!ref || !src)
401                             {
402 ms.aruran      1.24             PEG_TRACE_CSTRING(
403                                     TRC_CMPIPROVIDERINTERFACE,
404 marek          1.26                 Tracer::LEVEL1,
405 ms.aruran      1.24                 "Received invalid handle in \
406                                     CMPIObjectPath:refSetHostAndNameSpaceFromObjectPath");
407 venkat.puvvada 1.23             CMReturn(CMPI_RC_ERR_INVALID_HANDLE);
408                             }
409                             ref->setNameSpace(src->getNameSpace());
410                             ref->setHost(src->getHost());
411                             CMReturn(CMPI_RC_OK);
412                         }
413                     
414                         static CMPIString *refToString(const CMPIObjectPath* eRef, CMPIStatus* rc)
415                         {
416                             CIMObjectPath* ref = (CIMObjectPath*)eRef->hdl;
417                             if (!ref)
418                             {
419 ms.aruran      1.24             PEG_TRACE_CSTRING(
420                                     TRC_CMPIPROVIDERINTERFACE,
421 marek          1.26                 Tracer::LEVEL1,
422 ms.aruran      1.24                 "Received invalid handle in CMPIObjectPath:refToString");
423 venkat.puvvada 1.23             CMSetStatus(rc, CMPI_RC_ERR_INVALID_HANDLE);
424                                 return NULL;
425                             }
426                             String str = ref->toString();
427                             CMSetStatus(rc, CMPI_RC_OK);
428                             return reinterpret_cast<CMPIString*>(new CMPI_Object(str));
429                         }
430 schuur         1.1  
431                     }
432                     
433 venkat.puvvada 1.23 CMPIObjectPathFT objectPath_FT =
434                     {
435                         CMPICurrentVersion,
436                         refRelease,
437                         refClone,
438                         refSetNameSpace,
439                         refGetNameSpace,
440                         refSetHostname,
441                         refGetHostname,
442                         refSetClassName,
443                         refGetClassName,
444                         refAddKey,
445                         refGetKey,
446                         refGetKeyAt,
447                         refGetKeyCount,
448                         refSetNameSpaceFromObjectPath,
449                         refSetHostAndNameSpaceFromObjectPath,
450                         NULL,
451                         NULL,
452                         NULL,
453                         NULL,
454 venkat.puvvada 1.23     refToString
455 schuur         1.1  };
456                     
457 venkat.puvvada 1.23 CMPIObjectPathFT *CMPI_ObjectPath_Ftab = &objectPath_FT;
458 schuur         1.1  
459 venkat.puvvada 1.23 CMPIObjectPathFT objectPathOnStack_FT =
460                     {
461                         CMPICurrentVersion,
462                         refReleaseNop,
463                         refClone,
464                         refSetNameSpace,
465                         refGetNameSpace,
466                         refSetHostname,
467                         refGetHostname,
468                         refSetClassName,
469                         refGetClassName,
470                         refAddKey,
471                         refGetKey,
472                         refGetKeyAt,
473                         refGetKeyCount,
474                         refSetNameSpaceFromObjectPath,
475                         refSetHostAndNameSpaceFromObjectPath,
476                         NULL,
477                         NULL,
478                         NULL,
479                         NULL,
480 venkat.puvvada 1.23     refToString
481 schuur         1.1  };
482                     
483 venkat.puvvada 1.23 CMPIObjectPathFT *CMPI_ObjectPathOnStack_Ftab = &objectPathOnStack_FT;
484 schuur         1.1  
485                     
486 venkat.puvvada 1.23 CMPI_ObjectPathOnStack::CMPI_ObjectPathOnStack(const CIMObjectPath& cop)
487                     {
488                         hdl = (void*)&cop;
489                         ft = CMPI_ObjectPathOnStack_Ftab;
490                     }
491 schuur         1.1  
492                     
493                     PEGASUS_NAMESPACE_END
494                     

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2