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

/magnus/back_end/Elt/include/EltRep.h

Go to the documentation of this file.
00001 /*
00002  *   $Id: EltRep.h,v 1.3 1996/04/30 21:08:29 bormotov Exp $
00003  */
00004 
00005 // Copyright (C) 1994 The New York Group Theory Cooperative
00006 // See magnus/doc/COPYRIGHT for the full notice.
00007 
00008 // Contents: Definition of the EltRep class.
00009 //
00010 // Principal Author: Stephane Collart
00011 //
00012 // Status: Useable.
00013 //
00014 // Revision History:
00015 //
00016 
00017 #ifndef _ELT_REP_H_
00018 #define _ELT_REP_H_
00019 
00020 #include "GenericObject.h"
00021 #include "Type.h"
00022 
00023 
00024 //---------------------------- EltRep -------------------------------//
00025 
00026 
00027 struct EltRep : GenericRep {
00028 
00029 // constructors:
00030 
00031   // no default constructor
00032 
00033   // copy constructor supplied by compiler
00034 
00035   virtual ~EltRep( ) { };
00036   // destructor must be virtual at root of hierarchy with virtual
00037   // functions
00038   
00039 // representation and type stuff:
00040 
00041   static const Type theEltType;
00042 
00043   static Type type( ) { return theEltType; }
00044 
00045   virtual Type actualType( ) const { return theEltType; }
00046 
00047   // @stc there is a type datum and actualType() is not pure virtual
00048   // to have a type associated with this pseudo-abstract class too
00049 
00050   PureRep* clone( ) const = 0;
00051 
00052 // delegated methods and operators:
00053 
00054   virtual Bool operator == ( const EltRep& ) const = 0;
00055 
00056   virtual int hash( ) const = 0;
00057   
00058   virtual EltRep* operator * ( const EltRep& ) const = 0;
00059 
00060   virtual EltRep* inverse( ) const = 0;
00061 
00062   virtual EltRep* conjugateBy( const EltRep* ep ) const {
00063          EltRep* tmp1 = ep->inverse();
00064          EltRep* tmp2 = *tmp1 * *this;
00065          EltRep* result = *tmp2 * *ep;
00066          delete tmp1;
00067          delete tmp2;
00068          return result;
00069   }
00070 
00071   virtual EltRep* commutatorWith( const EltRep* ep ) const {
00072          EltRep* tmp1 = ep->conjugateBy( this );
00073          EltRep* result = *tmp1 * *ep;
00074          delete tmp1;
00075          return result;
00076   }
00077   
00078 // I/O:
00079 
00080   virtual void printOn(ostream&) const;
00081 
00082   virtual void debugPrint(ostream&) const;
00083 
00084 
00085   /////////////////////////////////////////////////////////////////////////
00086   //                                                                     //
00087   // IPC tools:                                                          //
00088   //                                                                     //
00089   /////////////////////////////////////////////////////////////////////////
00090 
00091   virtual void write( ostream& ostr ) const { };
00092 
00093   virtual void  read( istream& istr ) { };
00094 
00095 
00096 private:
00097 
00098   EltRep& operator = ( const EltRep& ); // disable assignment
00099     
00100 };
00101 
00102 
00103 //------------------------ EltIdentityRep ---------------------------//
00104 
00105 
00106 struct EltIdentityRep : EltRep {
00107 
00108 // constructors:
00109 
00110   // default constructor provided by compiler
00111 
00112   // copy constructor supplied by compiler
00113 
00114   // destructor supplied by compiler; virtual by inheritence
00115 
00116 // representation and type stuff:
00117 
00118   PureRep* clone( ) const { return new EltIdentityRep(*this); }
00119   // overrides EltRep::clone()
00120   
00121   static const Type theEltIdentityType;
00122   static Type type( ) { return theEltIdentityType; }
00123   Type actualType( ) const { return theEltIdentityType; }
00124   // overrides EltRep::actualType();
00125 
00126   virtual Bool operator == ( const EltRep& ) const { return false; }
00127   // @stc quick hack pending a comprehensive solution
00128   // 1) to the problem of where op == is resolved (see Elt.h)
00129   // 2) to the semantics required of EltIdentityRep (see Elt.h)
00130 
00131   virtual int hash( ) const { return 0; }
00132   
00133   virtual EltRep* operator * ( const EltRep& e ) const
00134         { e.addRef(); return (EltRep*)&e; }
00135   // @stc quick hack;
00136   // 1) it may be undesirable to pass representations around
00137   // through direct manipulation of the reference count; this would
00138   // preferably done through suitably arranged automatic set-ups in
00139   // the object/representation interplay
00140   // 2) this does nothing for the case when the second argument is an
00141   // EltIdentityRep and not the first
00142 
00143   virtual EltRep* inverse( ) const 
00144         { addRef(); return (EltRep*)this; }
00145   // @stc same comments as above
00146 
00147 };
00148 
00149 
00150 #endif

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