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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2