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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2