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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2