(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           // Modified By:
 26           //
 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            const Boolean CIMObject::equalClassName(const String& classname) const
112            {
113                _checkRep();
114                return _rep->equalClassName(classname);
115            }
116            
117            const CIMReference& CIMObject::getPath() const
118            {
119                _checkRep();
120                return _rep->getPath();
121 kumpf 1.10 }
122            
123            CIMObject& CIMObject::addQualifier(const CIMQualifier& qualifier)
124            {
125                _checkRep();
126                _rep->addQualifier(qualifier);
127                return *this;
128            }
129            
130            Uint32 CIMObject::findQualifier(const String& name) const
131            {
132                _checkRep();
133                return _rep->findQualifier(name);
134            }
135            
136            Boolean CIMObject::existsQualifier(const String& name) const
137            {
138                _checkRep();
139                return _rep->existsQualifier(name);
140            }
141            
142 kumpf 1.10 CIMQualifier CIMObject::getQualifier(Uint32 pos)
143            {
144                _checkRep();
145                return _rep->getQualifier(pos);
146            }
147            
148            CIMConstQualifier CIMObject::getQualifier(Uint32 pos) const
149            {
150                _checkRep();
151                return _rep->getQualifier(pos);
152            }
153            
154            void CIMObject::removeQualifier(Uint32 pos)
155            {
156                _checkRep();
157                _rep->removeQualifier(pos);
158            }
159            
160            Uint32 CIMObject::getQualifierCount() const
161            {
162                _checkRep();
163 kumpf 1.10     return _rep->getQualifierCount();
164            }
165            
166            CIMObject& CIMObject::addProperty(const CIMProperty& x)
167            {
168                _checkRep();
169                _rep->addProperty(x);
170                return *this;
171            }
172            
173            Uint32 CIMObject::findProperty(const String& name) const
174            {
175                _checkRep();
176                return _rep->findProperty(name);
177            }
178            
179            Boolean CIMObject::existsProperty(const String& name) const
180            {
181                _checkRep();
182                return _rep->existsProperty(name);
183            }
184 kumpf 1.10 
185            CIMProperty CIMObject::getProperty(Uint32 pos)
186            {
187                _checkRep();
188                return _rep->getProperty(pos);
189            }
190            
191            CIMConstProperty CIMObject::getProperty(Uint32 pos) const
192            {
193                _checkRep();
194                return _rep->getProperty(pos);
195            }
196            
197            void CIMObject::removeProperty(Uint32 pos)
198            {
199                _checkRep();
200                _rep->removeProperty(pos);
201            }
202            
203            Uint32 CIMObject::getPropertyCount() const
204            {
205 kumpf 1.10     _checkRep();
206                return _rep->getPropertyCount();
207            }
208            
209            CIMObject::operator int() const
210            {
211                return (_rep != 0);
212            }
213            
214 mike  1.6  Boolean CIMObject::identical(const CIMConstObject& x) const
215 mike  1.5  {
216 mike  1.6      x._checkRep();
217                _checkRep();
218                return _rep->identical(x._rep);
219            }
220 mike  1.5  
221 kumpf 1.10 void CIMObject::toXml(Array<Sint8>& out) const
222            {
223                _checkRep();
224                _rep->toXml(out);
225            }
226            
227            CIMObject CIMObject::clone() const
228            {
229                _checkRep();
230                return CIMObject(_rep->clone());
231            }
232            
233            void CIMObject::_checkRep() const
234            {
235                if (!_rep)
236                    ThrowUnitializedHandle();
237            }
238            
239 mike  1.6  ////////////////////////////////////////////////////////////////////////////////
240            //
241            // CIMConstObject
242            //
243            ////////////////////////////////////////////////////////////////////////////////
244            
245 kumpf 1.10 CIMConstObject::CIMConstObject()
246                : _rep(0)
247            {
248            }
249            
250            CIMConstObject::CIMConstObject(const CIMConstObject& x)
251            {
252                Inc(_rep = x._rep);
253            }
254            
255            CIMConstObject::CIMConstObject(const CIMObject& x)
256            {
257                Inc(_rep = x._rep);
258            }
259            
260 mike  1.6  CIMConstObject::CIMConstObject(const CIMClass& x)
261            {
262                Inc(_rep = x._rep);
263 mike  1.5  }
264            
265 chip  1.7  CIMConstObject::CIMConstObject(const CIMConstClass& x)
266            {
267                Inc(_rep = x._rep);
268            }
269            
270 mike  1.6  CIMConstObject::CIMConstObject(const CIMInstance& x)
271 mike  1.5  {
272 mike  1.6      Inc(_rep = x._rep);
273            }
274 mike  1.5  
275 chip  1.7  CIMConstObject::CIMConstObject(const CIMConstInstance& x)
276            {
277                Inc(_rep = x._rep);
278            }
279            
280 kumpf 1.10 CIMConstObject& CIMConstObject::operator=(const CIMConstObject& x)
281            {
282                if (x._rep != _rep)
283                {
284                    Dec(_rep);
285                    Inc(_rep = x._rep);
286                }
287                return *this;
288            }
289            
290            CIMConstObject& CIMConstObject::operator=(const CIMObject& x)
291            {
292                if (x._rep != _rep)
293                {
294                    Dec(_rep);
295                    Inc(_rep = x._rep);
296                }
297                return *this;
298            }
299            
300 mike  1.6  CIMConstObject& CIMConstObject::operator=(const CIMClass& x)
301            {
302                if (x._rep != _rep)
303                {
304 kumpf 1.9          Dec(_rep);
305 mike  1.6  	Inc(_rep = x._rep);
306                }
307                return *this;
308 mike  1.5  }
309            
310 mike  1.6  CIMConstObject& CIMConstObject::operator=(const CIMInstance& x)
311 mike  1.5  {
312 mike  1.6      if (x._rep != _rep)
313                {
314 kumpf 1.9          Dec(_rep);
315 mike  1.6  	Inc(_rep = x._rep);
316                }
317                return *this;
318            }
319 mike  1.5  
320 mike  1.6  CIMConstObject& CIMConstObject::operator=(const CIMConstClass& x)
321            {
322                if (x._rep != _rep)
323 mike  1.5      {
324 kumpf 1.9          Dec(_rep);
325 mike  1.6  	Inc(_rep = x._rep);
326 mike  1.5      }
327 mike  1.6      return *this;
328            }
329            
330            CIMConstObject& CIMConstObject::operator=(const CIMConstInstance& x)
331            {
332                if (x._rep != _rep)
333 mike  1.5      {
334 kumpf 1.9          Dec(_rep);
335 mike  1.6  	Inc(_rep = x._rep);
336 mike  1.5      }
337 mike  1.6      return *this;
338 mike  1.5  }
339            
340 kumpf 1.10 CIMConstObject::~CIMConstObject()
341            {
342                Dec(_rep);
343            }
344            
345            const String& CIMConstObject::getClassName() const
346            {
347                _checkRep();
348                return _rep->getClassName();
349            }
350            
351            const CIMReference& CIMConstObject::getPath() const
352            {
353                _checkRep();
354                return _rep->getPath();
355            }
356            
357            Uint32 CIMConstObject::findQualifier(const String& name) const
358            {
359                _checkRep();
360                return _rep->findQualifier(name);
361 kumpf 1.10 }
362            
363            CIMConstQualifier CIMConstObject::getQualifier(Uint32 pos) const
364            {
365                _checkRep();
366                return _rep->getQualifier(pos);
367            }
368            
369            Uint32 CIMConstObject::getQualifierCount() const
370            {
371                _checkRep();
372                return _rep->getQualifierCount();
373            }
374            
375            Uint32 CIMConstObject::findProperty(const String& name) const
376            {
377                _checkRep();
378                return _rep->findProperty(name);
379            }
380            
381            CIMConstProperty CIMConstObject::getProperty(Uint32 pos) const
382 kumpf 1.10 {
383                _checkRep();
384                return _rep->getProperty(pos);
385            }
386            
387            Uint32 CIMConstObject::getPropertyCount() const
388            {
389                _checkRep();
390                return _rep->getPropertyCount();
391            }
392            
393            CIMConstObject::operator int() const
394            {
395                return (_rep != 0);
396            }
397            
398            void CIMConstObject::toXml(Array<Sint8>& out) const
399            {
400                _checkRep();
401                _rep->toXml(out);
402            }
403 kumpf 1.10 
404            void CIMConstObject::print(PEGASUS_STD(ostream)& o) const
405            {
406                _checkRep();
407                _rep->print(o);
408            }
409            
410            Boolean CIMConstObject::identical(const CIMConstObject& x) const
411            {
412                x._checkRep();
413                _checkRep();
414                return _rep->identical(x._rep);
415            }
416            
417            CIMObject CIMConstObject::clone() const
418            {
419                return CIMObject(_rep->clone());
420            }
421            
422            void CIMConstObject::_checkRep() const
423            {
424 kumpf 1.10     if (!_rep)
425                    ThrowUnitializedHandle();
426            }
427            
428 mike  1.5  ////////////////////////////////////////////////////////////////////////////////
429            //
430            // CIMObjectWithPath
431            //
432            ////////////////////////////////////////////////////////////////////////////////
433            
434            CIMObjectWithPath::CIMObjectWithPath()
435            {
436            }
437            
438            CIMObjectWithPath::CIMObjectWithPath(
439                const CIMReference& reference,
440 chip  1.7      const CIMObject& object)
441 mike  1.5      : _reference(reference), _object(object)
442            {
443            }
444            
445            CIMObjectWithPath::CIMObjectWithPath(const CIMObjectWithPath& x)
446                : _reference(x._reference), _object(x._object)
447            {
448            }
449            
450            CIMObjectWithPath::~CIMObjectWithPath()
451            {
452            }
453            
454            CIMObjectWithPath& CIMObjectWithPath::operator=(const CIMObjectWithPath& x)
455            {
456                if (this != &x)
457                {
458            	_reference = x._reference;
459            	_object = x._object;
460                }
461                return *this;
462 mike  1.5  }
463            
464            void CIMObjectWithPath::set(
465 chip  1.7      const CIMReference& reference,
466 mike  1.5      const CIMObject& object)
467            {
468                _reference = reference;
469                _object = object;
470 kumpf 1.10 }
471            
472            const CIMReference& CIMObjectWithPath::getReference() const
473            {
474                return _reference;
475            }
476            
477            const CIMObject& CIMObjectWithPath::getObject() const
478            {
479                return _object;
480            }
481            
482            CIMReference& CIMObjectWithPath::getReference()
483            {
484                return _reference;
485            }
486            
487            CIMObject& CIMObjectWithPath::getObject()
488            {
489                return _object;
490 mike  1.5  }
491            
492            void CIMObjectWithPath::toXml(Array<Sint8>& out) const
493            {
494                out << "<VALUE.OBJECTWITHPATH>\n";
495            
496                _reference.toXml(out, false);
497                _object.toXml(out);
498            
499                out << "</VALUE.OBJECTWITHPATH>\n";
500            }
501            
502            PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2