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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2