Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

/magnus/back_end/global/GenericObject.h

Go to the documentation of this file.
00001 /*
00002  *   $Id: GenericObject.h,v 1.1.1.1 1995/11/20 17:54:40 rogern Exp $
00003  */
00004 
00005 // Copyright (C) 1995 The New York Group Theory Cooperative
00006 // See magnus/doc/COPYRIGHT for the full notice.
00007 
00008 // Contents: Definition of classes GenericRep, GenericObject
00009 //
00010 // Description:
00011 //
00012 // * a common root class for all object-level (see PureObject.h) classes
00013 //   with a coherent type scheme.
00014 //
00015 // Principal Author: Stephane Collart
00016 //
00017 // Status: Under development
00018 //
00019 // Usage:
00020 //
00021 // * See PureObject
00022 //
00023 // * In addition, this class provides explicit type query handles; classes
00024 //   derived from this class will normally derive *publicly*, to permit
00025 //   assignment by non-friend
00026 //
00027 // Bugs:
00028 //
00029 // Revision History:
00030 //
00031 
00032 
00033 
00034 #ifndef _GENERIC_OBJECT_H_
00035 #define _GENERIC_OBJECT_H_
00036 
00037 
00038 
00039 #include "PureRep.h"
00040 #include "BaseObjectOf.h"
00041 #include "Type.h"
00042 
00043 
00044 
00045 /*! A common root class for all object-level (see PureObject.h) classes
00046   with a coherent type scheme. */
00047 struct GenericRep : public PureRep
00048 {
00049 
00050         //////////////////////////////////////////////////////////////////////
00051         //                                                                  //
00052         // Constructors:                                                    //
00053         //                                                                  //
00054         //////////////////////////////////////////////////////////////////////
00055 
00056         // default constructor provided by compiler
00057 
00058         // copy constructor provided by compiler
00059 
00060         //////////////////////////////////////////////////////////////////////
00061         //                                                                  //
00062         // Standard Operators:                                              //
00063         //                                                                  //
00064         //////////////////////////////////////////////////////////////////////
00065 
00066         // assignment operator disabled
00067 
00068         //////////////////////////////////////////////////////////////////////
00069         //                                                                  //
00070         // Type Stuff and Access:                                           //
00071         //                                                                  //
00072         //////////////////////////////////////////////////////////////////////
00073 
00074         static const Type theGenericObjectType;
00075          /*!< Unique object type.
00076            
00077          Every representation class derived from this should carry a similarly
00078          defined type field
00079          */
00080 
00081         static Type type() { return theGenericObjectType; }
00082          /*!< Returns unique object type.
00083 
00084          Every representation class derived from this should carry a similarly
00085          defined type member */
00086 
00087         virtual Type actualType() const { return type(); }
00088          /*!< Returns objects type.
00089 
00090          This member serves as the root of all type querying members in this
00091          type scheme
00092          every representation class derived from this should override this
00093          member similarly to return the actual type of the class */
00094 
00095         //////////////////////////////////////////////////////////////////////
00096         //                                                                  //
00097         // Representation Stuff:                                            //
00098         //                                                                  //
00099         //////////////////////////////////////////////////////////////////////
00100 
00101         PureRep* clone( ) const { return new GenericRep(*this); }
00102         /*!< Returns a pointer to a copy of the GenericRep object. */
00103 };
00104 
00105 
00106 
00107 class GenericObject : protected BaseObjectOf<GenericRep>
00108 {
00109 public:
00110 
00111         //////////////////////////////////////////////////////////////////////
00112         //                                                                  //
00113         // Constructors:                                                    //
00114         //                                                                  //
00115         //////////////////////////////////////////////////////////////////////
00116 
00117         GenericObject( ) : BaseObjectOf<GenericRep>( new GenericRep ) { }
00118   //!< Default constructor.
00119         // copy constructor provided by compiler
00120         // destructor provided by compiler
00121         // both of the preceding ref-counting compatible
00122 
00123         // assignment operator provided by compiler
00124         // ref-counting compatible
00125 
00126         //////////////////////////////////////////////////////////////////////
00127         //                                                                  //
00128         // Type Access:                                                     //
00129         //                                                                  //
00130         //////////////////////////////////////////////////////////////////////
00131 
00132         static Type type() { return GenericRep::type(); }
00133         /*!<  Returns unique type of the object.
00134 
00135         This `type querying' member is provided solely as an example, since
00136          this class is pseudo-abstract (ie. its representation class is abstract)
00137          and no actual objects of this type will ever be created */
00138 
00139         Type actualType() const { return look()->actualType(); }
00140   /*!<  Returns  type of the object. */
00141 
00142 protected:
00143 
00144         //////////////////////////////////////////////////////////////////////
00145         //                                                                  //
00146         // Representation Access:                                           //
00147         //                                                                  //
00148         //////////////////////////////////////////////////////////////////////
00149 
00150         // look(), change() and enhance() inherited
00151 
00152         //////////////////////////////////////////////////////////////////////
00153         //                                                                  //
00154         // Special Constructors:                                            //
00155         //                                                                  //
00156         //////////////////////////////////////////////////////////////////////
00157 
00158         /*! Special wrapping constructor to wrap new representations (returned
00159          by eg. delegated methods) and for base initialisation by derived
00160          classes. */
00161         GenericObject( GenericRep* newrep ) : BaseObjectOf<GenericRep>(newrep) { }
00162 
00163 };
00164 
00165 #endif

Generated at Tue Jun 19 09:49:36 2001 for Magnus Classes by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001