(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            void CIMInstance::_checkRep() const
206            {
207                if (!_rep)
208 kumpf 1.32         throw UninitializedObjectException();
209 kumpf 1.14 }
210            
211 mike  1.12 ////////////////////////////////////////////////////////////////////////////////
212            //
213            // CIMConstInstance
214            //
215            ////////////////////////////////////////////////////////////////////////////////
216            
217 kumpf 1.14 CIMConstInstance::CIMConstInstance()
218                : _rep(0)
219            {
220            }
221            
222            CIMConstInstance::CIMConstInstance(const CIMConstInstance& x)
223            {
224                Inc(_rep = x._rep);
225            }
226            
227            CIMConstInstance::CIMConstInstance(const CIMInstance& x)
228            {
229                Inc(_rep = x._rep);
230            }
231            
232 kumpf 1.34 CIMConstInstance::CIMConstInstance(const CIMObject& x)
233 mike  1.12 {
234                if (!(_rep = dynamic_cast<CIMInstanceRep*>(x._rep)))
235 kumpf 1.32 	throw DynamicCastFailedException();
236 kumpf 1.15     Inc(_rep);
237 mike  1.12 }
238            
239            CIMConstInstance::CIMConstInstance(const CIMConstObject& x)
240            {
241                if (!(_rep = dynamic_cast<CIMInstanceRep*>(x._rep)))
242 kumpf 1.32 	throw DynamicCastFailedException();
243 kumpf 1.15     Inc(_rep);
244 kumpf 1.14 }
245            
246 kumpf 1.28 CIMConstInstance::CIMConstInstance(const CIMName& className)
247 kumpf 1.14 {
248 kumpf 1.28     _rep = new CIMInstanceRep(CIMObjectPath(String::EMPTY, CIMNamespaceName(), className));
249 kumpf 1.14 }
250            
251            CIMConstInstance& CIMConstInstance::operator=(const CIMConstInstance& x)
252            {
253                if (x._rep != _rep)
254                {
255                    Dec(_rep);
256                    Inc(_rep = x._rep);
257                }
258                return *this;
259            }
260            
261            CIMConstInstance& CIMConstInstance::operator=(const CIMInstance& x)
262            {
263                if (x._rep != _rep)
264                {
265                    Dec(_rep);
266                    Inc(_rep = x._rep);
267                }
268                return *this;
269            }
270 kumpf 1.14 
271            CIMConstInstance::~CIMConstInstance()
272            {
273                Dec(_rep);
274            }
275            
276 kumpf 1.28 const CIMName& CIMConstInstance::getClassName() const
277 kumpf 1.14 {
278                _checkRep();
279                return _rep->getClassName();
280            }
281            
282 kumpf 1.22 const CIMObjectPath& CIMConstInstance::getPath() const
283 kumpf 1.14 {
284                _checkRep();
285                return _rep->getPath();
286            }
287            
288 kumpf 1.28 Uint32 CIMConstInstance::findQualifier(const CIMName& name) const
289 kumpf 1.14 {
290                _checkRep();
291                return _rep->findQualifier(name);
292            }
293            
294 kumpf 1.33 CIMConstQualifier CIMConstInstance::getQualifier(Uint32 index) const
295 kumpf 1.14 {
296                _checkRep();
297 kumpf 1.33     return _rep->getQualifier(index);
298 kumpf 1.14 }
299            
300            Uint32 CIMConstInstance::getQualifierCount() const
301            {
302                _checkRep();
303                return _rep->getQualifierCount();
304            }
305            
306 kumpf 1.28 Uint32 CIMConstInstance::findProperty(const CIMName& name) const
307 kumpf 1.14 {
308                _checkRep();
309                return _rep->findProperty(name);
310            }
311            
312 kumpf 1.33 CIMConstProperty CIMConstInstance::getProperty(Uint32 index) const
313 kumpf 1.14 {
314                _checkRep();
315 kumpf 1.33     return _rep->getProperty(index);
316 kumpf 1.14 }
317            
318            Uint32 CIMConstInstance::getPropertyCount() const
319            {
320                _checkRep();
321                return _rep->getPropertyCount();
322            }
323            
324 kumpf 1.29 Boolean CIMConstInstance::isUninitialized() const
325 kumpf 1.14 {
326 kumpf 1.18     return (_rep == 0)? true : false;
327 kumpf 1.14 }
328            
329            Boolean CIMConstInstance::identical(const CIMConstInstance& x) const
330            {
331                x._checkRep();
332                _checkRep();
333                return _rep->identical(x._rep);
334            }
335            
336            CIMInstance CIMConstInstance::clone() const
337            {
338                return CIMInstance((CIMInstanceRep*)(_rep->clone()));
339            }
340            
341 kumpf 1.30 CIMObjectPath CIMConstInstance::buildPath(const CIMConstClass& cimClass) const
342 kumpf 1.14 {
343                _checkRep();
344 kumpf 1.30     return _rep->buildPath(cimClass);
345 kumpf 1.14 }
346            
347            void CIMConstInstance::_checkRep() const
348            {
349                if (!_rep)
350 kumpf 1.32         throw UninitializedObjectException();
351 mike  1.11 }
352            
353            PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2