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

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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2