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