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

  1 mike  1.9 //%/////////////////////////////////////////////////////////////////////////////
  2 mike  1.1 //
  3           // Copyright (c) 2000 The Open Group, BMC Software, Tivoli Systems, IBM
  4           //
  5           // Permission is hereby granted, free of charge, to any person obtaining a
  6           // copy of this software and associated documentation files (the "Software"),
  7           // to deal in the Software without restriction, including without limitation
  8           // the rights to use, copy, modify, merge, publish, distribute, sublicense,
  9           // and/or sell copies of the Software, and to permit persons to whom the
 10           // Software is furnished to do so, subject to the following conditions:
 11           //
 12           // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 13           // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 14           // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
 15           // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 16           // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 17           // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 18           // DEALINGS IN THE SOFTWARE.
 19           //
 20 mike  1.9 //==============================================================================
 21 mike  1.1 //
 22 mike  1.9 // Author: Mike Brasher (mbrasher@bmc.com)
 23 mike  1.1 //
 24 mike  1.9 // Modified By:
 25 karl  1.7 //
 26 mike  1.9 //%/////////////////////////////////////////////////////////////////////////////
 27 mike  1.1 
 28 mike  1.9 #ifndef Pegasus_CIMClass_h
 29           #define Pegasus_CIMClass_h
 30 mike  1.1 
 31           #include <Pegasus/Common/Config.h>
 32           #include <Pegasus/Common/CIMClassRep.h>
 33           
 34           PEGASUS_NAMESPACE_BEGIN
 35           
 36 mike  1.8 class CIMConstClass;
 37 mike  1.1 
 38 karl  1.4 /** The CIMClass class is used to represent CIM classes in Pegasus.  In CIM,
 39               a class object may be a class or an associator.  A CIM class must contain a
 40               name and may contain methods, properties, and qualifiers.  It is a template
 41               for creating a CIM instance.  A CIM class represents a collection of CIM
 42               instances, all of which support a common type (for example, a set of
 43               properties, methods, and associations).
 44 mike  1.1 */
 45           
 46           class PEGASUS_COMMON_LINKAGE CIMClass
 47           {
 48           public:
 49           
 50 karl  1.11     /** Constructor - Creates an uninitiated a new CIM object
 51 karl  1.6  	reprenting a CIM class. The class object created by this
 52            	constructor can only be used in an operation such as the
 53            	copy constructor.  It cannot be used to create a class by
 54            	appending names, properties, etc. since it is unitiated.
 55 karl  1.11 
 56            	Use one of the other constructors to create an initiated new CIM class
 57 karl  1.6  	object.
 58 karl  1.11 	@exception Throws an exception "unitialized handle" if this
 59 karl  1.7  	unitialized handle is used
 60            	/REF(HPEGASUS_HANDLES)
 61 mike  1.1      */
 62                CIMClass() : _rep(0)
 63                {
 64            
 65                }
 66            
 67 karl  1.7      /** Constructor - Creates a class from a previous class
 68                */
 69 mike  1.1      CIMClass(const CIMClass& x)
 70                {
 71            	Inc(_rep = x._rep);
 72                }
 73            
 74 karl  1.6      /// Operator = Assigns the CIM Class constructor.
 75 mike  1.1      CIMClass& operator=(const CIMClass& x)
 76                {
 77            	if (x._rep != _rep)
 78            	{
 79            	    Dec(_rep);
 80            	    Inc(_rep = x._rep);
 81            	}
 82            	return *this;
 83                }
 84            
 85 karl  1.4      /**	 Constructor - Creates a Class from inputs of a classname and
 86 mike  1.3  	SuperClassName
 87 karl  1.11 	@param className String representing name of the class being created
 88            	@param superClassName String representing name of the SuperClass
 89 mike  1.3  	ATTN: Define what makes up legal name.
 90            	@return Throws IllegalName if className argument illegal CIM identifier.
 91 karl  1.7  	<pre>
 92 karl  1.11 	    CIMClass NewCass("MyClass", "YourClass");
 93 karl  1.7  	</pre>
 94            
 95 mike  1.1      */
 96                CIMClass(
 97 karl  1.4  	const String& className,
 98 mike  1.1  	const String& superClassName = String())
 99                {
100            	_rep = new CIMClassRep(className, superClassName);
101                }
102 mike  1.3  
103 mike  1.1      /// Destructor
104                ~CIMClass()
105                {
106            	Dec(_rep);
107                }
108 mike  1.3  
109 karl  1.11     /** isAssociation - Identifies whether or not this CIM class
110 karl  1.4  	is an association. An association is a relationship between two
111            	(or more) classes or instances of two classes.  The properties of an
112            	association class include pointers, or references, to the two (or
113            	more) instances. All CIM classes can be included in one or more
114 karl  1.11 	associations.
115 karl  1.4  	@return  Boolean True if this CIM class belongs to an association;
116            	otherwise, false.
117                */
118 mike  1.1      Boolean isAssociation() const
119                {
120            	_checkRep();
121            	return _rep->isAssociation();
122                }
123 mike  1.3  
124 mike  1.1      ///	 CIMMethod isAbstract
125                Boolean isAbstract() const
126                {
127            	_checkRep();
128            	return _rep->isAbstract();
129                }
130 mike  1.3  
131 karl  1.11     /** getClassName Gets the name of the class
132 mike  1.3  	ATTN: COMMENT. Why not just get name so we have common method for all.
133 karl  1.11 	@return Returns string with the class name.
134 mike  1.1      */
135 karl  1.4      const String& getClassName() const
136 mike  1.3      {
137 mike  1.1  	_checkRep();
138 karl  1.4  	return _rep->getClassName();
139 mike  1.1      }
140 mike  1.3  
141 mike  1.1      /** CIMMethod getSuperClassName - Gets the name of the Parent
142 mike  1.3  	@return String with parent class name.
143 mike  1.1      */
144 karl  1.4      const String& getSuperClassName() const
145 mike  1.3      {
146 mike  1.1  	_checkRep();
147 karl  1.4  	return _rep->getSuperClassName();
148 mike  1.1      }
149 mike  1.3  
150 mike  1.1      /**	CIMMethod setSuperClassName - Sets the name of the parent class from
151 mike  1.3  	the input parameter. \REF{CLASSNAME}. ATTN: Define legal classnames
152 karl  1.11 	@param String defining parent name.
153 karl  1.4  	@return Throws IllegalName if superClassName argument not legal CIM
154 karl  1.11 	identifier
155            	@exception throws IllegalName if the name is not correct. See
156            	\URL[ClassNames]{DefinitionofTerms.html#CLASSNAME}
157 mike  1.3      */
158 mike  1.1      void setSuperClassName(const String& superClassName)
159                {
160            	_checkRep();
161            	_rep->setSuperClassName(superClassName);
162                }
163 mike  1.3  
164 karl  1.11     /** addQualifier - Adds the specified qualifier to the class
165 mike  1.3  	and increments the qualifier count. It is illegal to add the same
166            	qualifier more than one time.
167 karl  1.11 	@param qualifier CIMQualifier object representing the qualifier to be
168            	added
169            	@return Returns handle of the class object
170            	@exception Throws AlreadyExists.
171 mike  1.1      */
172                CIMClass& addQualifier(const CIMQualifier& qualifier)
173                {
174            	_checkRep();
175            	_rep->addQualifier(qualifier);
176            	return *this;
177                }
178 mike  1.3  
179 karl  1.11     /**	findQualifier - Searches for a qualifier with the specified `
180                    input name if it exists in the class
181            	@param name CIMName of the qualifier
182            	to be found @return Position of the qualifier in the Class.
183 karl  1.16 	@return Returns index of the qualifier found or PEG_NOT_FOUND
184            	if not found.
185 mike  1.1      */
186                Uint32 findQualifier(const String& name)
187                {
188            	_checkRep();
189            	return _rep->findQualifier(name);
190                }
191 karl  1.11     ///
192 mike  1.1      Uint32 findQualifier(const String& name) const
193                {
194            	_checkRep();
195            	return _rep->findQualifier(name);
196                }
197 karl  1.15     /** existsQualifier - Returns true if the qualifier with the
198                specified name exists in the class
199                @param name String name of the qualifier object being tested.
200                @return True if the qualifier exits.  Otherwise false is returned.
201                */
202 karl  1.14     Boolean existsQualifier(const String& name)
203                {
204            	_checkRep();
205            	return _rep->existsQualifier(name);
206                }
207                ///
208                Boolean existsQualifier(const String& name) const
209                {
210            	_checkRep();
211            	return _rep->existsQualifier(name);
212                }
213            
214 karl  1.11     /**	getQualifier - Gets the CIMQualifier object defined
215 mike  1.3  	by the input parameter
216            	@param pos defines the position of the qualifier in the class from the
217            	findQualifier method
218            	@return CIMQualifier object representing the qualifier found.
219            	ATTN: what is error return here?
220 mike  1.1      */
221                CIMQualifier getQualifier(Uint32 pos)
222                {
223            	_checkRep();
224            	return _rep->getQualifier(pos);
225                }
226 mike  1.3  
227 karl  1.11     /// getQualifier - ATTN:
228 mike  1.1      CIMConstQualifier getQualifier(Uint32 pos) const
229                {
230            	_checkRep();
231            	return _rep->getQualifier(pos);
232                }
233 karl  1.16 
234 karl  1.14     /** removeQualifier - Removes the qualifier defined by the
235                index parameter.
236                @param Defines the index of the qualifier to be removed.
237                @return There is no return.
238                @exception Throw OutOfBound exception if the index is outside
239                the range of existing qualifier objects for this class
240                */
241                void removeQualifier(Uint32 pos) const
242                {
243            	_checkRep();
244            	_rep->removeQualifier(pos);
245                }
246 mike  1.3  
247 karl  1.11     /** getQualifierCount - Returns the number of qualifiers
248 karl  1.4  	in the class.
249 mike  1.3  	@return ATTN:
250 mike  1.1      */
251                Uint32 getQualifierCount() const
252                {
253            	_checkRep();
254            	return _rep->getQualifierCount();
255                }
256 mike  1.3  
257 karl  1.11     /**	addProperty - Adds the specified property object to the
258 mike  1.3  	properties in the CIM class
259 mike  1.1      */
260                CIMClass& addProperty(const CIMProperty& x)
261                {
262            	_checkRep();
263            	_rep->addProperty(x);
264            	return *this;
265                }
266 mike  1.3  
267 karl  1.16 
268 mike  1.3  
269 mike  1.1      /** CIMMethod findProperty - Finds the property object with the
270 mike  1.3  	name defined by the input parameter in the class.
271            	@param String parameter with the property name.
272 karl  1.16 	@return position representing the property object found or
273            	PEG_NOT_FOUND if the property is not found.
274 mike  1.1      */
275                Uint32 findProperty(const String& name)
276                {
277            	_checkRep();
278            	return _rep->findProperty(name);
279                }
280 mike  1.3  
281 mike  1.1      Uint32 findProperty(const String& name) const
282                {
283            	_checkRep();
284            	return _rep->findProperty(name);
285                }
286 mike  1.3  
287 karl  1.14     /** existsPropery - Determines if a property object with the
288            	name defined by the input parameter exists in the class.
289            	@parm String parameter with the property name.
290            	@return True if the property object exists.
291                */
292                Boolean existsProperty(const String& name)
293                {
294            	_checkRep();
295            	return _rep->existsProperty(name);
296                }
297                Boolean existsProperty(const String& name) const
298                {
299                   _checkRep();
300                   return _rep->existsProperty(name);
301                }
302            
303 karl  1.11     /** getProperty - Returns a property representing the property
304 mike  1.3  	defined by the input parameter
305            	@param position for this property
306            	ATTN: Should we not use something like handle for position???
307            	@return CIMProperty object
308            	ATTN: what is error return?
309 mike  1.1      */
310                CIMProperty getProperty(Uint32 pos)
311                {
312            	_checkRep();
313            	return _rep->getProperty(pos);
314                }
315 mike  1.3  
316 karl  1.11     /**getProperty Gets a property object from the CIMClass
317                	@param pos The index of the property object to get.
318                	@return Returns handle of the property object requested
319                	@exception Throws OutofBounds if the size field is greather than the
320                	bunber of properties in the class.
321                */
322 mike  1.8      CIMConstProperty getProperty(Uint32 pos) const
323 mike  1.1      {
324            	_checkRep();
325            	return _rep->getProperty(pos);
326                }
327 mike  1.3  
328 karl  1.14     /** removeProperty - Removes the property represented
329            	by the position input parameter from the class
330            	@param pos Index to the property to be removed from the
331            	findPropety method
332            	@exception Throws OutofBounds if index is not a property object
333                */
334                void removeProperty(Uint32 pos)
335                {
336            	_checkRep();
337            	_rep->removeProperty(pos);
338                }
339            
340                /** getPropertyCount -   Gets the count of the number of properties
341 mike  1.3  	defined in the class.
342            	@return count of number of proerties in the class
343 mike  1.1      */
344                Uint32 getPropertyCount() const
345                {
346            	_checkRep();
347            	return _rep->getPropertyCount();
348                }
349 mike  1.3  
350 karl  1.11     /** addMethod - Adds the method object defined by the input
351 karl  1.4  	parameter to the class and increments the count of the number of
352 mike  1.3  	methods in the class
353 karl  1.11 	@param method object representing the method to be added
354            	@return Returns the CIMClass object to which the method was added.
355            	@exception Throws AlreadyExists if the method already exists and throws
356            	UnitializedHandle if the handle is not initialized
357 mike  1.1      */
358                CIMClass& addMethod(const CIMMethod& x)
359                {
360            	_checkRep();
361            	_rep->addMethod(x);
362            	return *this;
363                }
364 mike  1.3  
365 karl  1.14     /** findMethod - Locate the method object defined by the
366 mike  1.3  	name input
367            	@param String representing the name of the method to be found
368 karl  1.4  	@return Position of the method object in the class to be used in
369 mike  1.3  	subsequent getmethod, etc. operations
370 mike  1.1      */
371                Uint32 findMethod(const String& name)
372                {
373            	_checkRep();
374            	return _rep->findMethod(name);
375                }
376 mike  1.3  
377 mike  1.1      Uint32 findMethod(const String& name) const
378                {
379            	_checkRep();
380            	return _rep->findMethod(name);
381                }
382 mike  1.3  
383 karl  1.14      /** existsMethod - Determine if the method object defined by the
384            	name input exists
385            	@param String representing the name of the method to be found
386            	@return True if the method exists
387                */
388                Boolean existsMethod(const String& name)
389                {
390            	_checkRep();
391            	return _rep->existsMethod(name);
392                }
393            
394                Boolean existsMethod(const String& name) const
395                {
396            	_checkRep();
397            	return _rep->existsMethod(name);
398                }
399            
400            
401 karl  1.11     /** getMethod - Gets the method object defined by the
402 mike  1.3  	input parameter.
403 karl  1.11 	@param pos Index to the CIMMethod object to get
404            	@return Returns handle of the CIMMethod requested
405            	@exception Throws OutofBounds if the index represented by pos is greater
406            	than the number of methods defined in the class object
407 mike  1.1      */
408                CIMMethod getMethod(Uint32 pos)
409                {
410            	_checkRep();
411            	return _rep->getMethod(pos);
412                }
413 mike  1.3  
414 karl  1.11     /** getMethod Gets the method object defined by the input
415                parameter. This is the const version.
416                */
417            
418 mike  1.1      CIMConstMethod getMethod(Uint32 pos) const
419                {
420            	_checkRep();
421            	return _rep->getMethod(pos);
422 karl  1.14     }
423            
424                /** removeMethod - Removes the method defined by the
425                index parameter.
426                @param Defines the index of the method to be removed.
427                @return There is no return.
428                @exception Throw OutOfBound exception if the index is outside
429                the range of existing method objects for this class
430                */
431                void removeMethod(Uint32 pos) const
432                {
433            	_checkRep();
434            	_rep->removeMethod(pos);
435 mike  1.1      }
436 mike  1.3  
437 mike  1.1      /** CIMMethod getMethodCount - Count of the number of methods in the class
438 karl  1.11 	@return integer representing the number of methods in the class object.
439 mike  1.1      */
440                Uint32 getMethodCount() const
441                {
442            	_checkRep();
443            	return _rep->getMethodCount();
444                }
445 karl  1.4  
446 karl  1.11     /** Resolve -  Resolve the class: inherit any properties and
447 karl  1.4  	qualifiers. Make sure the superClass really exists and is consistent
448 mike  1.3  	with this class. Also set the propagated flag class-origin for each
449            	class feature.
450            	ATTN: explain why this here
451 mike  1.1      */
452                void resolve(
453            	DeclContext* declContext,
454            	const String& nameSpace)
455                {
456            	_checkRep();
457            	_rep->resolve(declContext, nameSpace);
458                }
459 mike  1.3  
460 mike  1.1      /// operator - ATTN:
461                operator int() const { return _rep != 0; }
462 mike  1.3  
463 karl  1.4      /// CIMMethod toXML
464 mike  1.1      void toXml(Array<Sint8>& out) const
465                {
466            	_checkRep();
467            	_rep->toXml(out);
468                }
469 mike  1.3  
470 karl  1.11     /// CIMMethod print
471 mike  1.13     void print(PEGASUS_STD(ostream) &o=PEGASUS_STD(cout)) const
472 mike  1.1      {
473            	_checkRep();
474 bob   1.5  	_rep->print(o);
475 mike  1.1      }
476 mike  1.3  
477 mike  1.1      /** CIMMethod identical -  Compares with another class
478 mike  1.3  	ATTN: Clarify exactly what identical means
479 karl  1.11 	@param Class object for the class to be compared
480 mike  1.3  	@return True if the classes are identical
481 mike  1.1      */
482 mike  1.8      Boolean identical(const CIMConstClass& x) const;
483 mike  1.3  
484 mike  1.1      /// CIMMethod clone - ATTN:
485                CIMClass clone() const
486                {
487            	return CIMClass(_rep->clone());
488                }
489 karl  1.18     /** getKeyNames - ATTN
490                */
491 mike  1.3      void getKeyNames(Array<String>& keyNames) const
492                {
493            	_checkRep();
494            	_rep->getKeyNames(keyNames);
495                }
496            
497 mike  1.1  private:
498            
499                CIMClass(CIMClassRep* rep) : _rep(rep)
500                {
501                }
502            
503                void _checkRep() const
504                {
505            	if (!_rep)
506 mike  1.12 	    ThrowUnitializedHandle();
507 mike  1.1      }
508            
509                CIMClassRep* _rep;
510 mike  1.8      friend class CIMConstClass;
511 mike  1.1  };
512            
513 mike  1.17 #define PEGASUS_ARRAY_T CIMClass
514            # include "ArrayInter.h"
515            #undef PEGASUS_ARRAY_T
516            
517 mike  1.8  /** CIMConstClass - ATTN: define this.
518 mike  1.3  
519            */
520 mike  1.8  class PEGASUS_COMMON_LINKAGE CIMConstClass
521 mike  1.1  {
522            public:
523            
524 mike  1.8      CIMConstClass() : _rep(0)
525 mike  1.1      {
526            
527                }
528            
529 mike  1.8      CIMConstClass(const CIMConstClass& x)
530 mike  1.1      {
531            	Inc(_rep = x._rep);
532                }
533            
534 mike  1.8      CIMConstClass(const CIMClass& x)
535 mike  1.1      {
536            	Inc(_rep = x._rep);
537                }
538            
539 mike  1.8      CIMConstClass& operator=(const CIMConstClass& x)
540 mike  1.1      {
541            	if (x._rep != _rep)
542            	{
543            	    Dec(_rep);
544            	    Inc(_rep = x._rep);
545            	}
546            	return *this;
547                }
548            
549 mike  1.8      CIMConstClass& operator=(const CIMClass& x)
550 mike  1.1      {
551            	if (x._rep != _rep)
552            	{
553            	    Dec(_rep);
554            	    Inc(_rep = x._rep);
555            	}
556            	return *this;
557                }
558            
559                // Throws IllegalName if className argument not legal CIM identifier.
560            
561 mike  1.8      CIMConstClass(
562 karl  1.4  	const String& className,
563 mike  1.1  	const String& superClassName = String())
564                {
565            	_rep = new CIMClassRep(className, superClassName);
566                }
567            
568 mike  1.8      ~CIMConstClass()
569 mike  1.1      {
570            	Dec(_rep);
571                }
572            
573                Boolean isAssociation() const
574                {
575            	_checkRep();
576            	return _rep->isAssociation();
577                }
578            
579                Boolean isAbstract() const
580                {
581            	_checkRep();
582            	return _rep->isAbstract();
583                }
584            
585 karl  1.4      const String& getClassName() const
586                {
587 mike  1.1  	_checkRep();
588 karl  1.4  	return _rep->getClassName();
589 mike  1.1      }
590            
591 karl  1.4      const String& getSuperClassName() const
592                {
593 mike  1.1  	_checkRep();
594 karl  1.4  	return _rep->getSuperClassName();
595 mike  1.1      }
596            
597                Uint32 findQualifier(const String& name) const
598                {
599            	_checkRep();
600            	return _rep->findQualifier(name);
601                }
602            
603                CIMConstQualifier getQualifier(Uint32 pos) const
604                {
605            	_checkRep();
606            	return _rep->getQualifier(pos);
607                }
608            
609                Uint32 getQualifierCount() const
610                {
611            	_checkRep();
612            	return _rep->getQualifierCount();
613                }
614            
615                Uint32 findProperty(const String& name) const
616 mike  1.1      {
617            	_checkRep();
618            	return _rep->findProperty(name);
619                }
620            
621 mike  1.8      CIMConstProperty getProperty(Uint32 pos) const
622 mike  1.1      {
623            	_checkRep();
624            	return _rep->getProperty(pos);
625                }
626            
627                Uint32 getPropertyCount() const
628                {
629            	_checkRep();
630            	return _rep->getPropertyCount();
631                }
632            
633                Uint32 findMethod(const String& name) const
634                {
635            	_checkRep();
636            	return _rep->findMethod(name);
637                }
638            
639                CIMConstMethod getMethod(Uint32 pos) const
640                {
641            	_checkRep();
642            	return _rep->getMethod(pos);
643 mike  1.1      }
644            
645                Uint32 getMethodCount() const
646                {
647            	_checkRep();
648            	return _rep->getMethodCount();
649                }
650            
651                operator int() const { return _rep != 0; }
652            
653                void toXml(Array<Sint8>& out) const
654                {
655            	_checkRep();
656            	_rep->toXml(out);
657                }
658            
659 mike  1.13     void print(PEGASUS_STD(ostream) &o=PEGASUS_STD(cout)) const
660 mike  1.1      {
661            	_checkRep();
662 bob   1.5  	_rep->print(o);
663 mike  1.1      }
664            
665 mike  1.8      Boolean identical(const CIMConstClass& x) const
666 mike  1.1      {
667            	x._checkRep();
668            	_checkRep();
669            	return _rep->identical(x._rep);
670                }
671            
672                CIMClass clone() const
673                {
674            	return CIMClass(_rep->clone());
675 mike  1.3      }
676            
677                void getKeyNames(Array<String>& keyNames) const
678                {
679            	_checkRep();
680            	_rep->getKeyNames(keyNames);
681 mike  1.1      }
682            
683            private:
684            
685                void _checkRep() const
686                {
687            	if (!_rep)
688 mike  1.12 	    ThrowUnitializedHandle();
689 mike  1.1      }
690            
691                CIMClassRep* _rep;
692            
693                friend class CIMClassRep;
694                friend class CIMClass;
695                friend class CIMInstanceRep;
696            };
697            
698            PEGASUS_NAMESPACE_END
699            
700 mike  1.9  #endif /* Pegasus_CIMClass_h */

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2