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

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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2