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

  1 karl  1.18 //%2006////////////////////////////////////////////////////////////////////////
  2 schuur 1.1  //
  3 karl   1.11 // 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 schuur 1.1  // IBM Corp.; EMC Corporation, The Open Group.
  7 karl   1.11 // 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.13 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 10             // EMC Corporation; VERITAS Software Corporation; The Open Group.
 11 karl   1.18 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 12             // EMC Corporation; Symantec Corporation; The Open Group.
 13 schuur 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 venkat.puvvada 1.23 //
 21 schuur         1.1  // 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                     //%/////////////////////////////////////////////////////////////////////////////
 33                     
 34 schuur         1.5  #include "CMPI_Version.h"
 35 schuur         1.3  
 36 schuur         1.1  #include "CMPI_ObjectPath.h"
 37                     
 38                     #include "CMPI_Ftabs.h"
 39                     #include "CMPI_Value.h"
 40                     #include "CMPI_String.h"
 41                     
 42                     PEGASUS_USING_STD;
 43                     PEGASUS_NAMESPACE_BEGIN
 44                     
 45 venkat.puvvada 1.23 extern "C"
 46                     {
 47 schuur         1.1  
 48 venkat.puvvada 1.23     static CMPIStatus refRelease(CMPIObjectPath* eRef)
 49                         {
 50                             CIMObjectPath* ref = (CIMObjectPath*)eRef->hdl;
 51                             if (ref)
 52                             {
 53                                 delete ref;
 54                                 (reinterpret_cast<CMPI_Object*>(eRef))->unlinkAndDelete();
 55                                 CMReturn(CMPI_RC_OK);
 56                             }
 57                             CMReturn(CMPI_RC_ERR_INVALID_HANDLE);
 58                         }
 59                     
 60                         static CMPIStatus refReleaseNop(CMPIObjectPath* eRef)
 61                         {
 62                             CMReturn(CMPI_RC_OK);
 63                         }
 64                     
 65                         static CMPIObjectPath* refClone(const CMPIObjectPath* eRef, CMPIStatus* rc)
 66                         {
 67                             CIMObjectPath *ref=(CIMObjectPath*)eRef->hdl;
 68                             if (!ref)
 69 venkat.puvvada 1.23         {
 70                                 CMSetStatus(rc, CMPI_RC_ERR_INVALID_HANDLE);
 71                                 return NULL;
 72                             }
 73                             CIMObjectPath *nRef = new CIMObjectPath(
 74                                 ref->getHost(),
 75                                 ref->getNameSpace(),
 76                                 ref->getClassName());
 77                     
 78                             Array<CIMKeyBinding> kb = ref->getKeyBindings();
 79                             nRef->setKeyBindings(kb);
 80                             CMPI_Object* obj = new CMPI_Object(nRef);
 81                             obj->unlink();
 82                             CMPIObjectPath* neRef = reinterpret_cast<CMPIObjectPath*>(obj);
 83                             CMSetStatus(rc, CMPI_RC_OK);
 84                             return neRef;
 85                         }
 86                     
 87                         static CMPIStatus refSetNameSpace(CMPIObjectPath* eRef, const char *ns)
 88                         {
 89                             CIMObjectPath* ref = (CIMObjectPath*)eRef->hdl;
 90 venkat.puvvada 1.23         if (!ref)
 91                             {
 92                                 CMReturn(CMPI_RC_ERR_INVALID_HANDLE);
 93                             }
 94                             if (!ns)
 95                             {
 96                                 CMReturn(CMPI_RC_ERR_INVALID_PARAMETER);
 97                             }
 98                             ref->setNameSpace(String(ns));
 99                             CMReturn(CMPI_RC_OK);
100                         }
101                     
102                         static CMPIString* refGetNameSpace(
103                             const CMPIObjectPath* eRef,
104                             CMPIStatus* rc)
105                         {
106                             CIMObjectPath* ref = (CIMObjectPath*)eRef->hdl;
107                             if (!ref)
108                             {
109                                 CMSetStatus(rc, CMPI_RC_ERR_INVALID_HANDLE);
110                                 return NULL;
111 venkat.puvvada 1.23         }
112                             const CIMNamespaceName &ns = ref->getNameSpace();
113                             CMPIString *eNs = (CMPIString*)string2CMPIString(ns.getString());
114                             CMSetStatus(rc, CMPI_RC_OK);
115                             return eNs;
116                         }
117                     
118                         static CMPIStatus refSetHostname(CMPIObjectPath* eRef, const char *hn)
119                         {
120                             CIMObjectPath* ref = (CIMObjectPath*)eRef->hdl;
121                             if (!ref)
122                             {
123                                 CMReturn(CMPI_RC_ERR_INVALID_HANDLE);
124                             }
125                             if (!hn)
126                             {
127                                 CMReturn(CMPI_RC_ERR_INVALID_PARAMETER);
128                             }
129                             ref->setHost(String(hn));
130                             CMReturn(CMPI_RC_OK);
131                         }
132 venkat.puvvada 1.23 
133                         static CMPIString* refGetHostname(
134                             const CMPIObjectPath* eRef,
135                             CMPIStatus* rc)
136                         {
137                             CIMObjectPath* ref = (CIMObjectPath*)eRef->hdl;
138                             if (!ref)
139                             {
140                                 CMSetStatus(rc, CMPI_RC_ERR_INVALID_HANDLE);
141                                 return NULL;
142                             }
143                             const String &hn = ref->getHost();
144                             CMPIString *eHn = (CMPIString*)string2CMPIString(hn);
145                             CMSetStatus(rc, CMPI_RC_OK);
146                             return eHn;
147                         }
148                     
149                         static CMPIStatus refSetClassName(CMPIObjectPath* eRef, const char *cn)
150                         {
151                             CIMObjectPath* ref = (CIMObjectPath*)eRef->hdl;
152                             if (!ref)
153 venkat.puvvada 1.23         {
154                                 CMReturn(CMPI_RC_ERR_INVALID_HANDLE);
155                             }
156                             if (!cn)
157                             {
158                                 CMReturn(CMPI_RC_ERR_INVALID_PARAMETER);
159                             }
160                             ref->setClassName(String(cn));
161                             CMReturn(CMPI_RC_OK);
162                         }
163                     
164                         static CMPIString* refGetClassName(
165                             const CMPIObjectPath* eRef,
166                             CMPIStatus* rc)
167                         {
168                             CIMObjectPath* ref = (CIMObjectPath*)eRef->hdl;
169                             if (!ref)
170                             {
171                                 CMSetStatus(rc, CMPI_RC_ERR_INVALID_HANDLE);
172                                 return NULL;
173                             }
174 venkat.puvvada 1.23         const CIMName &cn = ref->getClassName();
175                             CMPIString* eCn = (CMPIString*)string2CMPIString(cn.getString());
176                             CMSetStatus(rc, CMPI_RC_OK);
177                             return eCn;
178                         }
179                     
180                     
181                         static long locateKey(const Array<CIMKeyBinding> &kb, const CIMName &eName)
182                         {
183                             for (unsigned long i=0,s=kb.size(); i<s; i++)
184                             {
185                                 const String &n = kb[i].getName().getString();
186                                 if (String::equalNoCase(n,eName.getString()))
187                                 {
188                                     return i;
189                                 }
190                             }
191                             return -1;
192                         }
193                     
194                         static CMPIStatus refAddKey(
195 venkat.puvvada 1.23         CMPIObjectPath* eRef,
196                             const char *name,
197                             const CMPIValue* data,
198                             const CMPIType type)
199                         {
200                             CIMObjectPath* ref = (CIMObjectPath*)eRef->hdl;
201                             if (!ref)
202                             {
203                                 CMReturn(CMPI_RC_ERR_INVALID_HANDLE);
204                             }
205                             if (!name)
206                             {
207                                 CMReturn(CMPI_RC_ERR_INVALID_PARAMETER);
208                             }
209                             Array<CIMKeyBinding> keyBindings = ref->getKeyBindings();
210                             CIMName key(name);
211                             CMPIrc rc;
212                     
213                             long i = locateKey(keyBindings,key);
214                             if (i >= 0)
215                             {
216 venkat.puvvada 1.23             keyBindings.remove(i);
217                             }
218                     
219                             CIMValue val = value2CIMValue(data,type,&rc);
220                             keyBindings.append(CIMKeyBinding(key,val));
221                             ref->setKeyBindings(Array<CIMKeyBinding>(keyBindings));
222                             CMReturn(CMPI_RC_OK);
223                         }
224                     
225                         static CMPIData refGetKey(
226                             const CMPIObjectPath* eRef,
227                             const char *name,
228                             CMPIStatus* rc)
229                         {
230                             CIMObjectPath* ref = (CIMObjectPath*)eRef->hdl;
231                             CMPIData data = {0, CMPI_nullValue | CMPI_notFound, {0}};
232                     
233                             if (!ref)
234                             {
235                                 CMSetStatus(rc, CMPI_RC_ERR_INVALID_HANDLE);
236                                 return data;
237 venkat.puvvada 1.23         }
238                             if (!name)
239                             {
240                                 CMSetStatus(rc, CMPI_RC_ERR_INVALID_PARAMETER);
241                                 return data;
242                             }
243                             const CIMName eName(name);
244                             const Array<CIMKeyBinding> &akb = ref->getKeyBindings();
245                             CMSetStatus(rc, CMPI_RC_OK);
246                     
247                             long i = locateKey(akb,eName);
248                             if (i >= 0)
249                             {
250                                 key2CMPIData(akb[i].getValue(),akb[i].getType(),&data);
251                                 return data;
252                             }
253                             CMSetStatus(rc, CMPI_RC_ERR_NOT_FOUND);
254                             return data;
255                         }
256                     
257                         static CMPIData refGetKeyAt(
258 venkat.puvvada 1.23         const CMPIObjectPath* eRef,
259                             unsigned pos,
260                             CMPIString** name,
261                             CMPIStatus* rc)
262                         {
263                             CIMObjectPath* ref = (CIMObjectPath*)eRef->hdl;
264                             CMPIData data = {0, CMPI_nullValue | CMPI_notFound, {0}};
265                     
266                             if (!ref)
267                             {
268                                 CMSetStatus(rc, CMPI_RC_ERR_INVALID_HANDLE);
269                                 return data;
270                             }
271                     
272                             const Array<CIMKeyBinding> &akb = ref->getKeyBindings();
273                             CMSetStatus(rc, CMPI_RC_OK);
274                     
275                             if (pos >= akb.size())
276                             {
277                                 CMSetStatus(rc, CMPI_RC_ERR_NO_SUCH_PROPERTY);
278                                 return data;
279 venkat.puvvada 1.23         }
280                     
281                             key2CMPIData(akb[pos].getValue(),akb[pos].getType(),&data);
282                     
283                             if (name)
284                             {
285                                 const String &n = akb[pos].getName().getString();
286                                 *name = (CMPIString*)string2CMPIString(n);
287                             }
288                             return data;
289                         }
290                     
291                         static CMPICount refGetKeyCount(const CMPIObjectPath* eRef, CMPIStatus* rc)
292                         {
293                             CIMObjectPath* ref = (CIMObjectPath*)eRef->hdl;
294                             if (!ref)
295                             {
296                                 CMSetStatus(rc, CMPI_RC_ERR_INVALID_HANDLE);
297                                 return 0;
298                             }
299                             const Array<CIMKeyBinding> &akb = ref->getKeyBindings();
300 venkat.puvvada 1.23         CMSetStatus(rc, CMPI_RC_OK);
301                             return akb.size();
302                         }
303                     
304                         static CMPIStatus refSetNameSpaceFromObjectPath(
305                             CMPIObjectPath* eRef,
306                             const CMPIObjectPath* eSrc)
307                         {
308                             CIMObjectPath* ref = (CIMObjectPath*)eRef->hdl;
309                             CIMObjectPath* src = (CIMObjectPath*)eSrc->hdl;
310                             if (!ref || !src)
311                             {
312                                 CMReturn(CMPI_RC_ERR_INVALID_HANDLE);
313                             }
314                             ref->setNameSpace(src->getNameSpace());
315                             CMReturn(CMPI_RC_OK);
316                         }
317                     
318                         static CMPIStatus refSetHostAndNameSpaceFromObjectPath(
319                             CMPIObjectPath* eRef,
320                             const CMPIObjectPath* eSrc)
321 venkat.puvvada 1.23     {
322                             CIMObjectPath* ref = (CIMObjectPath*)eRef->hdl;
323                             CIMObjectPath* src = (CIMObjectPath*)eSrc->hdl;
324                             if (!ref || !src)
325                             {
326                                 CMReturn(CMPI_RC_ERR_INVALID_HANDLE);
327                             }
328                             ref->setNameSpace(src->getNameSpace());
329                             ref->setHost(src->getHost());
330                             CMReturn(CMPI_RC_OK);
331                         }
332                     
333                         static CMPIString *refToString(const CMPIObjectPath* eRef, CMPIStatus* rc)
334                         {
335                             CIMObjectPath* ref = (CIMObjectPath*)eRef->hdl;
336                             if (!ref)
337                             {
338                                 CMSetStatus(rc, CMPI_RC_ERR_INVALID_HANDLE);
339                                 return NULL;
340                             }
341                             String str = ref->toString();
342 venkat.puvvada 1.23         CMSetStatus(rc, CMPI_RC_OK);
343                             return reinterpret_cast<CMPIString*>(new CMPI_Object(str));
344                         }
345 schuur         1.1  
346                     }
347                     
348 venkat.puvvada 1.23 CMPIObjectPathFT objectPath_FT =
349                     {
350                         CMPICurrentVersion,
351                         refRelease,
352                         refClone,
353                         refSetNameSpace,
354                         refGetNameSpace,
355                         refSetHostname,
356                         refGetHostname,
357                         refSetClassName,
358                         refGetClassName,
359                         refAddKey,
360                         refGetKey,
361                         refGetKeyAt,
362                         refGetKeyCount,
363                         refSetNameSpaceFromObjectPath,
364                         refSetHostAndNameSpaceFromObjectPath,
365                         NULL,
366                         NULL,
367                         NULL,
368                         NULL,
369 venkat.puvvada 1.23     refToString
370 schuur         1.1  };
371                     
372 venkat.puvvada 1.23 CMPIObjectPathFT *CMPI_ObjectPath_Ftab = &objectPath_FT;
373 schuur         1.1  
374 venkat.puvvada 1.23 CMPIObjectPathFT objectPathOnStack_FT =
375                     {
376                         CMPICurrentVersion,
377                         refReleaseNop,
378                         refClone,
379                         refSetNameSpace,
380                         refGetNameSpace,
381                         refSetHostname,
382                         refGetHostname,
383                         refSetClassName,
384                         refGetClassName,
385                         refAddKey,
386                         refGetKey,
387                         refGetKeyAt,
388                         refGetKeyCount,
389                         refSetNameSpaceFromObjectPath,
390                         refSetHostAndNameSpaceFromObjectPath,
391                         NULL,
392                         NULL,
393                         NULL,
394                         NULL,
395 venkat.puvvada 1.23     refToString
396 schuur         1.1  };
397                     
398 venkat.puvvada 1.23 CMPIObjectPathFT *CMPI_ObjectPathOnStack_Ftab = &objectPathOnStack_FT;
399 schuur         1.1  
400                     
401 venkat.puvvada 1.23 CMPI_ObjectPathOnStack::CMPI_ObjectPathOnStack(const CIMObjectPath& cop)
402                     {
403                         hdl = (void*)&cop;
404                         ft = CMPI_ObjectPathOnStack_Ftab;
405                     }
406 schuur         1.1  
407                     
408                     PEGASUS_NAMESPACE_END
409                     

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2