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

  1 karl  1.34 //%2005////////////////////////////////////////////////////////////////////////
  2 mike  1.5  //
  3 karl  1.31 // 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 karl  1.29 // IBM Corp.; EMC Corporation, The Open Group.
  7 karl  1.31 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
  8            // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
  9 karl  1.34 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 10            // EMC Corporation; VERITAS Software Corporation; The Open Group.
 11 mike  1.5  //
 12            // Permission is hereby granted, free of charge, to any person obtaining a copy
 13 chip  1.7  // of this software and associated documentation files (the "Software"), to
 14            // deal in the Software without restriction, including without limitation the
 15            // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 16 mike  1.5  // sell copies of the Software, and to permit persons to whom the Software is
 17            // furnished to do so, subject to the following conditions:
 18 kumpf 1.21 // 
 19 chip  1.7  // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
 20 mike  1.5  // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
 21            // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
 22 chip  1.7  // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
 23            // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 24            // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 25 mike  1.5  // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 26            // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 27            //
 28            //==============================================================================
 29            //
 30            // Author: Mike Brasher (mbrasher@bmc.com)
 31            //
 32 kumpf 1.11 // Modified By: Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com)
 33 kumpf 1.18 //              Carol Ann Krug Graves, Hewlett-Packard Company
 34            //                  (carolann_graves@hp.com)
 35 dave.sudlik 1.32 //              Dave Sudlik, IBM (dsudlik@us.ibm.com)
 36 david.dillard 1.33 //              David Dillard, VERITAS Software Corp.
 37                    //                  (david.dillard@veritas.com)
 38 mike          1.5  //
 39                    //%/////////////////////////////////////////////////////////////////////////////
 40                    
 41 kumpf         1.10 #include "CIMClassRep.h"
 42                    #include "CIMInstanceRep.h"
 43                    #include "CIMObjectRep.h"
 44 mike          1.5  #include "CIMObject.h"
 45 mike          1.6  #include "CIMClass.h"
 46                    #include "CIMInstance.h"
 47 mike          1.5  #include "XmlWriter.h"
 48                    
 49                    PEGASUS_NAMESPACE_BEGIN
 50                    
 51 kumpf         1.19 #define PEGASUS_ARRAY_T CIMObject
 52                    # include "ArrayImpl.h"
 53                    #undef PEGASUS_ARRAY_T
 54                    
 55 mike          1.5  ////////////////////////////////////////////////////////////////////////////////
 56                    //
 57                    // CIMObject
 58                    //
 59                    ////////////////////////////////////////////////////////////////////////////////
 60                    
 61 kumpf         1.10 CIMObject::CIMObject()
 62                        : _rep(0)
 63                    {
 64                    }
 65                    
 66                    CIMObject::CIMObject(const CIMObject& x)
 67                    {
 68                        Inc(_rep = x._rep);
 69                    }
 70                    
 71 mike          1.6  CIMObject::CIMObject(const CIMClass& x)
 72 mike          1.5  {
 73 mike          1.6      Inc(_rep = x._rep);
 74                    }
 75 mike          1.5  
 76 mike          1.6  CIMObject::CIMObject(const CIMInstance& x)
 77                    {
 78                        Inc(_rep = x._rep);
 79 mike          1.5  }
 80                    
 81 kumpf         1.10 CIMObject::CIMObject(CIMObjectRep* rep)
 82                        : _rep(rep)
 83                    {
 84                    }
 85                    
 86                    CIMObject& CIMObject::operator=(const CIMObject& x)
 87                    {
 88                        if (x._rep != _rep)
 89                        {
 90                            Dec(_rep);
 91                    	Inc(_rep = x._rep);
 92                        }
 93                        return *this;
 94                    }
 95                    
 96                    CIMObject::~CIMObject()
 97                    {
 98                        Dec(_rep);
 99                    }
100                    
101 kumpf         1.23 const CIMName& CIMObject::getClassName() const
102 kumpf         1.10 {
103                        _checkRep();
104                        return _rep->getClassName();
105                    }
106                    
107 kumpf         1.16 const CIMObjectPath& CIMObject::getPath() const
108 kumpf         1.10 {
109                        _checkRep();
110                        return _rep->getPath();
111 kumpf         1.18 }
112                    
113                    void CIMObject::setPath (const CIMObjectPath & path)
114                    {
115                        _checkRep ();
116                        _rep->setPath (path);
117 kumpf         1.10 }
118                    
119                    CIMObject& CIMObject::addQualifier(const CIMQualifier& qualifier)
120                    {
121                        _checkRep();
122                        _rep->addQualifier(qualifier);
123                        return *this;
124                    }
125                    
126 kumpf         1.23 Uint32 CIMObject::findQualifier(const CIMName& name) const
127 kumpf         1.10 {
128                        _checkRep();
129                        return _rep->findQualifier(name);
130                    }
131                    
132 kumpf         1.28 CIMQualifier CIMObject::getQualifier(Uint32 index)
133 kumpf         1.10 {
134                        _checkRep();
135 kumpf         1.28     return _rep->getQualifier(index);
136 kumpf         1.10 }
137                    
138 kumpf         1.28 CIMConstQualifier CIMObject::getQualifier(Uint32 index) const
139 kumpf         1.10 {
140                        _checkRep();
141 kumpf         1.28     return _rep->getQualifier(index);
142 kumpf         1.10 }
143                    
144 kumpf         1.28 void CIMObject::removeQualifier(Uint32 index)
145 kumpf         1.10 {
146                        _checkRep();
147 kumpf         1.28     _rep->removeQualifier(index);
148 kumpf         1.10 }
149                    
150                    Uint32 CIMObject::getQualifierCount() const
151                    {
152                        _checkRep();
153                        return _rep->getQualifierCount();
154                    }
155                    
156                    CIMObject& CIMObject::addProperty(const CIMProperty& x)
157                    {
158                        _checkRep();
159                        _rep->addProperty(x);
160                        return *this;
161                    }
162                    
163 kumpf         1.23 Uint32 CIMObject::findProperty(const CIMName& name) const
164 kumpf         1.10 {
165                        _checkRep();
166                        return _rep->findProperty(name);
167                    }
168                    
169 kumpf         1.28 CIMProperty CIMObject::getProperty(Uint32 index)
170 kumpf         1.10 {
171                        _checkRep();
172 kumpf         1.28     return _rep->getProperty(index);
173 kumpf         1.10 }
174                    
175 kumpf         1.28 CIMConstProperty CIMObject::getProperty(Uint32 index) const
176 kumpf         1.10 {
177                        _checkRep();
178 kumpf         1.28     return _rep->getProperty(index);
179 kumpf         1.10 }
180                    
181 kumpf         1.28 void CIMObject::removeProperty(Uint32 index)
182 kumpf         1.10 {
183                        _checkRep();
184 kumpf         1.28     _rep->removeProperty(index);
185 kumpf         1.10 }
186                    
187                    Uint32 CIMObject::getPropertyCount() const
188                    {
189                        _checkRep();
190                        return _rep->getPropertyCount();
191                    }
192                    
193 kumpf         1.24 Boolean CIMObject::isUninitialized() const
194 kumpf         1.10 {
195 kumpf         1.13     return (_rep == 0)? true : false;
196 kumpf         1.10 }
197                    
198 dave.sudlik   1.32 String CIMObject::toString () const
199                    {
200 david.dillard 1.33     Array<char> out;
201 dave.sudlik   1.32     
202                        _checkRep();
203                        _rep->toXml(out);
204 david.dillard 1.35     out.append('\0');
205 dave.sudlik   1.32 
206                        return out.getData();
207                    }
208                    
209 kumpf         1.25 Boolean CIMObject::isClass () const
210                    {
211                        try
212                        {
213                            const CIMClass c (*this);
214                            return true;
215                        }
216 kumpf         1.30     catch (DynamicCastFailedException&)
217 kumpf         1.25     {
218                            return false;
219                        }
220                    }
221                    
222                    Boolean CIMObject::isInstance () const
223                    {
224                        try
225                        {
226                            const CIMInstance i (*this);
227                            return true;
228                        }
229 kumpf         1.30     catch (DynamicCastFailedException&)
230 kumpf         1.25     {
231                            return false;
232                        }
233                    }
234                    
235 mike          1.6  Boolean CIMObject::identical(const CIMConstObject& x) const
236 mike          1.5  {
237 mike          1.6      x._checkRep();
238                        _checkRep();
239                        return _rep->identical(x._rep);
240                    }
241 mike          1.5  
242 kumpf         1.10 CIMObject CIMObject::clone() const
243                    {
244                        _checkRep();
245                        return CIMObject(_rep->clone());
246                    }
247                    
248                    void CIMObject::_checkRep() const
249                    {
250                        if (!_rep)
251 kumpf         1.27         throw UninitializedObjectException();
252 kumpf         1.10 }
253                    
254 mike          1.6  ////////////////////////////////////////////////////////////////////////////////
255                    //
256                    // CIMConstObject
257                    //
258                    ////////////////////////////////////////////////////////////////////////////////
259                    
260 kumpf         1.10 CIMConstObject::CIMConstObject()
261                        : _rep(0)
262                    {
263                    }
264                    
265                    CIMConstObject::CIMConstObject(const CIMConstObject& x)
266                    {
267                        Inc(_rep = x._rep);
268                    }
269                    
270                    CIMConstObject::CIMConstObject(const CIMObject& x)
271                    {
272                        Inc(_rep = x._rep);
273                    }
274                    
275 mike          1.6  CIMConstObject::CIMConstObject(const CIMClass& x)
276                    {
277                        Inc(_rep = x._rep);
278 mike          1.5  }
279                    
280 chip          1.7  CIMConstObject::CIMConstObject(const CIMConstClass& x)
281                    {
282                        Inc(_rep = x._rep);
283                    }
284                    
285 mike          1.6  CIMConstObject::CIMConstObject(const CIMInstance& x)
286 mike          1.5  {
287 mike          1.6      Inc(_rep = x._rep);
288                    }
289 mike          1.5  
290 chip          1.7  CIMConstObject::CIMConstObject(const CIMConstInstance& x)
291                    {
292                        Inc(_rep = x._rep);
293                    }
294                    
295 kumpf         1.10 CIMConstObject& CIMConstObject::operator=(const CIMConstObject& x)
296                    {
297                        if (x._rep != _rep)
298                        {
299                            Dec(_rep);
300                            Inc(_rep = x._rep);
301 mike          1.5      }
302 mike          1.6      return *this;
303 mike          1.5  }
304                    
305 kumpf         1.10 CIMConstObject::~CIMConstObject()
306                    {
307                        Dec(_rep);
308                    }
309                    
310 kumpf         1.23 const CIMName& CIMConstObject::getClassName() const
311 kumpf         1.10 {
312                        _checkRep();
313                        return _rep->getClassName();
314                    }
315                    
316 kumpf         1.16 const CIMObjectPath& CIMConstObject::getPath() const
317 kumpf         1.10 {
318                        _checkRep();
319                        return _rep->getPath();
320                    }
321                    
322 kumpf         1.23 Uint32 CIMConstObject::findQualifier(const CIMName& name) const
323 kumpf         1.10 {
324                        _checkRep();
325                        return _rep->findQualifier(name);
326                    }
327                    
328 kumpf         1.28 CIMConstQualifier CIMConstObject::getQualifier(Uint32 index) const
329 kumpf         1.10 {
330                        _checkRep();
331 kumpf         1.28     return _rep->getQualifier(index);
332 kumpf         1.10 }
333                    
334                    Uint32 CIMConstObject::getQualifierCount() const
335                    {
336                        _checkRep();
337                        return _rep->getQualifierCount();
338                    }
339                    
340 kumpf         1.23 Uint32 CIMConstObject::findProperty(const CIMName& name) const
341 kumpf         1.10 {
342                        _checkRep();
343                        return _rep->findProperty(name);
344                    }
345                    
346 kumpf         1.28 CIMConstProperty CIMConstObject::getProperty(Uint32 index) const
347 kumpf         1.10 {
348                        _checkRep();
349 kumpf         1.28     return _rep->getProperty(index);
350 kumpf         1.10 }
351                    
352                    Uint32 CIMConstObject::getPropertyCount() const
353                    {
354                        _checkRep();
355                        return _rep->getPropertyCount();
356                    }
357                    
358 kumpf         1.24 Boolean CIMConstObject::isUninitialized() const
359 kumpf         1.10 {
360 kumpf         1.13     return (_rep == 0)? true : false;
361 kumpf         1.10 }
362                    
363 dave.sudlik   1.32 String CIMConstObject::toString () const
364                    {
365 david.dillard 1.33     Array<char> out;
366 dave.sudlik   1.32     
367                        _checkRep();
368                        _rep->toXml(out);
369 david.dillard 1.35     out.append('\0');
370 dave.sudlik   1.32 
371                        return out.getData();
372                    }
373                    
374 kumpf         1.27 Boolean CIMConstObject::isClass() const
375                    {
376                        try
377                        {
378                            const CIMConstClass c(*this);
379                            return true;
380                        }
381 kumpf         1.30     catch (DynamicCastFailedException&)
382 kumpf         1.27     {
383                            return false;
384                        }
385                    }
386                    
387                    Boolean CIMConstObject::isInstance() const
388                    {
389                        try
390                        {
391                            const CIMConstInstance i(*this);
392                            return true;
393                        }
394 kumpf         1.30     catch (DynamicCastFailedException&)
395 kumpf         1.27     {
396                            return false;
397                        }
398                    }
399                    
400 kumpf         1.10 Boolean CIMConstObject::identical(const CIMConstObject& x) const
401                    {
402                        x._checkRep();
403                        _checkRep();
404                        return _rep->identical(x._rep);
405                    }
406                    
407                    CIMObject CIMConstObject::clone() const
408                    {
409                        return CIMObject(_rep->clone());
410                    }
411                    
412                    void CIMConstObject::_checkRep() const
413                    {
414                        if (!_rep)
415 kumpf         1.27         throw UninitializedObjectException();
416 kumpf         1.10 }
417                    
418 mike          1.5  PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2