1 mike 1.11 //%/////////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (c) 2000, 2001 The Open group, BMC Software, Tivoli Systems, IBM
4 //
5 // Permission is hereby granted, free of charge, to any person obtaining a copy
6 // of this software and associated documentation files (the "Software"), to
7 // deal in the Software without restriction, including without limitation the
8 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
9 // sell copies of the Software, and to permit persons to whom the Software is
10 // furnished to do so, subject to the following conditions:
11 //
12 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
13 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
14 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
15 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
16 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
17 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
18 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
19 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20 //
21 //==============================================================================
22 mike 1.11 //
23 // Author: Mike Brasher (mbrasher@bmc.com)
24 //
|
25 kumpf 1.15 // Modified By: Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com)
|
26 karl 1.21 // Karl Schopmeyer, (k.schopmeyer@opengroup.org)
|
27 mike 1.11 //
28 //%/////////////////////////////////////////////////////////////////////////////
29
|
30 kumpf 1.14 #include "CIMInstanceRep.h"
|
31 mike 1.11 #include "CIMInstance.h"
32 #include "DeclContext.h"
33 #include "Indentor.h"
34 #include "CIMName.h"
35 #include "XmlWriter.h"
36
|
37 mike 1.13 PEGASUS_USING_STD;
38
|
39 mike 1.11 PEGASUS_NAMESPACE_BEGIN
40
41 #define PEGASUS_ARRAY_T CIMInstance
42 # include "ArrayImpl.h"
43 #undef PEGASUS_ARRAY_T
44
|
45 mike 1.12 ////////////////////////////////////////////////////////////////////////////////
46 //
47 // CIMInstance
48 //
49 ////////////////////////////////////////////////////////////////////////////////
50
|
51 kumpf 1.14 CIMInstance::CIMInstance()
52 : _rep(0)
53 {
54 }
55
56 CIMInstance::CIMInstance(const CIMInstance& x)
57 {
58 Inc(_rep = x._rep);
59 }
60
|
61 kumpf 1.16 CIMInstance::CIMInstance(const CIMObject& x) throw(DynamicCastFailed)
|
62 mike 1.12 {
63 if (!(_rep = dynamic_cast<CIMInstanceRep*>(x._rep)))
64 throw DynamicCastFailed();
|
65 kumpf 1.15 Inc(_rep);
|
66 mike 1.12 }
67
|
68 kumpf 1.14 CIMInstance::CIMInstance(const String& className)
69 {
70 _rep = new CIMInstanceRep(className);
71 }
72
73 CIMInstance::CIMInstance(CIMInstanceRep* rep)
74 : _rep(rep)
75 {
76 }
77
78 CIMInstance& CIMInstance::operator=(const CIMInstance& x)
79 {
80 if (x._rep != _rep)
81 {
82 Dec(_rep);
83 Inc(_rep = x._rep);
84 }
85 return *this;
86 }
87
88 CIMInstance::~CIMInstance()
89 kumpf 1.14 {
90 Dec(_rep);
91 }
92
93 const String& CIMInstance::getClassName() const
94 {
95 _checkRep();
96 return _rep->getClassName();
97 }
98
99 const Boolean CIMInstance::equalClassName(const String& classname) const
100 {
101 _checkRep();
102 return _rep->equalClassName(classname);
103
104 }
105
106 const CIMReference& CIMInstance::getPath() const
107 {
108 _checkRep();
109 return _rep->getPath();
110 kumpf 1.14 }
111
112 CIMInstance& CIMInstance::addQualifier(const CIMQualifier& qualifier)
113 {
114 _checkRep();
115 _rep->addQualifier(qualifier);
116 return *this;
117 }
118
119 Uint32 CIMInstance::findQualifier(const String& name) const
120 {
121 _checkRep();
122 return _rep->findQualifier(name);
123 }
124
125 Boolean CIMInstance::existsQualifier(const String& name) const
126 {
127 _checkRep();
128 return _rep->existsQualifier(name);
129 }
130
131 kumpf 1.14 CIMQualifier CIMInstance::getQualifier(Uint32 pos)
132 {
133 _checkRep();
134 return _rep->getQualifier(pos);
135 }
136
137 CIMConstQualifier CIMInstance::getQualifier(Uint32 pos) const
138 {
139 _checkRep();
140 return _rep->getQualifier(pos);
141 }
142
143 Uint32 CIMInstance::getQualifierCount() const
144 {
145 _checkRep();
146 return _rep->getQualifierCount();
147 }
148
149 CIMInstance& CIMInstance::addProperty(const CIMProperty& x)
150 {
151 _checkRep();
152 kumpf 1.14 _rep->addProperty(x);
153 return *this;
154 }
155
156 Uint32 CIMInstance::findProperty(const String& name) const
157 {
158 _checkRep();
159 return _rep->findProperty(name);
160 }
161
162 Boolean CIMInstance::existsProperty(const String& name) const
163 {
164 _checkRep();
165 return _rep->existsProperty(name);
166 }
167
|
168 karl 1.21 CIMProperty CIMInstance::getProperty(Uint32 pos) throw(OutOfBounds)
|
169 kumpf 1.14 {
170 _checkRep();
171 return _rep->getProperty(pos);
172 }
173
|
174 karl 1.21 CIMConstProperty CIMInstance::getProperty(Uint32 pos) const throw(OutOfBounds)
|
175 kumpf 1.14 {
176 _checkRep();
177 return _rep->getProperty(pos);
178 }
179
|
180 karl 1.21 void CIMInstance::removeProperty(Uint32 pos) throw(OutOfBounds)
|
181 kumpf 1.14 {
182 _checkRep();
183 _rep->removeProperty(pos);
184 }
185
186 Uint32 CIMInstance::getPropertyCount() const
187 {
188 _checkRep();
189 return _rep->getPropertyCount();
190 }
191
|
192 kumpf 1.18 Boolean CIMInstance::isNull() const
|
193 kumpf 1.14 {
|
194 kumpf 1.18 return (_rep == 0)? true : false;
|
195 kumpf 1.14 }
196
|
197 mike 1.11 Boolean CIMInstance::identical(const CIMConstInstance& x) const
198 {
199 x._checkRep();
200 _checkRep();
201 return _rep->identical(x._rep);
202 }
203
|
204 mike 1.13 void CIMInstance::resolve(
205 DeclContext* declContext,
206 const String& nameSpace,
207 Boolean propagateQualifiers)
|
208 mike 1.11 {
209 _checkRep();
210 CIMConstClass cimClass;
|
211 mike 1.13 _rep->resolve(declContext, nameSpace, cimClass, propagateQualifiers);
|
212 mike 1.12 }
213
|
214 kumpf 1.14 void CIMInstance::resolve(
215 DeclContext* declContext,
216 const String& nameSpace,
217 CIMConstClass& cimClassOut,
218 Boolean propagateQualifiers)
219 {
220 _checkRep();
221 _rep->resolve(declContext, nameSpace, cimClassOut, propagateQualifiers);
222 }
223
224 CIMInstance CIMInstance::clone() const
225 {
226 return CIMInstance((CIMInstanceRep*)(_rep->clone()));
227 }
228
229 CIMReference CIMInstance::getInstanceName(const CIMConstClass& cimClass) const
230 {
231 _checkRep();
232 return _rep->getInstanceName(cimClass);
233 }
234
235 kumpf 1.14 String CIMInstance::toString() const
236 {
237 _checkRep();
238 return _rep->toString();
239 }
240
241 void CIMInstance::_checkRep() const
242 {
243 if (!_rep)
|
244 kumpf 1.17 ThrowUninitializedHandle();
|
245 kumpf 1.14 }
246
|
247 mike 1.12 ////////////////////////////////////////////////////////////////////////////////
248 //
249 // CIMConstInstance
250 //
251 ////////////////////////////////////////////////////////////////////////////////
252
|
253 kumpf 1.14 CIMConstInstance::CIMConstInstance()
254 : _rep(0)
255 {
256 }
257
258 CIMConstInstance::CIMConstInstance(const CIMConstInstance& x)
259 {
260 Inc(_rep = x._rep);
261 }
262
263 CIMConstInstance::CIMConstInstance(const CIMInstance& x)
264 {
265 Inc(_rep = x._rep);
266 }
267
|
268 kumpf 1.16 CIMConstInstance::CIMConstInstance(const CIMObject& x) throw(DynamicCastFailed)
|
269 mike 1.12 {
270 if (!(_rep = dynamic_cast<CIMInstanceRep*>(x._rep)))
271 throw DynamicCastFailed();
|
272 kumpf 1.15 Inc(_rep);
|
273 mike 1.12 }
274
275 CIMConstInstance::CIMConstInstance(const CIMConstObject& x)
|
276 kumpf 1.16 throw(DynamicCastFailed)
|
277 mike 1.12 {
278 if (!(_rep = dynamic_cast<CIMInstanceRep*>(x._rep)))
279 throw DynamicCastFailed();
|
280 kumpf 1.15 Inc(_rep);
|
281 kumpf 1.14 }
282
283 CIMConstInstance::CIMConstInstance(const String& className)
284 {
285 _rep = new CIMInstanceRep(className);
286 }
287
288 CIMConstInstance& CIMConstInstance::operator=(const CIMConstInstance& x)
289 {
290 if (x._rep != _rep)
291 {
292 Dec(_rep);
293 Inc(_rep = x._rep);
294 }
295 return *this;
296 }
297
298 CIMConstInstance& CIMConstInstance::operator=(const CIMInstance& x)
299 {
300 if (x._rep != _rep)
301 {
302 kumpf 1.14 Dec(_rep);
303 Inc(_rep = x._rep);
304 }
305 return *this;
306 }
307
308 CIMConstInstance::~CIMConstInstance()
309 {
310 Dec(_rep);
311 }
312
313 const String& CIMConstInstance::getClassName() const
314 {
315 _checkRep();
316 return _rep->getClassName();
317 }
318
319 const Boolean CIMConstInstance::equalClassName(const String& classname) const
320 {
321 _checkRep();
322 return _rep->equalClassName(classname);
323 kumpf 1.14 }
324
325 const CIMReference& CIMConstInstance::getPath() const
326 {
327 _checkRep();
328 return _rep->getPath();
329 }
330
331 Uint32 CIMConstInstance::findQualifier(const String& name) const
332 {
333 _checkRep();
334 return _rep->findQualifier(name);
335 }
336
337 CIMConstQualifier CIMConstInstance::getQualifier(Uint32 pos) const
338 {
339 _checkRep();
340 return _rep->getQualifier(pos);
341 }
342
343 Uint32 CIMConstInstance::getQualifierCount() const
344 kumpf 1.14 {
345 _checkRep();
346 return _rep->getQualifierCount();
347 }
348
349 Uint32 CIMConstInstance::findProperty(const String& name) const
350 {
351 _checkRep();
352 return _rep->findProperty(name);
353 }
354
355 CIMConstProperty CIMConstInstance::getProperty(Uint32 pos) const
356 {
357 _checkRep();
358 return _rep->getProperty(pos);
359 }
360
361 Uint32 CIMConstInstance::getPropertyCount() const
362 {
363 _checkRep();
364 return _rep->getPropertyCount();
365 kumpf 1.14 }
366
|
367 kumpf 1.18 Boolean CIMConstInstance::isNull() const
|
368 kumpf 1.14 {
|
369 kumpf 1.18 return (_rep == 0)? true : false;
|
370 kumpf 1.14 }
371
372 Boolean CIMConstInstance::identical(const CIMConstInstance& x) const
373 {
374 x._checkRep();
375 _checkRep();
376 return _rep->identical(x._rep);
377 }
378
379 CIMInstance CIMConstInstance::clone() const
380 {
381 return CIMInstance((CIMInstanceRep*)(_rep->clone()));
382 }
383
384 CIMReference CIMConstInstance::getInstanceName(const CIMConstClass& cimClass) const
385 {
386 _checkRep();
387 return _rep->getInstanceName(cimClass);
388 }
389
390 String CIMConstInstance::toString() const
391 kumpf 1.14 {
392 _checkRep();
393 return _rep->toString();
394 }
395
396 void CIMConstInstance::_checkRep() const
397 {
398 if (!_rep)
|
399 kumpf 1.17 ThrowUninitializedHandle();
|
400 kumpf 1.18 }
401
402
403 Boolean operator==(const CIMInstance& x, const CIMInstance& y)
404 {
405 return x.identical(y);
|
406 mike 1.11 }
407
408 PEGASUS_NAMESPACE_END
|