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

/magnus/back_end/Enumerators/include/SMListIterator.h

Go to the documentation of this file.
00001 /*
00002  *   $Id: 
00003  */
00004 
00005 // Copyright (C) 1997 The New York Group Theory Cooperative
00006 // See magnus/doc/COPYRIGHT for the full notice.
00007 
00008 // Contents: 
00009 //
00010 // Principal Author: Alexei Myasnikov
00011 //
00012 // Status: in progress
00013 //
00014 // Revision History:
00015 //
00016 
00017 #ifndef _SMLIST_ITERATOR_H_
00018 #define _SMLIST_ITERATOR_H_
00019 
00020 #include "SMList.h"
00021 #include "Word.h"
00022 #include "SMEnumerator.h"
00023 
00024 //-------------------------- SMListIterator -----------------------------//
00025 
00026 template <class T> class SMListIterator {
00027 public:
00028   SMListIterator(const SMList<T>& );
00029   
00030   ~SMListIterator() { 
00031     theData.closeCurrentMode();
00032     if ( currentData )
00033       delete currentData;
00034   }
00035   
00036   // Iteration procedures
00037        
00038   bool EOL() const { return eol_reached; }
00039   
00040   void reset(); 
00041 
00042   bool nextCell();
00043   
00044   const T& getData(); 
00045 
00046   int getNumberOfElements()const { return theData.numberOfElements(); }
00047 
00048 private:
00049 
00050   void deleteCurrentData();
00051 
00052   void parseData();
00053   // Parser of an element from the list.
00054   // Unique for each type T.
00055                             
00056   Chars currentLine;
00057 
00058   T* currentData;
00059   // value of the current element from the list
00060   FPGroup theGroup;
00061   // group
00062 
00063   int numberOfCurrent;
00064   // number of the last parsed element( which is the currentData)
00065    
00066   SMListData theData;
00067 
00068   bool eol_reached;
00069 };
00070 
00071 
00072 // Classes below define standards for element presentation in
00073 // enumerators and lists.  
00074  
00075 
00076 // ---------------- WriteEnumeratorElement --------------------- //
00077 
00078 class WriteEnumeratorElement
00079 {
00080  public:
00081   WriteEnumeratorElement() {}
00082   virtual void print(ostream& ostr) const = 0;
00083   inline friend ostream& operator << ( ostream& o, 
00084                                        const WriteEnumeratorElement& we ) {
00085 //    o << we.position << ":" << "$D" << " " ;
00086     we.print( o );
00087     return o;
00088   }
00089  protected:
00090 
00091  private:
00092   WriteEnumeratorElement(const WriteEnumeratorElement&);
00093 };
00094 
00095 // ------------------------ EnumWriteWord --------------------- //
00096 
00097 class EnumWriteWord : public WriteEnumeratorElement
00098 {
00099  public:
00100   EnumWriteWord( const Word& w, const FPGroup& g) 
00101     :  theW( w ), theG( g ) { }
00102   
00103   void print( ostream& o ) const;
00104  private:
00105   Word theW;
00106   FPGroup theG;
00107 
00108 };
00109 
00110 // ------------------------ EnumWriteMap --------------------- //
00111 
00112 class EnumWriteMap : public WriteEnumeratorElement
00113 {
00114  public:
00115   EnumWriteMap( const Map& m ) 
00116     : theM( m ) { }
00117   
00118   void print( ostream& o ) const;
00119  private:
00120   Map theM;
00121 };
00122 // ------------------------ EnumWriteVectorOfWords --------------------- //
00123 
00124 class EnumWriteVectorOfWords : public WriteEnumeratorElement
00125 {
00126  public:
00127   EnumWriteVectorOfWords( const VectorOf<Word>& v, const FPGroup& g ) 
00128     : theV( v ),
00129     theG( g )
00130     { }
00131   
00132   void print( ostream& o ) const;
00133  private:
00134   VectorOf<Word> theV;
00135   FPGroup theG;
00136 };
00137         
00138 // ------------------------ EnumWriteSetOfWords --------------------- //
00139 
00140 class EnumWriteSetOfWords : public WriteEnumeratorElement
00141 {
00142  public:
00143   EnumWriteSetOfWords( const SetOf<Word>& s, const FPGroup& g ) 
00144     : theS( s ),
00145     theG( g )
00146     { }
00147   
00148   void print( ostream& o ) const;
00149  private:
00150   SetOf<Word> theS;
00151   FPGroup theG;
00152 };
00153 
00154 // ------------------------ EnumWriteChars  --------------------- //
00155 
00156 class EnumWriteChars : public WriteEnumeratorElement
00157 {
00158  public:
00159   EnumWriteChars( const Chars& c ) 
00160     : theC( c )
00161     { }
00162   
00163   void print( ostream& o ) const;
00164  private:
00165   Chars theC;
00166 };
00167 
00168 #endif

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