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

  1 mike  1.5 //%/////////////////////////////////////////////////////////////////////////////
  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 chip  1.7 // 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 mike  1.5 // 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 chip  1.7 //
 12           // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
 13 mike  1.5 // 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 chip  1.7 // 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 mike  1.5 // 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           //
 23           // Author: Mike Brasher (mbrasher@bmc.com)
 24           //
 25 kumpf 1.11 // Modified By: Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com)
 26 mike  1.5  //
 27            //%/////////////////////////////////////////////////////////////////////////////
 28            
 29 kumpf 1.10 #include "CIMClassRep.h"
 30            #include "CIMInstanceRep.h"
 31            #include "CIMObjectRep.h"
 32 mike  1.5  #include "CIMObject.h"
 33 mike  1.6  #include "CIMClass.h"
 34            #include "CIMInstance.h"
 35 mike  1.5  #include "XmlWriter.h"
 36            
 37            PEGASUS_NAMESPACE_BEGIN
 38            
 39            ////////////////////////////////////////////////////////////////////////////////
 40            //
 41            // CIMObject
 42            //
 43            ////////////////////////////////////////////////////////////////////////////////
 44            
 45 kumpf 1.10 CIMObject::CIMObject()
 46                : _rep(0)
 47            {
 48            }
 49            
 50            CIMObject::CIMObject(const CIMObject& x)
 51            {
 52                Inc(_rep = x._rep);
 53            }
 54            
 55 mike  1.6  CIMObject::CIMObject(const CIMClass& x)
 56 mike  1.5  {
 57 mike  1.6      Inc(_rep = x._rep);
 58            }
 59 mike  1.5  
 60 mike  1.6  CIMObject::CIMObject(const CIMInstance& x)
 61            {
 62                Inc(_rep = x._rep);
 63 mike  1.5  }
 64            
 65 kumpf 1.10 CIMObject::CIMObject(CIMObjectRep* rep)
 66                : _rep(rep)
 67            {
 68            }
 69            
 70            CIMObject& CIMObject::operator=(const CIMObject& x)
 71            {
 72                if (x._rep != _rep)
 73                {
 74                    Dec(_rep);
 75            	Inc(_rep = x._rep);
 76                }
 77                return *this;
 78            }
 79            
 80 mike  1.6  CIMObject& CIMObject::operator=(const CIMClass& x)
 81 mike  1.5  {
 82 mike  1.6      if (x._rep != _rep)
 83                {
 84 kumpf 1.9          Dec(_rep);
 85 mike  1.6  	Inc(_rep = x._rep);
 86                }
 87                return *this;
 88            }
 89 mike  1.5  
 90 mike  1.6  CIMObject& CIMObject::operator=(const CIMInstance& x)
 91            {
 92                if (x._rep != _rep)
 93                {
 94 kumpf 1.9          Dec(_rep);
 95 mike  1.6  	Inc(_rep = x._rep);
 96                }
 97                return *this;
 98 mike  1.5  }
 99            
100 kumpf 1.10 CIMObject::~CIMObject()
101            {
102                Dec(_rep);
103            }
104            
105            const String& CIMObject::getClassName() const
106            {
107                _checkRep();
108                return _rep->getClassName();
109            }
110            
111 kumpf 1.16 const CIMObjectPath& CIMObject::getPath() const
112 kumpf 1.10 {
113                _checkRep();
114                return _rep->getPath();
115            }
116            
117            CIMObject& CIMObject::addQualifier(const CIMQualifier& qualifier)
118            {
119                _checkRep();
120                _rep->addQualifier(qualifier);
121                return *this;
122            }
123            
124            Uint32 CIMObject::findQualifier(const String& name) const
125            {
126                _checkRep();
127                return _rep->findQualifier(name);
128            }
129            
130            Boolean CIMObject::existsQualifier(const String& name) const
131            {
132                _checkRep();
133 kumpf 1.10     return _rep->existsQualifier(name);
134            }
135            
136            CIMQualifier CIMObject::getQualifier(Uint32 pos)
137            {
138                _checkRep();
139                return _rep->getQualifier(pos);
140            }
141            
142            CIMConstQualifier CIMObject::getQualifier(Uint32 pos) const
143            {
144                _checkRep();
145                return _rep->getQualifier(pos);
146            }
147            
148            void CIMObject::removeQualifier(Uint32 pos)
149            {
150                _checkRep();
151                _rep->removeQualifier(pos);
152            }
153            
154 kumpf 1.10 Uint32 CIMObject::getQualifierCount() const
155            {
156                _checkRep();
157                return _rep->getQualifierCount();
158            }
159            
160            CIMObject& CIMObject::addProperty(const CIMProperty& x)
161            {
162                _checkRep();
163                _rep->addProperty(x);
164                return *this;
165            }
166            
167            Uint32 CIMObject::findProperty(const String& name) const
168            {
169                _checkRep();
170                return _rep->findProperty(name);
171            }
172            
173            Boolean CIMObject::existsProperty(const String& name) const
174            {
175 kumpf 1.10     _checkRep();
176                return _rep->existsProperty(name);
177            }
178            
179            CIMProperty CIMObject::getProperty(Uint32 pos)
180            {
181                _checkRep();
182                return _rep->getProperty(pos);
183            }
184            
185            CIMConstProperty CIMObject::getProperty(Uint32 pos) const
186            {
187                _checkRep();
188                return _rep->getProperty(pos);
189            }
190            
191            void CIMObject::removeProperty(Uint32 pos)
192            {
193                _checkRep();
194                _rep->removeProperty(pos);
195            }
196 kumpf 1.10 
197            Uint32 CIMObject::getPropertyCount() const
198            {
199                _checkRep();
200                return _rep->getPropertyCount();
201            }
202            
203 kumpf 1.13 Boolean CIMObject::isNull() const
204 kumpf 1.10 {
205 kumpf 1.13     return (_rep == 0)? true : false;
206 kumpf 1.10 }
207            
208 mike  1.6  Boolean CIMObject::identical(const CIMConstObject& x) const
209 mike  1.5  {
210 mike  1.6      x._checkRep();
211                _checkRep();
212                return _rep->identical(x._rep);
213            }
214 mike  1.5  
215 kumpf 1.10 CIMObject CIMObject::clone() const
216            {
217                _checkRep();
218                return CIMObject(_rep->clone());
219            }
220            
221            void CIMObject::_checkRep() const
222            {
223                if (!_rep)
224 kumpf 1.12         ThrowUninitializedHandle();
225 kumpf 1.10 }
226            
227 mike  1.6  ////////////////////////////////////////////////////////////////////////////////
228            //
229            // CIMConstObject
230            //
231            ////////////////////////////////////////////////////////////////////////////////
232            
233 kumpf 1.10 CIMConstObject::CIMConstObject()
234                : _rep(0)
235            {
236            }
237            
238            CIMConstObject::CIMConstObject(const CIMConstObject& x)
239            {
240                Inc(_rep = x._rep);
241            }
242            
243            CIMConstObject::CIMConstObject(const CIMObject& x)
244            {
245                Inc(_rep = x._rep);
246            }
247            
248 mike  1.6  CIMConstObject::CIMConstObject(const CIMClass& x)
249            {
250                Inc(_rep = x._rep);
251 mike  1.5  }
252            
253 chip  1.7  CIMConstObject::CIMConstObject(const CIMConstClass& x)
254            {
255                Inc(_rep = x._rep);
256            }
257            
258 mike  1.6  CIMConstObject::CIMConstObject(const CIMInstance& x)
259 mike  1.5  {
260 mike  1.6      Inc(_rep = x._rep);
261            }
262 mike  1.5  
263 chip  1.7  CIMConstObject::CIMConstObject(const CIMConstInstance& x)
264            {
265                Inc(_rep = x._rep);
266            }
267            
268 kumpf 1.10 CIMConstObject& CIMConstObject::operator=(const CIMConstObject& x)
269            {
270                if (x._rep != _rep)
271                {
272                    Dec(_rep);
273                    Inc(_rep = x._rep);
274                }
275                return *this;
276            }
277            
278            CIMConstObject& CIMConstObject::operator=(const CIMObject& x)
279            {
280                if (x._rep != _rep)
281                {
282                    Dec(_rep);
283                    Inc(_rep = x._rep);
284                }
285                return *this;
286            }
287            
288 mike  1.6  CIMConstObject& CIMConstObject::operator=(const CIMClass& x)
289            {
290                if (x._rep != _rep)
291                {
292 kumpf 1.9          Dec(_rep);
293 mike  1.6  	Inc(_rep = x._rep);
294                }
295                return *this;
296 mike  1.5  }
297            
298 mike  1.6  CIMConstObject& CIMConstObject::operator=(const CIMInstance& x)
299 mike  1.5  {
300 mike  1.6      if (x._rep != _rep)
301                {
302 kumpf 1.9          Dec(_rep);
303 mike  1.6  	Inc(_rep = x._rep);
304                }
305                return *this;
306            }
307 mike  1.5  
308 mike  1.6  CIMConstObject& CIMConstObject::operator=(const CIMConstClass& x)
309            {
310                if (x._rep != _rep)
311 mike  1.5      {
312 kumpf 1.9          Dec(_rep);
313 mike  1.6  	Inc(_rep = x._rep);
314 mike  1.5      }
315 mike  1.6      return *this;
316            }
317            
318            CIMConstObject& CIMConstObject::operator=(const CIMConstInstance& x)
319            {
320                if (x._rep != _rep)
321 mike  1.5      {
322 kumpf 1.9          Dec(_rep);
323 mike  1.6  	Inc(_rep = x._rep);
324 mike  1.5      }
325 mike  1.6      return *this;
326 mike  1.5  }
327            
328 kumpf 1.10 CIMConstObject::~CIMConstObject()
329            {
330                Dec(_rep);
331            }
332            
333            const String& CIMConstObject::getClassName() const
334            {
335                _checkRep();
336                return _rep->getClassName();
337            }
338            
339 kumpf 1.16 const CIMObjectPath& CIMConstObject::getPath() const
340 kumpf 1.10 {
341                _checkRep();
342                return _rep->getPath();
343            }
344            
345            Uint32 CIMConstObject::findQualifier(const String& name) const
346            {
347                _checkRep();
348                return _rep->findQualifier(name);
349            }
350            
351            CIMConstQualifier CIMConstObject::getQualifier(Uint32 pos) const
352            {
353                _checkRep();
354                return _rep->getQualifier(pos);
355            }
356            
357            Uint32 CIMConstObject::getQualifierCount() const
358            {
359                _checkRep();
360                return _rep->getQualifierCount();
361 kumpf 1.10 }
362            
363            Uint32 CIMConstObject::findProperty(const String& name) const
364            {
365                _checkRep();
366                return _rep->findProperty(name);
367            }
368            
369            CIMConstProperty CIMConstObject::getProperty(Uint32 pos) const
370            {
371                _checkRep();
372                return _rep->getProperty(pos);
373            }
374            
375            Uint32 CIMConstObject::getPropertyCount() const
376            {
377                _checkRep();
378                return _rep->getPropertyCount();
379            }
380            
381 kumpf 1.13 Boolean CIMConstObject::isNull() const
382 kumpf 1.10 {
383 kumpf 1.13     return (_rep == 0)? true : false;
384 kumpf 1.10 }
385            
386            Boolean CIMConstObject::identical(const CIMConstObject& x) const
387            {
388                x._checkRep();
389                _checkRep();
390                return _rep->identical(x._rep);
391            }
392            
393            CIMObject CIMConstObject::clone() const
394            {
395                return CIMObject(_rep->clone());
396            }
397            
398            void CIMConstObject::_checkRep() const
399            {
400                if (!_rep)
401 kumpf 1.12         ThrowUninitializedHandle();
402 kumpf 1.10 }
403            
404 mike  1.5  ////////////////////////////////////////////////////////////////////////////////
405            //
406            // CIMObjectWithPath
407            //
408            ////////////////////////////////////////////////////////////////////////////////
409            
410            CIMObjectWithPath::CIMObjectWithPath()
411            {
412            }
413            
414            CIMObjectWithPath::CIMObjectWithPath(
415 kumpf 1.16     const CIMObjectPath& reference,
416 chip  1.7      const CIMObject& object)
417 mike  1.5      : _reference(reference), _object(object)
418            {
419            }
420            
421            CIMObjectWithPath::CIMObjectWithPath(const CIMObjectWithPath& x)
422                : _reference(x._reference), _object(x._object)
423            {
424            }
425            
426            CIMObjectWithPath::~CIMObjectWithPath()
427            {
428            }
429            
430            CIMObjectWithPath& CIMObjectWithPath::operator=(const CIMObjectWithPath& x)
431            {
432                if (this != &x)
433                {
434            	_reference = x._reference;
435            	_object = x._object;
436                }
437                return *this;
438 mike  1.5  }
439            
440            void CIMObjectWithPath::set(
441 kumpf 1.16     const CIMObjectPath& reference,
442 mike  1.5      const CIMObject& object)
443            {
444                _reference = reference;
445                _object = object;
446 kumpf 1.10 }
447            
448 kumpf 1.16 const CIMObjectPath& CIMObjectWithPath::getReference() const
449 kumpf 1.10 {
450                return _reference;
451            }
452            
453            const CIMObject& CIMObjectWithPath::getObject() const
454            {
455                return _object;
456            }
457            
458 kumpf 1.16 CIMObjectPath& CIMObjectWithPath::getReference()
459 kumpf 1.10 {
460                return _reference;
461            }
462            
463            CIMObject& CIMObjectWithPath::getObject()
464            {
465                return _object;
466 mike  1.5  }
467            
468            PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2