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

  1 mike  1.6 //%/////////////////////////////////////////////////////////////////////////////
  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.9 // 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.6 // 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.9 //
 12           // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
 13 mike  1.6 // 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.9 // 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.6 // 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 mike  1.7 #ifndef Pegasus_Object_h
 30           #define Pegasus_Object_h
 31 mike  1.6 
 32           #include <Pegasus/Common/Config.h>
 33 mike  1.7 #include <Pegasus/Common/CIMObjectRep.h>
 34 mike  1.6 
 35           PEGASUS_NAMESPACE_BEGIN
 36           
 37 mike  1.7 class CIMClass;
 38           class CIMConstClass;
 39           class CIMInstance;
 40           class CIMConstInstance;
 41           
 42           ////////////////////////////////////////////////////////////////////////////////
 43           //
 44           // CIMObject
 45           //
 46           ////////////////////////////////////////////////////////////////////////////////
 47           
 48           class CIMConstObject;
 49           class CIMObject;
 50           
 51 chip  1.9 /** This class either refers to a CIMInstance or a CIMClass.
 52 mike  1.7 
 53               The CIMObjectRep data member points to either a CIMInstanceRep or
 54               CIMClassRep.
 55 mike  1.6 */
 56           class PEGASUS_COMMON_LINKAGE CIMObject
 57           {
 58           public:
 59           
 60 mike  1.7     /** Constructor.
 61               */
 62               CIMObject() : _rep(0)
 63 mike  1.6     {
 64           
 65               }
 66           
 67 mike  1.7     /** Copy constructor.
 68               */
 69               CIMObject(const CIMObject& x)
 70 mike  1.6     {
 71           	Inc(_rep = x._rep);
 72               }
 73           
 74 mike  1.7     /** Construction from CIMClass.
 75               */
 76               CIMObject(const CIMClass& x);
 77 mike  1.6 
 78 mike  1.7     /** Construction from CIMInstance.
 79               */
 80               CIMObject(const CIMInstance& x);
 81 mike  1.6 
 82 mike  1.7     /** Assignment operator.
 83               */
 84 mike  1.6     CIMObject& operator=(const CIMObject& x)
 85               {
 86           	if (x._rep != _rep)
 87           	{
 88           	    Dec(_rep);
 89           	    Inc(_rep = x._rep);
 90           	}
 91           	return *this;
 92               }
 93           
 94 mike  1.7     /** Assignment operator.
 95               */
 96               CIMObject& operator=(const CIMClass& x);
 97           
 98               /** Assignment operator.
 99               */
100               CIMObject& operator=(const CIMInstance& x);
101           
102 chip  1.9     /** Destructor.
103 mike  1.7     */
104               ~CIMObject()
105               {
106           	Dec(_rep);
107               }
108           
109               /**	Accessor.
110               */
111               const String& getClassName() const
112               {
113           	_checkRep();
114           	return _rep->getClassName();
115               }
116           
117 chip  1.12     const CIMReference& getPath() const
118                {
119            	_checkRep();
120            	return _rep->getPath();
121                }
122            
123 mike  1.7      /**	addQualifier - Adds the CIMQualifier object to the instance.
124            	Thows an exception of the CIMQualifier already exists in the instance
125            	@param CIMQualifier object to add to instance
126            	@return ATTN:
127            	@exception Throws AlreadyExists.
128                */
129                CIMObject& addQualifier(const CIMQualifier& qualifier)
130                {
131            	_checkRep();
132            	_rep->addQualifier(qualifier);
133            	return *this;
134                }
135            
136                /**	findQualifier - Searches the instance for the qualifier object
137                    defined by the input parameter.
138            	@param String defining the qualifier object to be found.
139            	@return - Position of the qualifier to be used in subsequent
140            	operations or PEG_NOT_FOUND if the qualifier is not found.
141                */
142                Uint32 findQualifier(const String& name)
143                {
144 mike  1.7  	_checkRep();
145            	return _rep->findQualifier(name);
146                }
147            
148                Uint32 findQualifier(const String& name) const
149                {
150            	_checkRep();
151            	return _rep->findQualifier(name);
152                }
153            
154                /**	existsQualifier - Searches the instance for the qualifier object
155                    defined by the input parameter.
156            	@param String defining the qualifier object to be found.
157            	@return - Returns True if  the qualifier object exists or false
158            	if the qualifier is not found.
159                */
160                Boolean existsQualifier(const String& name)
161                {
162            	_checkRep();
163            	return _rep->existsQualifier(name);
164                }
165 mike  1.7  
166                Boolean existsQualifier(const String& name) const
167                {
168            	_checkRep();
169            	return _rep->existsQualifier(name);
170                }
171            
172                /**	getQualifier - Retrieves the qualifier object defined by the
173            	index input parameter.  @ index for the qualifier object.
174            	The index to qualifier objects is zero-origin and continuous
175            	so that incrementing loops can be used to get all qualifier
176            	objects in a CIMInstnace.
177            	@return: Returns qualifier object defined by index.
178            	@exception Throws the OutOfBounds exception if the index
179            	is out of bounds
180                */
181                CIMQualifier getQualifier(Uint32 pos)
182                {
183            	_checkRep();
184            	return _rep->getQualifier(pos);
185                }
186 mike  1.7  
187                /** getQualifier - Retrieves the qualifier object defined by the
188            	index input parameter.  @ index for the qualifier object.
189            	The index to qualifier objects is zero-origin and continuous
190            	so that incrementing loops can be used to get all qualifier
191            	objects in a CIMInstnace.
192            	@return: Returns qualifier object defined by index.
193            	@exception Throws the OutOfBounds exception if the index
194            	is out of bounds
195            	ATTN: What is effect of out of range index???
196            	ATTN: Is the above statement correct???
197                */
198                CIMConstQualifier getQualifier(Uint32 pos) const
199                {
200            	_checkRep();
201            	return _rep->getQualifier(pos);
202                }
203            
204 chip  1.11     void removeQualifier(Uint32 pos)
205            	{
206            	_checkRep();
207            	_rep->removeQualifier(pos);
208            	}
209            	
210            	/**	getQualifierCount - Gets the numbercount of CIMQualifierobjects
211 mike  1.7  	defined for this CIMObject.
212            	@return	Count of the number of CIMQalifier objects in the
213            	CIMObject.
214            	@exception Throws the OutOfBounds exception if the index
215            	is out of bounds
216                */
217                Uint32 getQualifierCount() const
218                {
219            	_checkRep();
220            	return _rep->getQualifierCount();
221                }
222            
223                /**	addProperty - Adds a property object defined by the input
224            	parameter to the CIMObject
225            	@param Property Object to be added.  See the CIM Property
226            	class for definition of the property object
227            	@return ATTN:
228            	@exception Throws the exception AlreadyExists if the property
229            	already exists.
230                */
231                CIMObject& addProperty(const CIMProperty& x)
232 mike  1.7      {
233            	_checkRep();
234            	_rep->addProperty(x);
235            	return *this;
236                }
237            
238                /**	findProperty - Searches the CIMProperty objects installed in the
239            	CIMObject for property objects with the name defined by the
240            	input.
241            	@param String with the name of the property object to be found
242            	@return Position in the CIM object to the property object if found or
243            	PEG_NOT_FOUND if no property object found with the name defined by the
244            	input.
245                */
246                Uint32 findProperty(const String& name)
247                {
248            	_checkRep();
249            	return _rep->findProperty(name);
250                }
251            
252                Uint32 findProperty(const String& name) const
253 mike  1.7      {
254            	_checkRep();
255            	return _rep->findProperty(name);
256                }
257            
258                /** existsPropery - Determines if a property object with the
259            	name defined by the input parameter exists in the class.
260            	@parm String parameter with the property name.
261            	@return True if the property object exists.
262                */
263                Boolean existsProperty(const String& name)
264                {
265            	_checkRep();
266            	return _rep->existsProperty(name);
267                }
268            
269                Boolean existsProperty(const String& name) const
270                {
271                   _checkRep();
272                   return _rep->existsProperty(name);
273                }
274 mike  1.7  
275                /**	getProperty - Gets the CIMproperty object in the CIMObject defined
276            	by the input index parameter.
277            	@param Index to the property object in the CIMObject.
278                	The index to qualifier objects is zero-origin and continuous
279            	so that incrementing loops can be used to get all qualifier
280            	objects in a CIMObject.
281            	@return CIMProperty object corresponding to the index.
282            	@exception Throws the OutOfBounds exception if the index
283            	is out of bounds
284            
285            	ATTN: What is the effect of out of range?
286                */
287                CIMProperty getProperty(Uint32 pos)
288                {
289            	_checkRep();
290            	return _rep->getProperty(pos);
291                }
292            
293                /**	getProperty - Gets the CIMproperty object in the CIMObject defined
294            	by the input index parameter.
295 mike  1.7  	@param Index to the property object in the CIMObject.
296                	The index to qualifier objects is zero-origin and continuous
297            	so that incrementing loops can be used to get all qualifier
298            	objects in a CIMInstnace.
299            	@return CIMProperty object corresponding to the index.
300            	@exception Throws the OutOfBounds exception if the index
301            	is out of bounds
302            
303            	ATTN: What is the effect of out of range?
304                */
305                CIMConstProperty getProperty(Uint32 pos) const
306                {
307            	_checkRep();
308            	return _rep->getProperty(pos);
309                }
310            
311                /** removeProperty - Removes the property represented
312            	by the position input parameter from the instance.
313            	@param pos Index to the property to be removed from the
314            	instance.  Normally this is obtained by getProperty();
315            	@exception Throws OutofBounds if index is not a property object
316 mike  1.7      */
317                void removeProperty(Uint32 pos)
318                {
319            	_checkRep();
320            	_rep->removeProperty(pos);
321                }
322            
323                /**	getPropertyCount - Gets the numbercount of CIMProperty
324            	objects defined for this CIMObject.
325            	@return	Count of the number of CIMProperty objects in the
326            	CIMObject. Zero indicates that no CIMProperty objects
327            	are contained in the CIMObject
328            	@exception Throws the OutOfBounds exception if the index
329            	is out of bounds
330            
331                */
332                Uint32 getPropertyCount() const
333                {
334            	_checkRep();
335            	return _rep->getPropertyCount();
336                }
337 mike  1.7  
338                /**	operator int() - ATTN: */
339                operator int() const { return _rep != 0; }
340            
341                /**	Returns true if the two classes are structurally identical.
342                */
343                Boolean identical(const CIMConstObject& x) const;
344            
345                /** Convert object to XML format.
346                */
347 mike  1.8      void toXml(Array<Sint8>& out) const
348 mike  1.7      {
349            	_checkRep();
350            	_rep->toXml(out);
351                }
352            
353                /**	Clones the given object.
354                */
355                CIMObject clone() const
356                {
357            	_checkRep();
358            	return CIMObject(_rep->clone());
359                }
360            
361            private:
362            
363                CIMObject(CIMObjectRep* rep) : _rep(rep)
364                {
365            
366                }
367            
368                void _checkRep() const
369 mike  1.7      {
370            	if (!_rep)
371            	    ThrowUnitializedHandle();
372                }
373            
374 chip  1.10     CIMObjectRep* _rep;
375 mike  1.7  
376                friend class CIMConstObject;
377                friend class CIMClass;
378                friend class CIMConstClass;
379                friend class CIMInstance;
380                friend class CIMConstInstance;
381            };
382            
383            ////////////////////////////////////////////////////////////////////////////////
384            //
385            // CIMConstObject
386            //
387            ////////////////////////////////////////////////////////////////////////////////
388            
389            class PEGASUS_COMMON_LINKAGE CIMConstObject
390            {
391            public:
392            
393                CIMConstObject() : _rep(0)
394                {
395            
396 mike  1.7      }
397            
398                CIMConstObject(const CIMConstObject& x)
399                {
400            	Inc(_rep = x._rep);
401                }
402            
403                CIMConstObject(const CIMObject& x)
404                {
405            	Inc(_rep = x._rep);
406                }
407            
408                /** Construction from CIMClass.
409                */
410                CIMConstObject(const CIMClass& x);
411            
412                /** Construction from CIMInstance.
413                */
414                CIMConstObject(const CIMInstance& x);
415            
416                /** Construction from CIMClass.
417 mike  1.7      */
418                CIMConstObject(const CIMConstClass& x);
419            
420                /** Construction from CIMInstance.
421                */
422                CIMConstObject(const CIMConstInstance& x);
423            
424                CIMConstObject& operator=(const CIMConstObject& x)
425 mike  1.6      {
426            	if (x._rep != _rep)
427            	{
428            	    Dec(_rep);
429            	    Inc(_rep = x._rep);
430            	}
431            	return *this;
432                }
433            
434 mike  1.7      CIMConstObject& operator=(const CIMObject& x)
435 mike  1.6      {
436            	if (x._rep != _rep)
437            	{
438            	    Dec(_rep);
439            	    Inc(_rep = x._rep);
440            	}
441            	return *this;
442                }
443            
444 mike  1.7      CIMConstObject& operator=(const CIMClass& x);
445            
446                CIMConstObject& operator=(const CIMConstClass& x);
447            
448                CIMConstObject& operator=(const CIMInstance& x);
449            
450                CIMConstObject& operator=(const CIMConstInstance& x);
451            
452                ~CIMConstObject()
453 mike  1.6      {
454            	Dec(_rep);
455                }
456            
457 mike  1.7      const String& getClassName() const
458 mike  1.6      {
459 mike  1.7  	_checkRep();
460            	return _rep->getClassName();
461 chip  1.12     }
462            
463                const CIMReference& getPath() const
464                {
465            	_checkRep();
466            	return _rep->getPath();
467 mike  1.6      }
468            
469 mike  1.7      Uint32 findQualifier(const String& name) const
470 mike  1.6      {
471 mike  1.7  	_checkRep();
472            	return _rep->findQualifier(name);
473 mike  1.6      }
474            
475 mike  1.7      CIMConstQualifier getQualifier(Uint32 pos) const
476                {
477            	_checkRep();
478            	return _rep->getQualifier(pos);
479                }
480            
481                Uint32 getQualifierCount() const
482                {
483            	_checkRep();
484            	return _rep->getQualifierCount();
485                }
486            
487                Uint32 findProperty(const String& name) const
488                {
489            	_checkRep();
490            	return _rep->findProperty(name);
491                }
492 mike  1.6  
493 mike  1.7      CIMConstProperty getProperty(Uint32 pos) const
494                {
495            	_checkRep();
496            	return _rep->getProperty(pos);
497                }
498 mike  1.6  
499 mike  1.7      Uint32 getPropertyCount() const
500                {
501            	_checkRep();
502            	return _rep->getPropertyCount();
503                }
504 mike  1.6  
505 mike  1.7      operator int() const { return _rep != 0; }
506 mike  1.6  
507 mike  1.7      void toXml(Array<Sint8>& out) const
508                {
509            	_checkRep();
510            	_rep->toXml(out);
511                }
512 mike  1.6  
513 mike  1.7      void print(PEGASUS_STD(ostream) &o=PEGASUS_STD(cout)) const
514                {
515            	_checkRep();
516            	_rep->print(o);
517                }
518 mike  1.6  
519 mike  1.7      Boolean identical(const CIMConstObject& x) const
520                {
521            	x._checkRep();
522            	_checkRep();
523            	return _rep->identical(x._rep);
524 mike  1.6      }
525            
526 mike  1.7      CIMObject clone() const
527                {
528            	return CIMObject(_rep->clone());
529                }
530 mike  1.6  
531            private:
532            
533                void _checkRep() const
534                {
535            	if (!_rep)
536            	    ThrowUnitializedHandle();
537                }
538            
539 mike  1.7      CIMObjectRep* _rep;
540 mike  1.6  
541 mike  1.7      friend class CIMObject;
542                friend class CIMClass;
543                friend class CIMConstClass;
544                friend class CIMInstance;
545                friend class CIMConstInstance;
546 mike  1.6  };
547            
548            /** The CIMObjectWithPath encapsulates a CIMReference and CIMObject.
549                Accessors are provided for getting the two parts. Constructors are
550                provided for initializing it from a CIMObject.
551            */
552            class PEGASUS_COMMON_LINKAGE CIMObjectWithPath
553            {
554            public:
555            
556                /**	Constructor
557                */
558                CIMObjectWithPath();
559            
560                /** constructor
561                */
562                CIMObjectWithPath(const CIMReference& reference, const CIMObject& object);
563            
564                /** Constructor - Constructs a CIMObjectWithPath Object from
565                    another CimObjectWithPath
566                    @param - ATTN
567 mike  1.6      */
568                CIMObjectWithPath(const CIMObjectWithPath& x);
569            
570                ~CIMObjectWithPath();
571            
572                CIMObjectWithPath& operator=(const CIMObjectWithPath& x);
573            
574 chip  1.9      /** set -
575 mike  1.6      */
576                void set(const CIMReference& reference, const CIMObject& object);
577            
578                /**
579                */
580                const CIMReference& getReference() const { return _reference; }
581            
582                /**
583                */
584                const CIMObject& getObject() const { return _object; }
585            
586                /**
587                */
588                CIMReference& getReference() { return _reference; }
589            
590                /**
591                */
592                CIMObject& getObject() { return _object; }
593            
594                /**
595                */
596 mike  1.6      void toXml(Array<Sint8>& out) const;
597            
598            private:
599            
600                CIMReference _reference;
601                CIMObject _object;
602            };
603            
604            PEGASUS_NAMESPACE_END
605            
606 mike  1.7  #endif /* Pegasus_Object_h */

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2