(file) Return to CIMInstance.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Common

  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            // Modified By:
 26            //
 27            //%/////////////////////////////////////////////////////////////////////////////
 28            
 29 kumpf 1.14 #include "CIMInstanceRep.h"
 30 mike  1.11 #include "CIMInstance.h"
 31            #include "DeclContext.h"
 32            #include "Indentor.h"
 33            #include "CIMName.h"
 34            #include "XmlWriter.h"
 35            
 36 mike  1.13 PEGASUS_USING_STD;
 37            
 38 mike  1.11 PEGASUS_NAMESPACE_BEGIN
 39            
 40            #define PEGASUS_ARRAY_T CIMInstance
 41            # include "ArrayImpl.h"
 42            #undef PEGASUS_ARRAY_T
 43            
 44 mike  1.12 ////////////////////////////////////////////////////////////////////////////////
 45            //
 46            // CIMInstance
 47            //
 48            ////////////////////////////////////////////////////////////////////////////////
 49            
 50 kumpf 1.14 CIMInstance::CIMInstance()
 51                : _rep(0)
 52            {
 53            }
 54            
 55            CIMInstance::CIMInstance(const CIMInstance& x)
 56            {
 57                Inc(_rep = x._rep);
 58            }
 59            
 60 mike  1.12 CIMInstance::CIMInstance(const CIMObject& x)
 61            {
 62 kumpf 1.14     // ATTN-RK-P1-20020502: Need to Inc(_rep)?
 63 mike  1.12     if (!(_rep = dynamic_cast<CIMInstanceRep*>(x._rep)))
 64            	throw DynamicCastFailed();
 65            }
 66            
 67            CIMInstance::CIMInstance(const CIMObject& x, NoThrow&)
 68            {
 69 kumpf 1.14     // ATTN-RK-P1-20020502: Need to Inc(_rep)?
 70 mike  1.12     _rep = dynamic_cast<CIMInstanceRep*>(x._rep);
 71            }
 72            
 73 kumpf 1.14 CIMInstance::CIMInstance(const String& className)
 74            {
 75                _rep = new CIMInstanceRep(className);
 76            }
 77            
 78            CIMInstance::CIMInstance(CIMInstanceRep* rep)
 79                : _rep(rep)
 80            {
 81            }
 82            
 83            CIMInstance& CIMInstance::operator=(const CIMInstance& x)
 84            {
 85                if (x._rep != _rep)
 86                {
 87                    Dec(_rep);
 88                    Inc(_rep = x._rep);
 89                }
 90                return *this;
 91            }
 92            
 93            CIMInstance::~CIMInstance()
 94 kumpf 1.14 {
 95                Dec(_rep);
 96            }
 97            
 98            const String& CIMInstance::getClassName() const
 99            {
100                _checkRep();
101                return _rep->getClassName();
102            }
103            
104            const Boolean CIMInstance::equalClassName(const String& classname) const
105            {
106                _checkRep();
107                return _rep->equalClassName(classname);
108            
109            }
110            
111            const CIMReference& CIMInstance::getPath() const
112            {
113                _checkRep();
114                return _rep->getPath();
115 kumpf 1.14 }
116            
117            CIMInstance& CIMInstance::addQualifier(const CIMQualifier& qualifier)
118            {
119                _checkRep();
120                _rep->addQualifier(qualifier);
121                return *this;
122            }
123            
124            Uint32 CIMInstance::findQualifier(const String& name) const
125            {
126                _checkRep();
127                return _rep->findQualifier(name);
128            }
129            
130            Boolean CIMInstance::existsQualifier(const String& name) const
131            {
132                _checkRep();
133                return _rep->existsQualifier(name);
134            }
135            
136 kumpf 1.14 CIMQualifier CIMInstance::getQualifier(Uint32 pos)
137            {
138                _checkRep();
139                return _rep->getQualifier(pos);
140            }
141            
142            CIMConstQualifier CIMInstance::getQualifier(Uint32 pos) const
143            {
144                _checkRep();
145                return _rep->getQualifier(pos);
146            }
147            
148            Uint32 CIMInstance::getQualifierCount() const
149            {
150                _checkRep();
151                return _rep->getQualifierCount();
152            }
153            
154            CIMInstance& CIMInstance::addProperty(const CIMProperty& x)
155            {
156                _checkRep();
157 kumpf 1.14     _rep->addProperty(x);
158                return *this;
159            }
160            
161            Uint32 CIMInstance::findProperty(const String& name) const
162            {
163                _checkRep();
164                return _rep->findProperty(name);
165            }
166            
167            Boolean CIMInstance::existsProperty(const String& name) const
168            {
169               _checkRep();
170               return _rep->existsProperty(name);
171            }
172            
173            CIMProperty CIMInstance::getProperty(Uint32 pos)
174            {
175                _checkRep();
176                return _rep->getProperty(pos);
177            }
178 kumpf 1.14 
179            CIMConstProperty CIMInstance::getProperty(Uint32 pos) const
180            {
181                _checkRep();
182                return _rep->getProperty(pos);
183            }
184            
185            void CIMInstance::removeProperty(Uint32 pos)
186            {
187                _checkRep();
188                _rep->removeProperty(pos);
189            }
190            
191            Uint32 CIMInstance::getPropertyCount() const
192            {
193                _checkRep();
194                return _rep->getPropertyCount();
195            }
196            
197            CIMInstance::operator int() const
198            {
199 kumpf 1.14     return (_rep != 0);
200            }
201            
202 mike  1.11 Boolean CIMInstance::identical(const CIMConstInstance& x) const
203            {
204                x._checkRep();
205                _checkRep();
206                return _rep->identical(x._rep);
207            }
208            
209 mike  1.13 void CIMInstance::resolve(
210                DeclContext* declContext, 
211                const String& nameSpace,
212                Boolean propagateQualifiers)
213 mike  1.11 {
214                _checkRep();
215                CIMConstClass cimClass;
216 mike  1.13     _rep->resolve(declContext, nameSpace, cimClass, propagateQualifiers);
217 mike  1.12 }
218            
219 kumpf 1.14 void CIMInstance::resolve(
220                DeclContext* declContext,
221                const String& nameSpace,
222                CIMConstClass& cimClassOut,
223                Boolean propagateQualifiers)
224            {
225                _checkRep();
226                _rep->resolve(declContext, nameSpace, cimClassOut, propagateQualifiers);
227            }
228            
229            void CIMInstance::toXml(Array<Sint8>& out) const
230            {
231                _checkRep();
232                _rep->toXml(out);
233            }
234            
235            void CIMInstance::print(PEGASUS_STD(ostream)& o) const
236            {
237                _checkRep();
238                _rep->print(o);
239            }
240 kumpf 1.14 
241            void CIMInstance::toMof(Array<Sint8>& out) const
242            {
243                _checkRep();
244                _rep->toMof(out);
245            }
246            
247            CIMInstance CIMInstance::clone() const
248            {
249                return CIMInstance((CIMInstanceRep*)(_rep->clone()));
250            }
251            
252            CIMReference CIMInstance::getInstanceName(const CIMConstClass& cimClass) const
253            {
254                _checkRep();
255                return _rep->getInstanceName(cimClass);
256            }
257            
258            String CIMInstance::toString() const
259            {
260                _checkRep();
261 kumpf 1.14     return _rep->toString();
262            }
263            
264            void CIMInstance::_checkRep() const
265            {
266                if (!_rep)
267                    ThrowUnitializedHandle();
268            }
269            
270 mike  1.12 ////////////////////////////////////////////////////////////////////////////////
271            //
272            // CIMConstInstance
273            //
274            ////////////////////////////////////////////////////////////////////////////////
275            
276 kumpf 1.14 CIMConstInstance::CIMConstInstance()
277                : _rep(0)
278            {
279            }
280            
281            CIMConstInstance::CIMConstInstance(const CIMConstInstance& x)
282            {
283                Inc(_rep = x._rep);
284            }
285            
286            CIMConstInstance::CIMConstInstance(const CIMInstance& x)
287            {
288                Inc(_rep = x._rep);
289            }
290            
291 mike  1.12 CIMConstInstance::CIMConstInstance(const CIMObject& x)
292            {
293 kumpf 1.14     // ATTN-RK-P1-20020502: Need to Inc(_rep)?
294 mike  1.12     if (!(_rep = dynamic_cast<CIMInstanceRep*>(x._rep)))
295            	throw DynamicCastFailed();
296            }
297            
298            CIMConstInstance::CIMConstInstance(const CIMConstObject& x)
299            {
300 kumpf 1.14     // ATTN-RK-P1-20020502: Need to Inc(_rep)?
301 mike  1.12     if (!(_rep = dynamic_cast<CIMInstanceRep*>(x._rep)))
302            	throw DynamicCastFailed();
303            }
304            
305            CIMConstInstance::CIMConstInstance(const CIMObject& x, NoThrow&)
306            {
307 kumpf 1.14     // ATTN-RK-P1-20020502: Need to Inc(_rep)?
308 mike  1.12     _rep = dynamic_cast<CIMInstanceRep*>(x._rep);
309            }
310            
311            CIMConstInstance::CIMConstInstance(const CIMConstObject& x, NoThrow&)
312            {
313 kumpf 1.14     // ATTN-RK-P1-20020502: Need to Inc(_rep)?
314 mike  1.12     _rep = dynamic_cast<CIMInstanceRep*>(x._rep);
315 kumpf 1.14 }
316            
317            CIMConstInstance::CIMConstInstance(const String& className)
318            {
319                _rep = new CIMInstanceRep(className);
320            }
321            
322            CIMConstInstance& CIMConstInstance::operator=(const CIMConstInstance& x)
323            {
324                if (x._rep != _rep)
325                {
326                    Dec(_rep);
327                    Inc(_rep = x._rep);
328                }
329                return *this;
330            }
331            
332            CIMConstInstance& CIMConstInstance::operator=(const CIMInstance& x)
333            {
334                if (x._rep != _rep)
335                {
336 kumpf 1.14         Dec(_rep);
337                    Inc(_rep = x._rep);
338                }
339                return *this;
340            }
341            
342            CIMConstInstance::~CIMConstInstance()
343            {
344                Dec(_rep);
345            }
346            
347            const String& CIMConstInstance::getClassName() const
348            {
349                _checkRep();
350                return _rep->getClassName();
351            }
352            
353            const Boolean CIMConstInstance::equalClassName(const String& classname) const
354            {
355                _checkRep();
356                return _rep->equalClassName(classname);
357 kumpf 1.14 }
358            
359            const CIMReference& CIMConstInstance::getPath() const
360            {
361                _checkRep();
362                return _rep->getPath();
363            }
364            
365            Uint32 CIMConstInstance::findQualifier(const String& name) const
366            {
367                _checkRep();
368                return _rep->findQualifier(name);
369            }
370            
371            CIMConstQualifier CIMConstInstance::getQualifier(Uint32 pos) const
372            {
373                _checkRep();
374                return _rep->getQualifier(pos);
375            }
376            
377            Uint32 CIMConstInstance::getQualifierCount() const
378 kumpf 1.14 {
379                _checkRep();
380                return _rep->getQualifierCount();
381            }
382            
383            Uint32 CIMConstInstance::findProperty(const String& name) const
384            {
385                _checkRep();
386                return _rep->findProperty(name);
387            }
388            
389            CIMConstProperty CIMConstInstance::getProperty(Uint32 pos) const
390            {
391                _checkRep();
392                return _rep->getProperty(pos);
393            }
394            
395            Uint32 CIMConstInstance::getPropertyCount() const
396            {
397                _checkRep();
398                return _rep->getPropertyCount();
399 kumpf 1.14 }
400            
401            CIMConstInstance::operator int() const
402            {
403                return (_rep != 0);
404            }
405            
406            void CIMConstInstance::toXml(Array<Sint8>& out) const
407            {
408                _checkRep();
409                _rep->toXml(out);
410            }
411            
412            void CIMConstInstance::print(PEGASUS_STD(ostream)& o) const
413            {
414                _checkRep();
415                _rep->print(o);
416            }
417            
418            Boolean CIMConstInstance::identical(const CIMConstInstance& x) const
419            {
420 kumpf 1.14     x._checkRep();
421                _checkRep();
422                return _rep->identical(x._rep);
423            }
424            
425            CIMInstance CIMConstInstance::clone() const
426            {
427                return CIMInstance((CIMInstanceRep*)(_rep->clone()));
428            }
429            
430            CIMReference CIMConstInstance::getInstanceName(const CIMConstClass& cimClass) const
431            {
432                _checkRep();
433                return _rep->getInstanceName(cimClass);
434            }
435            
436            String CIMConstInstance::toString() const
437            {
438                _checkRep();
439                return _rep->toString();
440            }
441 kumpf 1.14 
442            void CIMConstInstance::_checkRep() const
443            {
444                if (!_rep)
445                    ThrowUnitializedHandle();
446 mike  1.11 }
447            
448            PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2