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

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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2