(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 karl   1.11 // 
 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             // Author:      Adrian Schuur, schuur@de.ibm.com
 33             //
 34             // Modified By:
 35             //
 36             //%/////////////////////////////////////////////////////////////////////////////
 37             
 38 schuur 1.5  #include "CMPI_Version.h"
 39 schuur 1.3  
 40 schuur 1.1  #include "CMPI_ObjectPath.h"
 41             
 42             #include "CMPI_Ftabs.h"
 43             #include "CMPI_Value.h"
 44             #include "CMPI_String.h"
 45             
 46             PEGASUS_USING_STD;
 47             PEGASUS_NAMESPACE_BEGIN
 48             
 49 schuur 1.10 extern "C" {
 50 schuur 1.1  
 51 schuur 1.10    static CMPIStatus refRelease(CMPIObjectPath* eRef) {
 52                //   cout<<"--- refRelease()"<<endl;
 53                   CIMObjectPath* ref=(CIMObjectPath*)eRef->hdl;
 54                   if (ref) {
 55                      delete ref;
 56 mreddy 1.19          (reinterpret_cast<CMPI_Object*>(eRef))->unlinkAndDelete();
 57 schuur 1.10       }
 58                   CMReturn(CMPI_RC_OK);
 59                }
 60             
 61                static CMPIStatus refReleaseNop(CMPIObjectPath* eRef) {
 62                   CMReturn(CMPI_RC_OK);
 63                }
 64             
 65 konrad.r 1.14    static CMPIObjectPath* refClone(const CMPIObjectPath* eRef, CMPIStatus* rc) {
 66 schuur   1.10    //   cout<<"--- refClone()"<<endl;
 67                     CIMObjectPath *ref=(CIMObjectPath*)eRef->hdl;
 68 konrad.r 1.12 	  if (!ref) {
 69               		if (rc) CMSetStatus(rc, CMPI_RC_ERR_INVALID_PARAMETER);
 70               	    return NULL;
 71               	  }
 72 schuur   1.10       CIMObjectPath *nRef=new CIMObjectPath(ref->getHost(),
 73                                                            ref->getNameSpace(),
 74                                 ref->getClassName());
 75                     Array<CIMKeyBinding> kb=ref->getKeyBindings();
 76                     nRef->setKeyBindings(kb);
 77                     CMPI_Object* obj=new CMPI_Object(nRef);
 78                     obj->unlink();
 79 mreddy   1.19       CMPIObjectPath* neRef=reinterpret_cast<CMPIObjectPath*>(obj);
 80 schuur   1.10       if (rc) CMSetStatus(rc,CMPI_RC_OK);
 81                     return neRef;
 82                  }
 83               
 84                  static CMPIStatus refSetNameSpace(CMPIObjectPath* eRef, const char *ns) {
 85                     CIMObjectPath* ref=(CIMObjectPath*)eRef->hdl;
 86 konrad.r 1.12 	  if (!ref) 
 87               		CMReturn( CMPI_RC_ERR_INVALID_PARAMETER);
 88 schuur   1.10       ref->setNameSpace(String(ns));
 89                     CMReturn(CMPI_RC_OK);
 90                  }
 91               
 92 konrad.r 1.14    static CMPIString* refGetNameSpace(const CMPIObjectPath* eRef, CMPIStatus* rc) {
 93 schuur   1.10       CIMObjectPath* ref=(CIMObjectPath*)eRef->hdl;
 94 konrad.r 1.12 	  if (!ref) {
 95               		if (rc) CMSetStatus(rc, CMPI_RC_ERR_INVALID_PARAMETER);
 96               	    return NULL;
 97                     }
 98 schuur   1.10       const CIMNamespaceName &ns=ref->getNameSpace();
 99                     CMPIString *eNs=(CMPIString*)string2CMPIString(ns.getString());
100                     if (rc) CMSetStatus(rc,CMPI_RC_OK);
101                     return eNs;
102                  }
103               
104                  static CMPIStatus refSetHostname(CMPIObjectPath* eRef, const char *hn) {
105                     CIMObjectPath* ref=(CIMObjectPath*)eRef->hdl;
106 konrad.r 1.12 	  if (!ref) 
107               		CMReturn( CMPI_RC_ERR_INVALID_PARAMETER);
108 schuur   1.10       ref->setHost(String(hn));
109                     CMReturn(CMPI_RC_OK);
110                  }
111               
112 konrad.r 1.14    static CMPIString* refGetHostname(const CMPIObjectPath* eRef, CMPIStatus* rc) {
113 schuur   1.10       CIMObjectPath* ref=(CIMObjectPath*)eRef->hdl;
114 konrad.r 1.12 	  if (!ref) {
115               		if (rc) CMSetStatus(rc, CMPI_RC_ERR_INVALID_PARAMETER);
116               	    return NULL;
117                     }
118 schuur   1.10       const String &hn=ref->getHost();
119                     CMPIString *eHn=(CMPIString*)string2CMPIString(hn);
120                     if (rc) CMSetStatus(rc,CMPI_RC_OK);
121                     return eHn;
122                  }
123               
124                  static CMPIStatus refSetClassName(CMPIObjectPath* eRef, const char *cn) {
125                     CIMObjectPath* ref=(CIMObjectPath*)eRef->hdl;
126 konrad.r 1.12 	  if (!ref) 
127               		CMReturn(CMPI_RC_ERR_INVALID_PARAMETER);
128                     
129 schuur   1.10       ref->setClassName(String(cn));
130                     CMReturn(CMPI_RC_OK);
131                  }
132               
133 konrad.r 1.14    static CMPIString* refGetClassName(const CMPIObjectPath* eRef, CMPIStatus* rc) {
134 schuur   1.10       CIMObjectPath* ref=(CIMObjectPath*)eRef->hdl;
135 konrad.r 1.12 	  if (!ref) {
136               		if (rc) CMSetStatus(rc, CMPI_RC_ERR_INVALID_PARAMETER);
137               	    return NULL;
138                     }
139 schuur   1.10       const CIMName &cn=ref->getClassName();
140                     CMPIString* eCn=(CMPIString*)string2CMPIString(cn.getString());
141                     if (rc) CMSetStatus(rc,CMPI_RC_OK);
142                     return eCn;
143                  }
144               
145               
146                  static long locateKey(const Array<CIMKeyBinding> &kb, const CIMName &eName) {
147                     for (unsigned long i=0,s=kb.size(); i<s; i++) {
148                        const String &n=kb[i].getName().getString();
149                        if (String::equalNoCase(n,eName.getString())) return i;
150                     }
151                     return -1;
152                  }
153               
154                  static CMPIStatus refAddKey(CMPIObjectPath* eRef, const char *name,
155 konrad.r 1.17             const CMPIValue* data,  CMPIType type) {
156 schuur   1.10       CIMObjectPath* ref=(CIMObjectPath*)eRef->hdl;
157 konrad.r 1.12 	  if (!ref) 
158               		CMReturn( CMPI_RC_ERR_INVALID_PARAMETER);
159 schuur   1.10       Array<CIMKeyBinding> keyBindings=ref->getKeyBindings();
160                     CIMName key(name);
161                     CMPIrc rc;
162               
163                     long i=locateKey(keyBindings,key);
164                     if (i>=0) keyBindings.remove(i);
165               
166                     CIMValue val=value2CIMValue(data,type,&rc);
167                     keyBindings.append(CIMKeyBinding(key,val));
168                     ref->setKeyBindings(Array<CIMKeyBinding>(keyBindings));
169                     CMReturn(CMPI_RC_OK);
170                  }
171               
172 konrad.r 1.14    static CMPIData refGetKey(const CMPIObjectPath* eRef, const char *name, CMPIStatus* rc) {
173 schuur   1.10       CIMObjectPath* ref=(CIMObjectPath*)eRef->hdl;
174 konrad.r 1.12       CMPIData data={0,CMPI_nullValue|CMPI_notFound,{0}};
175               
176               	  if (!ref) {
177               		if (rc) CMSetStatus(rc, CMPI_RC_ERR_INVALID_PARAMETER);
178               	    return data;
179                     }
180               
181 schuur   1.10       const CIMName eName(name);
182                     const Array<CIMKeyBinding> &akb=ref->getKeyBindings();
183                     if (rc) CMSetStatus(rc,CMPI_RC_OK);
184               
185                     long i=locateKey(akb,eName);
186                     if (i>=0)  {
187                        key2CMPIData(akb[i].getValue(),akb[i].getType(),&data);
188                        return data;
189                     }
190                     if (rc) CMSetStatus(rc,CMPI_RC_ERR_NOT_FOUND);
191                     return data;
192 schuur   1.1     }
193               
194 konrad.r 1.14    static CMPIData refGetKeyAt(const CMPIObjectPath* eRef, unsigned pos, CMPIString** name,
195 schuur   1.10             CMPIStatus* rc) {
196                     CIMObjectPath* ref=(CIMObjectPath*)eRef->hdl;
197 konrad.r 1.12       CMPIData data={0,CMPI_nullValue|CMPI_notFound,{0}};
198               
199               	  if (!ref) {
200               		if (rc) CMSetStatus(rc, CMPI_RC_ERR_INVALID_PARAMETER);
201               	    return data;
202                     }
203               
204 schuur   1.10       const Array<CIMKeyBinding> &akb=ref->getKeyBindings();
205                     if (rc) CMSetStatus(rc,CMPI_RC_OK);
206               
207                     if (pos>=akb.size()) {
208                        if (rc) CMSetStatus(rc,CMPI_RC_ERR_NOT_FOUND);
209                        return data;
210                     }
211               
212                     key2CMPIData(akb[pos].getValue(),akb[pos].getType(),&data);
213               
214                     if (name) {
215                        const String &n=akb[pos].getName().getString();
216                        *name=(CMPIString*)string2CMPIString(n);
217                     }
218 schuur   1.1        return data;
219                  }
220               
221 konrad.r 1.14    static CMPICount refGetKeyCount(const CMPIObjectPath* eRef, CMPIStatus* rc) {
222 schuur   1.10       CIMObjectPath* ref=(CIMObjectPath*)eRef->hdl;
223 konrad.r 1.12 	  if (!ref) {
224               		if (rc) CMSetStatus(rc, CMPI_RC_ERR_INVALID_PARAMETER);
225               	    return 0;
226                     }
227 schuur   1.10       const Array<CIMKeyBinding> &akb=ref->getKeyBindings();
228                     if (rc) CMSetStatus(rc,CMPI_RC_OK);
229                     return akb.size();
230                  }
231               
232                  static CMPIStatus refSetNameSpaceFromObjectPath(CMPIObjectPath* eRef,
233 konrad.r 1.14             const CMPIObjectPath* eSrc) {
234 schuur   1.10       CIMObjectPath* ref=(CIMObjectPath*)eRef->hdl;
235                     CIMObjectPath* src=(CIMObjectPath*)eSrc->hdl;
236 konrad.r 1.12 	  if ((ref == NULL) || (src == NULL)) 
237               		CMReturn( CMPI_RC_ERR_INVALID_PARAMETER);
238               
239 schuur   1.10       ref->setNameSpace(src->getNameSpace());
240                     CMReturn(CMPI_RC_OK);
241                  }
242               
243                  static CMPIStatus refSetHostAndNameSpaceFromObjectPath(CMPIObjectPath* eRef,
244 konrad.r 1.14             const CMPIObjectPath* eSrc) {
245 schuur   1.10       CIMObjectPath* ref=(CIMObjectPath*)eRef->hdl;
246                     CIMObjectPath* src=(CIMObjectPath*)eSrc->hdl;
247 konrad.r 1.12 	  if ((ref==NULL) || (src == NULL))
248               		CMReturn( CMPI_RC_ERR_INVALID_PARAMETER);
249               
250 schuur   1.10       ref->setNameSpace(src->getNameSpace());
251                     ref->setHost(src->getHost());
252                     CMReturn(CMPI_RC_OK);
253                  }
254               
255 konrad.r 1.14    static CMPIString *refToString(const CMPIObjectPath* eRef, CMPIStatus* rc) {
256 schuur   1.10       CIMObjectPath* ref=(CIMObjectPath*)eRef->hdl;
257 konrad.r 1.12 	  if (!ref) {
258               		if (rc) CMSetStatus(rc, CMPI_RC_ERR_INVALID_PARAMETER);
259               	    return NULL;
260                     }
261 schuur   1.10       String str=ref->toString();
262                     if (rc) CMSetStatus(rc,CMPI_RC_OK);
263 mreddy   1.19       return reinterpret_cast<CMPIString*>(new CMPI_Object(str));
264 schuur   1.1     }
265               
266               }
267               
268               CMPIObjectPathFT objectPath_FT={
269                    CMPICurrentVersion,
270                    refRelease,
271                    refClone,
272                    refSetNameSpace,
273                    refGetNameSpace,
274                    refSetHostname,
275                    refGetHostname,
276                    refSetClassName,
277                    refGetClassName,
278                    refAddKey,
279                    refGetKey,
280                    refGetKeyAt,
281                    refGetKeyCount,
282                    refSetNameSpaceFromObjectPath,
283                    refSetHostAndNameSpaceFromObjectPath,
284                    NULL,
285 schuur   1.1       NULL,
286                    NULL,
287 schuur   1.2       NULL,
288                    refToString
289 schuur   1.1  };
290               
291               CMPIObjectPathFT *CMPI_ObjectPath_Ftab=&objectPath_FT;
292               
293               CMPIObjectPathFT objectPathOnStack_FT={
294                    CMPICurrentVersion,
295                    refReleaseNop,
296                    refClone,
297                    refSetNameSpace,
298                    refGetNameSpace,
299                    refSetHostname,
300                    refGetHostname,
301                    refSetClassName,
302                    refGetClassName,
303                    refAddKey,
304                    refGetKey,
305                    refGetKeyAt,
306                    refGetKeyCount,
307                    refSetNameSpaceFromObjectPath,
308                    refSetHostAndNameSpaceFromObjectPath,
309                    NULL,
310 schuur   1.1       NULL,
311                    NULL,
312 schuur   1.2       NULL,
313                    refToString
314 schuur   1.1  };
315               
316               CMPIObjectPathFT *CMPI_ObjectPathOnStack_Ftab=&objectPathOnStack_FT;
317               
318               
319               CMPI_ObjectPathOnStack::CMPI_ObjectPathOnStack(const CIMObjectPath& cop) {
320                     hdl=(void*)&cop;
321                     ft=CMPI_ObjectPathOnStack_Ftab;
322                  }
323               
324               
325               PEGASUS_NAMESPACE_END
326               

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2