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

  1 mike  1.5 //%/////////////////////////////////////////////////////////////////////////////
  2           //
  3 kumpf 1.21 // Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Company, IBM,
  4            // The Open Group, Tivoli Systems
  5 mike  1.5  //
  6            // Permission is hereby granted, free of charge, to any person obtaining a copy
  7 chip  1.7  // 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.5  // 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 kumpf 1.21 // 
 13 chip  1.7  // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
 14 mike  1.5  // 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 chip  1.7  // 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.5  // 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.11 // Modified By: Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com)
 27 kumpf 1.18 //              Carol Ann Krug Graves, Hewlett-Packard Company
 28            //                  (carolann_graves@hp.com)
 29 mike  1.5  //
 30            //%/////////////////////////////////////////////////////////////////////////////
 31            
 32 kumpf 1.10 #include "CIMClassRep.h"
 33            #include "CIMInstanceRep.h"
 34            #include "CIMObjectRep.h"
 35 mike  1.5  #include "CIMObject.h"
 36 mike  1.6  #include "CIMClass.h"
 37            #include "CIMInstance.h"
 38 mike  1.5  #include "XmlWriter.h"
 39            
 40            PEGASUS_NAMESPACE_BEGIN
 41            
 42 kumpf 1.19 #define PEGASUS_ARRAY_T CIMObject
 43            # include "ArrayImpl.h"
 44            #undef PEGASUS_ARRAY_T
 45            
 46 mike  1.5  ////////////////////////////////////////////////////////////////////////////////
 47            //
 48            // CIMObject
 49            //
 50            ////////////////////////////////////////////////////////////////////////////////
 51            
 52 kumpf 1.10 CIMObject::CIMObject()
 53                : _rep(0)
 54            {
 55            }
 56            
 57            CIMObject::CIMObject(const CIMObject& x)
 58            {
 59                Inc(_rep = x._rep);
 60            }
 61            
 62 mike  1.6  CIMObject::CIMObject(const CIMClass& x)
 63 mike  1.5  {
 64 mike  1.6      Inc(_rep = x._rep);
 65            }
 66 mike  1.5  
 67 mike  1.6  CIMObject::CIMObject(const CIMInstance& x)
 68            {
 69                Inc(_rep = x._rep);
 70 mike  1.5  }
 71            
 72 kumpf 1.10 CIMObject::CIMObject(CIMObjectRep* rep)
 73                : _rep(rep)
 74            {
 75            }
 76            
 77            CIMObject& CIMObject::operator=(const CIMObject& x)
 78            {
 79                if (x._rep != _rep)
 80                {
 81                    Dec(_rep);
 82            	Inc(_rep = x._rep);
 83                }
 84                return *this;
 85            }
 86            
 87            CIMObject::~CIMObject()
 88            {
 89                Dec(_rep);
 90            }
 91            
 92 kumpf 1.23 const CIMName& CIMObject::getClassName() const
 93 kumpf 1.10 {
 94                _checkRep();
 95                return _rep->getClassName();
 96            }
 97            
 98 kumpf 1.16 const CIMObjectPath& CIMObject::getPath() const
 99 kumpf 1.10 {
100                _checkRep();
101                return _rep->getPath();
102 kumpf 1.18 }
103            
104            void CIMObject::setPath (const CIMObjectPath & path)
105            {
106                _checkRep ();
107                _rep->setPath (path);
108 kumpf 1.10 }
109            
110            CIMObject& CIMObject::addQualifier(const CIMQualifier& qualifier)
111            {
112                _checkRep();
113                _rep->addQualifier(qualifier);
114                return *this;
115            }
116            
117 kumpf 1.23 Uint32 CIMObject::findQualifier(const CIMName& name) const
118 kumpf 1.10 {
119                _checkRep();
120                return _rep->findQualifier(name);
121            }
122            
123 kumpf 1.28 CIMQualifier CIMObject::getQualifier(Uint32 index)
124 kumpf 1.10 {
125                _checkRep();
126 kumpf 1.28     return _rep->getQualifier(index);
127 kumpf 1.10 }
128            
129 kumpf 1.28 CIMConstQualifier CIMObject::getQualifier(Uint32 index) const
130 kumpf 1.10 {
131                _checkRep();
132 kumpf 1.28     return _rep->getQualifier(index);
133 kumpf 1.10 }
134            
135 kumpf 1.28 void CIMObject::removeQualifier(Uint32 index)
136 kumpf 1.10 {
137                _checkRep();
138 kumpf 1.28     _rep->removeQualifier(index);
139 kumpf 1.10 }
140            
141            Uint32 CIMObject::getQualifierCount() const
142            {
143                _checkRep();
144                return _rep->getQualifierCount();
145            }
146            
147            CIMObject& CIMObject::addProperty(const CIMProperty& x)
148            {
149                _checkRep();
150                _rep->addProperty(x);
151                return *this;
152            }
153            
154 kumpf 1.23 Uint32 CIMObject::findProperty(const CIMName& name) const
155 kumpf 1.10 {
156                _checkRep();
157                return _rep->findProperty(name);
158            }
159            
160 kumpf 1.28 CIMProperty CIMObject::getProperty(Uint32 index)
161 kumpf 1.10 {
162                _checkRep();
163 kumpf 1.28     return _rep->getProperty(index);
164 kumpf 1.10 }
165            
166 kumpf 1.28 CIMConstProperty CIMObject::getProperty(Uint32 index) const
167 kumpf 1.10 {
168                _checkRep();
169 kumpf 1.28     return _rep->getProperty(index);
170 kumpf 1.10 }
171            
172 kumpf 1.28 void CIMObject::removeProperty(Uint32 index)
173 kumpf 1.10 {
174                _checkRep();
175 kumpf 1.28     _rep->removeProperty(index);
176 kumpf 1.10 }
177            
178            Uint32 CIMObject::getPropertyCount() const
179            {
180                _checkRep();
181                return _rep->getPropertyCount();
182            }
183            
184 kumpf 1.24 Boolean CIMObject::isUninitialized() const
185 kumpf 1.10 {
186 kumpf 1.13     return (_rep == 0)? true : false;
187 kumpf 1.10 }
188            
189 kumpf 1.25 Boolean CIMObject::isClass () const
190            {
191                try
192                {
193                    const CIMClass c (*this);
194                    return true;
195                }
196 kumpf 1.27     catch (DynamicCastFailedException)
197 kumpf 1.25     {
198                    return false;
199                }
200            }
201            
202            Boolean CIMObject::isInstance () const
203            {
204                try
205                {
206                    const CIMInstance i (*this);
207                    return true;
208                }
209 kumpf 1.27     catch (DynamicCastFailedException)
210 kumpf 1.25     {
211                    return false;
212                }
213            }
214            
215 mike  1.6  Boolean CIMObject::identical(const CIMConstObject& x) const
216 mike  1.5  {
217 mike  1.6      x._checkRep();
218                _checkRep();
219                return _rep->identical(x._rep);
220            }
221 mike  1.5  
222 kumpf 1.10 CIMObject CIMObject::clone() const
223            {
224                _checkRep();
225                return CIMObject(_rep->clone());
226            }
227            
228            void CIMObject::_checkRep() const
229            {
230                if (!_rep)
231 kumpf 1.27         throw UninitializedObjectException();
232 kumpf 1.10 }
233            
234 mike  1.6  ////////////////////////////////////////////////////////////////////////////////
235            //
236            // CIMConstObject
237            //
238            ////////////////////////////////////////////////////////////////////////////////
239            
240 kumpf 1.10 CIMConstObject::CIMConstObject()
241                : _rep(0)
242            {
243            }
244            
245            CIMConstObject::CIMConstObject(const CIMConstObject& x)
246            {
247                Inc(_rep = x._rep);
248            }
249            
250            CIMConstObject::CIMConstObject(const CIMObject& x)
251            {
252                Inc(_rep = x._rep);
253            }
254            
255 mike  1.6  CIMConstObject::CIMConstObject(const CIMClass& x)
256            {
257                Inc(_rep = x._rep);
258 mike  1.5  }
259            
260 chip  1.7  CIMConstObject::CIMConstObject(const CIMConstClass& x)
261            {
262                Inc(_rep = x._rep);
263            }
264            
265 mike  1.6  CIMConstObject::CIMConstObject(const CIMInstance& x)
266 mike  1.5  {
267 mike  1.6      Inc(_rep = x._rep);
268            }
269 mike  1.5  
270 chip  1.7  CIMConstObject::CIMConstObject(const CIMConstInstance& x)
271            {
272                Inc(_rep = x._rep);
273            }
274            
275 kumpf 1.10 CIMConstObject& CIMConstObject::operator=(const CIMConstObject& x)
276            {
277                if (x._rep != _rep)
278                {
279                    Dec(_rep);
280                    Inc(_rep = x._rep);
281 mike  1.5      }
282 mike  1.6      return *this;
283 mike  1.5  }
284            
285 kumpf 1.10 CIMConstObject::~CIMConstObject()
286            {
287                Dec(_rep);
288            }
289            
290 kumpf 1.23 const CIMName& CIMConstObject::getClassName() const
291 kumpf 1.10 {
292                _checkRep();
293                return _rep->getClassName();
294            }
295            
296 kumpf 1.16 const CIMObjectPath& CIMConstObject::getPath() const
297 kumpf 1.10 {
298                _checkRep();
299                return _rep->getPath();
300            }
301            
302 kumpf 1.23 Uint32 CIMConstObject::findQualifier(const CIMName& name) const
303 kumpf 1.10 {
304                _checkRep();
305                return _rep->findQualifier(name);
306            }
307            
308 kumpf 1.28 CIMConstQualifier CIMConstObject::getQualifier(Uint32 index) const
309 kumpf 1.10 {
310                _checkRep();
311 kumpf 1.28     return _rep->getQualifier(index);
312 kumpf 1.10 }
313            
314            Uint32 CIMConstObject::getQualifierCount() const
315            {
316                _checkRep();
317                return _rep->getQualifierCount();
318            }
319            
320 kumpf 1.23 Uint32 CIMConstObject::findProperty(const CIMName& name) const
321 kumpf 1.10 {
322                _checkRep();
323                return _rep->findProperty(name);
324            }
325            
326 kumpf 1.28 CIMConstProperty CIMConstObject::getProperty(Uint32 index) const
327 kumpf 1.10 {
328                _checkRep();
329 kumpf 1.28     return _rep->getProperty(index);
330 kumpf 1.10 }
331            
332            Uint32 CIMConstObject::getPropertyCount() const
333            {
334                _checkRep();
335                return _rep->getPropertyCount();
336            }
337            
338 kumpf 1.24 Boolean CIMConstObject::isUninitialized() const
339 kumpf 1.10 {
340 kumpf 1.13     return (_rep == 0)? true : false;
341 kumpf 1.10 }
342            
343 kumpf 1.27 Boolean CIMConstObject::isClass() const
344            {
345                try
346                {
347                    const CIMConstClass c(*this);
348                    return true;
349                }
350                catch (DynamicCastFailedException)
351                {
352                    return false;
353                }
354            }
355            
356            Boolean CIMConstObject::isInstance() const
357            {
358                try
359                {
360                    const CIMConstInstance i(*this);
361                    return true;
362                }
363                catch (DynamicCastFailedException)
364 kumpf 1.27     {
365                    return false;
366                }
367            }
368            
369 kumpf 1.10 Boolean CIMConstObject::identical(const CIMConstObject& x) const
370            {
371                x._checkRep();
372                _checkRep();
373                return _rep->identical(x._rep);
374            }
375            
376            CIMObject CIMConstObject::clone() const
377            {
378                return CIMObject(_rep->clone());
379            }
380            
381            void CIMConstObject::_checkRep() const
382            {
383                if (!_rep)
384 kumpf 1.27         throw UninitializedObjectException();
385 kumpf 1.10 }
386            
387 mike  1.5  PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2