1 karl 1.11 //%2004////////////////////////////////////////////////////////////////////////
|
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 schuur 1.1 //
10 // Permission is hereby granted, free of charge, to any person obtaining a copy
11 // of this software and associated documentation files (the "Software"), to
12 // deal in the Software without restriction, including without limitation the
13 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
14 // sell copies of the Software, and to permit persons to whom the Software is
15 // furnished to do so, subject to the following conditions:
|
16 karl 1.11 //
|
17 schuur 1.1 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
18 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
19 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
20 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
21 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
23 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 //
26 //==============================================================================
27 //
28 // Author: Adrian Schuur, schuur@de.ibm.com
29 //
30 // Modified By:
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 schuur 1.10 extern "C" {
|
46 schuur 1.1
|
47 schuur 1.10 static CMPIStatus refRelease(CMPIObjectPath* eRef) {
48 // cout<<"--- refRelease()"<<endl;
49 CIMObjectPath* ref=(CIMObjectPath*)eRef->hdl;
50 if (ref) {
51 delete ref;
52 ((CMPI_Object*)eRef)->unlinkAndDelete();
53 }
54 CMReturn(CMPI_RC_OK);
55 }
56
57 static CMPIStatus refReleaseNop(CMPIObjectPath* eRef) {
58 CMReturn(CMPI_RC_OK);
59 }
60
61 static CMPIObjectPath* refClone(CMPIObjectPath* eRef, CMPIStatus* rc) {
62 // cout<<"--- refClone()"<<endl;
63 CIMObjectPath *ref=(CIMObjectPath*)eRef->hdl;
64 CIMObjectPath *nRef=new CIMObjectPath(ref->getHost(),
65 ref->getNameSpace(),
66 ref->getClassName());
67 Array<CIMKeyBinding> kb=ref->getKeyBindings();
68 schuur 1.10 nRef->setKeyBindings(kb);
69 CMPI_Object* obj=new CMPI_Object(nRef);
70 obj->unlink();
71 CMPIObjectPath* neRef=(CMPIObjectPath*)obj;
72 if (rc) CMSetStatus(rc,CMPI_RC_OK);
73 return neRef;
74 }
75
76 static CMPIStatus refSetNameSpace(CMPIObjectPath* eRef, const char *ns) {
77 CIMObjectPath* ref=(CIMObjectPath*)eRef->hdl;
78 ref->setNameSpace(String(ns));
79 CMReturn(CMPI_RC_OK);
80 }
81
82 static CMPIString* refGetNameSpace(CMPIObjectPath* eRef, CMPIStatus* rc) {
83 CIMObjectPath* ref=(CIMObjectPath*)eRef->hdl;
84 const CIMNamespaceName &ns=ref->getNameSpace();
85 CMPIString *eNs=(CMPIString*)string2CMPIString(ns.getString());
86 if (rc) CMSetStatus(rc,CMPI_RC_OK);
87 return eNs;
88 }
89 schuur 1.10
90 static CMPIStatus refSetHostname(CMPIObjectPath* eRef, const char *hn) {
91 CIMObjectPath* ref=(CIMObjectPath*)eRef->hdl;
92 ref->setHost(String(hn));
93 CMReturn(CMPI_RC_OK);
94 }
95
96 static CMPIString* refGetHostname(CMPIObjectPath* eRef, CMPIStatus* rc) {
97 CIMObjectPath* ref=(CIMObjectPath*)eRef->hdl;
98 const String &hn=ref->getHost();
99 CMPIString *eHn=(CMPIString*)string2CMPIString(hn);
100 if (rc) CMSetStatus(rc,CMPI_RC_OK);
101 return eHn;
102 }
103
104 static CMPIStatus refSetClassName(CMPIObjectPath* eRef, const char *cn) {
105 CIMObjectPath* ref=(CIMObjectPath*)eRef->hdl;
106 ref->setClassName(String(cn));
107 CMReturn(CMPI_RC_OK);
108 }
109
110 schuur 1.10 static CMPIString* refGetClassName(CMPIObjectPath* eRef, CMPIStatus* rc) {
111 CIMObjectPath* ref=(CIMObjectPath*)eRef->hdl;
112 const CIMName &cn=ref->getClassName();
113 CMPIString* eCn=(CMPIString*)string2CMPIString(cn.getString());
114 if (rc) CMSetStatus(rc,CMPI_RC_OK);
115 return eCn;
116 }
117
118
119 static long locateKey(const Array<CIMKeyBinding> &kb, const CIMName &eName) {
120 for (unsigned long i=0,s=kb.size(); i<s; i++) {
121 const String &n=kb[i].getName().getString();
122 if (String::equalNoCase(n,eName.getString())) return i;
123 }
124 return -1;
125 }
126
127 static CMPIStatus refAddKey(CMPIObjectPath* eRef, const char *name,
128 CMPIValue* data, CMPIType type) {
129 CIMObjectPath* ref=(CIMObjectPath*)eRef->hdl;
130 Array<CIMKeyBinding> keyBindings=ref->getKeyBindings();
131 schuur 1.10 CIMName key(name);
132 CMPIrc rc;
133
134 long i=locateKey(keyBindings,key);
135 if (i>=0) keyBindings.remove(i);
136
137 CIMValue val=value2CIMValue(data,type,&rc);
138 keyBindings.append(CIMKeyBinding(key,val));
139 ref->setKeyBindings(Array<CIMKeyBinding>(keyBindings));
140 CMReturn(CMPI_RC_OK);
141 }
142
143 static CMPIData refGetKey(CMPIObjectPath* eRef, const char *name, CMPIStatus* rc) {
144 CIMObjectPath* ref=(CIMObjectPath*)eRef->hdl;
145 const CIMName eName(name);
146 const Array<CIMKeyBinding> &akb=ref->getKeyBindings();
147 CMPIData data={0,CMPI_nullValue|CMPI_notFound,{0}};
148 if (rc) CMSetStatus(rc,CMPI_RC_OK);
149
150 long i=locateKey(akb,eName);
151 if (i>=0) {
152 schuur 1.10 key2CMPIData(akb[i].getValue(),akb[i].getType(),&data);
153 return data;
154 }
155 if (rc) CMSetStatus(rc,CMPI_RC_ERR_NOT_FOUND);
156 return data;
|
157 schuur 1.1 }
158
|
159 schuur 1.10 static CMPIData refGetKeyAt(CMPIObjectPath* eRef, unsigned pos, CMPIString** name,
160 CMPIStatus* rc) {
161 CIMObjectPath* ref=(CIMObjectPath*)eRef->hdl;
162 const Array<CIMKeyBinding> &akb=ref->getKeyBindings();
163 CMPIData data={0,CMPI_nullValue|CMPI_notFound,{0}};
164 if (rc) CMSetStatus(rc,CMPI_RC_OK);
165
166 if (pos>=akb.size()) {
167 if (rc) CMSetStatus(rc,CMPI_RC_ERR_NOT_FOUND);
168 return data;
169 }
170
171 key2CMPIData(akb[pos].getValue(),akb[pos].getType(),&data);
172
173 if (name) {
174 const String &n=akb[pos].getName().getString();
175 *name=(CMPIString*)string2CMPIString(n);
176 }
|
177 schuur 1.1 return data;
178 }
179
|
180 schuur 1.10 static CMPICount refGetKeyCount(CMPIObjectPath* eRef, CMPIStatus* rc) {
181 CIMObjectPath* ref=(CIMObjectPath*)eRef->hdl;
182 const Array<CIMKeyBinding> &akb=ref->getKeyBindings();
183 if (rc) CMSetStatus(rc,CMPI_RC_OK);
184 return akb.size();
185 }
186
187 static CMPIStatus refSetNameSpaceFromObjectPath(CMPIObjectPath* eRef,
188 CMPIObjectPath* eSrc) {
189 CIMObjectPath* ref=(CIMObjectPath*)eRef->hdl;
190 CIMObjectPath* src=(CIMObjectPath*)eSrc->hdl;
191 ref->setNameSpace(src->getNameSpace());
192 CMReturn(CMPI_RC_OK);
193 }
194
195 static CMPIStatus refSetHostAndNameSpaceFromObjectPath(CMPIObjectPath* eRef,
196 CMPIObjectPath* eSrc) {
197 CIMObjectPath* ref=(CIMObjectPath*)eRef->hdl;
198 CIMObjectPath* src=(CIMObjectPath*)eSrc->hdl;
199 ref->setNameSpace(src->getNameSpace());
200 ref->setHost(src->getHost());
201 schuur 1.10 CMReturn(CMPI_RC_OK);
202 }
203
204 static CMPIString *refToString(CMPIObjectPath* eRef, CMPIStatus* rc) {
205 CIMObjectPath* ref=(CIMObjectPath*)eRef->hdl;
206 String str=ref->toString();
207 if (rc) CMSetStatus(rc,CMPI_RC_OK);
208 return (CMPIString*) new CMPI_Object(str);
|
209 schuur 1.1 }
210
211 }
212
213 CMPIObjectPathFT objectPath_FT={
214 CMPICurrentVersion,
215 refRelease,
216 refClone,
217 refSetNameSpace,
218 refGetNameSpace,
219 refSetHostname,
220 refGetHostname,
221 refSetClassName,
222 refGetClassName,
223 refAddKey,
224 refGetKey,
225 refGetKeyAt,
226 refGetKeyCount,
227 refSetNameSpaceFromObjectPath,
228 refSetHostAndNameSpaceFromObjectPath,
229 NULL,
230 schuur 1.1 NULL,
231 NULL,
|
232 schuur 1.2 NULL,
233 refToString
|
234 schuur 1.1 };
235
236 CMPIObjectPathFT *CMPI_ObjectPath_Ftab=&objectPath_FT;
237
238 CMPIObjectPathFT objectPathOnStack_FT={
239 CMPICurrentVersion,
240 refReleaseNop,
241 refClone,
242 refSetNameSpace,
243 refGetNameSpace,
244 refSetHostname,
245 refGetHostname,
246 refSetClassName,
247 refGetClassName,
248 refAddKey,
249 refGetKey,
250 refGetKeyAt,
251 refGetKeyCount,
252 refSetNameSpaceFromObjectPath,
253 refSetHostAndNameSpaceFromObjectPath,
254 NULL,
255 schuur 1.1 NULL,
256 NULL,
|
257 schuur 1.2 NULL,
258 refToString
|
259 schuur 1.1 };
260
261 CMPIObjectPathFT *CMPI_ObjectPathOnStack_Ftab=&objectPathOnStack_FT;
262
263
264 CMPI_ObjectPathOnStack::CMPI_ObjectPathOnStack(const CIMObjectPath& cop) {
265 hdl=(void*)&cop;
266 ft=CMPI_ObjectPathOnStack_Ftab;
267 }
268
269
270 PEGASUS_NAMESPACE_END
271
|