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

/magnus/back_end/SessionManager/include/Menu.h

Go to the documentation of this file.
00001 /*
00002  *   $Id: Menu.h,v 1.20 2000/09/26 20:30:09 bormotov 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: Declarations of helper classes for specifying menus
00009 //
00010 // Principal Author: Roger Needham
00011 //
00012 // Status: in progress
00013 //
00014 // Revision History:
00015 //
00016 // * 10/11/96 EP added stuff for SMVectorOfWords
00017 //
00018 //  96/10/09 @dp added struct ReadFreeGetNextN_thElementItem.
00019 //  96/10/10 @dp added struct ReadTerminalSegmentItem, ReadSegmentOfWordItem.
00020 //  96/10/10 @dp added struct DefineInt2, BoundedInteger.
00021 //
00022 
00023 
00024 #ifndef _MENU_H_
00025 #define _MENU_H_
00026 
00027 
00028 #include "FEData.h"
00029 #include "SMObject.h"
00030 
00031 //@rn These includes are required by the gcc 2.6.3 bug workaround,
00032 //@rn discussed below:
00033 
00034 #include "SMFPGroup.h"
00035 #include "SMWord.h"
00036 #include "SMEquation.h"
00037 #include "SMSubgroup.h"
00038 #include "SMSetOfWords.h"
00039 #include "SMVectorOfWords.h"
00040 #include "SMMap.h"
00041 #include "SMMagnusBreakdown.h"
00042 #include "SMPermutation.h"
00043 #include "fastProblems.h"
00044 #include "HomologyProblem.h"
00045 #include "FreeProblems.h"
00046 #include "IsNilpotentProblem.h"
00047 #include "SubgroupProblems.h"
00048 #include "OneRelatorProblems.h"
00049 #include "PackagesSMApps.h"
00050 #include "SMEqSystem.h"
00051 
00052 //#include "HNNProblems.h"
00053 
00054 //---------------------------------------------------------------------------//
00055 //------------------------------ Ctor<n> ------------------------------------//
00056 //---------------------------------------------------------------------------//
00057 
00058 // A programmer may specify an end user menu item by supplying a
00059 // `constructor wrapper', i.e., an appropriate derivative of class Ctor.
00060 // These arrange, in cooperation with class ObjectSmith, for a callback
00061 // when the menu item is selected. The callback reads the arguments of
00062 // the item, and creates the required derivative of SMObject. The
00063 // constructor wrapper does strong compile-time type checking of the
00064 // arguments against the SMObject to be created.
00065 
00066 // Templates cannot be class members (think about it), so these have
00067 // to hang out in the global namespace.
00068 
00069 struct Ctor
00070 {
00071   virtual void readFrom(istream& istr) const = 0;
00072   // This does all input, and construction and storage of objects.
00073 
00074   virtual Ctor* copy( ) const = 0;
00075   // Used for storing an object in a derived class as a Ctor*.
00076   // This is necessary in order to keep the right virtual table.
00077 
00078 protected:
00079 
00080   // With these here, only Ctor need be a friend of TheObjects,
00081   // SMObject, resp.:
00082 
00083   SMObject* get(int oid) const;
00084   // Returns the value of TheObjects::get( oid ).
00085 
00086   void newDependent(SMObject* smo, OID oid) const;
00087   // Tells smo that oid depends on it.
00088 };
00089 
00090 
00091 // The classes CtorAux<n> are not strictly necessary; they factor
00092 // common code out of the Ctor<n> templates, to mitigate the effects of
00093 // combinatorial explosion.
00094 // The `readFrom' member knows how many oid's to read. It gets the
00095 // corresponding SMObject*'s from TheObjects, and passes them to
00096 // `construct' for the actual construction and storage of the new object.
00097 // In special cases, e.g., when a parse error is possible, `construct' may
00098 // return 0.
00099 
00100 
00101 struct CtorAux0 : public Ctor
00102 {
00103   void readFrom(istream& istr) const;            // overrides Ctor
00104 
00105   virtual SMObject* construct(Chars&, istream&) const = 0;
00106 };
00107 
00108 
00109 struct CtorAux1 : public Ctor
00110 {
00111   void readFrom(istream& istr) const;            // overrides Ctor
00112 
00113   virtual SMObject* construct(SMObject*, Chars&, istream&) const = 0;
00114 };
00115 
00116 
00117 struct CtorAux2 : public Ctor
00118 {
00119   CtorAux2(bool transpose = false) : transposeARGS( transpose ) { }
00120 
00121   void readFrom(istream& istr) const;            // overrides Ctor
00122 
00123   virtual SMObject* construct(SMObject*, SMObject*, Chars&, istream&) const = 0;
00124 
00125   bool transposeARGS;
00126   // Marks whether to reverse the order of the arguments.
00127 };
00128 
00129 
00130 struct CtorAux3 : public Ctor
00131 {
00132   void readFrom(istream& istr) const;            // overrides Ctor
00133 
00134   virtual SMObject* construct(SMObject*, SMObject*, SMObject*, 
00135                               Chars&, istream&) const = 0;
00136 };
00137 
00138 
00139 struct CtorAux4 : public Ctor
00140 {
00141   void readFrom(istream& istr) const;            // overrides Ctor
00142 
00143   virtual SMObject* construct(SMObject*, SMObject*, SMObject*, SMObject*, 
00144                               Chars&, istream&) const = 0;
00145 };
00146 
00147 
00148 // The following are the Ctor's to be passed as arguments to the Menu
00149 // objects. Their purpose is to do the casting from mere SMObject*'s to
00150 // objects of precisely the right type, and to call the right
00151 // constructor.
00152 // Each derives from an intermediate CtorArgs<n>, so that the classes
00153 // Menu<n> below can check the types of the arguments.
00154 
00155 struct CtorArgs0 : public CtorAux0 { };
00156 
00157 template <class T>
00158 struct Ctor0 : public CtorArgs0
00159 {
00160   Ctor* copy( ) const { return new Ctor0; }          // overrides Ctor
00161 
00162 private:
00163 
00164   SMObject* construct(Chars&, istream&) const {      // overrides CtorAux1
00165          return new T( );
00166   }
00167   // The istream& is used only by specializations of this function.
00168 };
00169 
00170 
00171 template <class A1> struct CtorArgs1 : public CtorAux1 { };
00172 
00173 template <class T, class A1>
00174 struct Ctor1 : public CtorArgs1<A1>
00175 {
00176   Ctor* copy( ) const { return new Ctor1; }          // overrides Ctor
00177 
00178 private:
00179 
00180   SMObject* construct(SMObject* a1, Chars&, istream&) const {
00181          return new T( *((A1*)a1) );
00182   }
00183   // overrides CtorAux1
00184   // The istream& is used only by specializations of this function.
00185 };
00186 
00187 
00188 template <class A1, class A2> struct CtorArgs2 : public CtorAux2
00189 {
00190   CtorArgs2(bool transpose = false) : CtorAux2( transpose ) { }
00191 };
00192 
00193 template <class T, class A1, class A2>
00194 struct Ctor2 : public CtorArgs2<A1,A2>
00195 {
00196   Ctor2(bool transpose = false) : CtorArgs2<A1,A2>( transpose ) { }
00197 
00198   Ctor* copy( ) const { return new Ctor2( transposeARGS ); } // overrides Ctor
00199 
00200 private:
00201 
00202   SMObject* construct(SMObject* a1, SMObject* a2, Chars&, istream&) const {
00203          return new T( *((A1*)a1), *((A2*)a2) );
00204   }
00205   // overrides CtorAux2
00206   // The istream& is used only by specializations of this function.
00207 };
00208 
00209 
00210 template <class A1, class A2, class A3> struct CtorArgs3 : public CtorAux3 { };
00211 
00212 template <class T, class A1, class A2, class A3>
00213 struct Ctor3 : public CtorArgs3<A1,A2,A3>
00214 {
00215   Ctor* copy( ) const { return new Ctor3; } // overrides Ctor
00216 
00217 private:
00218 
00219   SMObject* construct(SMObject* a1, SMObject* a2, SMObject* a3, 
00220                       Chars&, istream&) const 
00221   {
00222     return new T( *((A1*)a1), *((A2*)a2), *((A3*)a3) );
00223   }
00224   // overrides CtorAux3
00225   // The istream& is used only by specializations of this function.
00226 };
00227 
00228 
00229 template <class A1, class A2, class A3, class A4> struct CtorArgs4 :
00230   public CtorAux4 { };
00231 
00232 template <class T, class A1, class A2, class A3, class A4>
00233 struct Ctor4 : public CtorArgs4<A1,A2,A3,A4>
00234 {
00235   Ctor* copy( ) const { return new Ctor4; } // overrides Ctor
00236 
00237 private:
00238 
00239   SMObject* construct(SMObject* a1, SMObject* a2, SMObject* a3, SMObject* a4, 
00240                       Chars&, istream&) const 
00241   {
00242     return new T( *((A1*)a1), *((A2*)a2), *((A3*)a3), *((A4*)a4) );
00243   }
00244   // overrides CtorAux4
00245   // The istream& is used only by specializations of this function.
00246 };
00247 
00248 // At this point we would appear to have a satisfactory situation. The
00249 // most common case, where a T has a constructor which takes arguments of
00250 // types A1, A2, ... is handled automatically. Special cases are easily
00251 // handled by specializing the member `Ctor<n>::construct' to use the
00252 // istream&. In fact, the work of reading the `standard case' arguments
00253 // is already done by CtorAux<n> even in special cases.
00254 // 
00255 // But no.
00256 // 
00257 // A sporadic gcc 2.6.3 bug sometimes prevents specializing a member
00258 // function of a template class. In the perhaps overly naive hope that
00259 // gcc will someday do templates (almost) right, we hack a workaround
00260 // which mimics as closely as possible what we really want to do:
00261 // 
00262 // For each and every special case, derive a subclass of the needed
00263 // instance of Ctor<n>. Override `construct', with the function body
00264 // being exactly what the specialization's would have been.
00265 // 
00266 // An unfortunate consequence is that Ctor<n> will still try to
00267 // instantiate the default version of `construct'. It cannot, because T
00268 // does not have the right constructor. Indeed, the resulting compiler
00269 // error is what this whole scheme is *designed* to cause! So, we hack
00270 // further by putting dummy ctors in the classes T. Now I have to puke.
00271 
00272 
00273 //---------------------------------------------------------------------------//
00274 //------------------------------- Ctor --------------------------------------//
00275 //--------------------------- special cases ---------------------------------//
00276 
00277 
00278 struct ReadSMFPGroup : public Ctor0<SMFPGroup>
00279 {
00280   Ctor* copy( ) const { return new ReadSMFPGroup; }          // overrides Ctor1
00281   SMObject* construct(Chars&, istream&) const;               // overrides Ctor1
00282 };
00283 
00284 
00285 struct ReadSMFreeGroup : public Ctor0<SMFPGroup>
00286 {
00287   Ctor* copy( ) const { return new ReadSMFreeGroup; }        // overrides Ctor1
00288   SMObject* construct(Chars&, istream&) const;               // overrides Ctor1
00289 };
00290 
00291 
00292 struct ReadSMAbelianGroup : public Ctor0<SMFPGroup>
00293 {
00294   Ctor* copy( ) const { return new ReadSMAbelianGroup; }     // overrides Ctor1
00295   SMObject* construct(Chars&, istream&) const;               // overrides Ctor1
00296 };
00297 
00298 
00299 struct ReadSMNilpotentGroup : public Ctor0<SMFPGroup>
00300 {
00301   Ctor* copy( ) const { return new ReadSMNilpotentGroup; }   // overrides Ctor1
00302   SMObject* construct(Chars&, istream&) const;               // overrides Ctor1
00303 };
00304 
00305 struct ReadSMFreeNilpotentGroup : public Ctor0<SMFPGroup>
00306 {
00307   Ctor* copy( ) const { return new ReadSMFreeNilpotentGroup; }   // overrides Ctor1
00308   SMObject* construct(Chars&, istream&) const;               // overrides Ctor1
00309 };
00310 
00311 struct ReadSMORGroup : public Ctor0<SMFPGroup>
00312 {
00313   Ctor* copy( ) const { return new ReadSMORGroup; }          // overrides Ctor1
00314   SMObject* construct(Chars&, istream&) const;               // overrides Ctor1
00315 };
00316 
00317 struct ReadSMSmallCancGroup : public Ctor0<SMFPGroup>
00318 {
00319   Ctor* copy( ) const { return new ReadSMSmallCancGroup; }   // overrides Ctor1
00320   SMObject* construct(Chars&, istream&) const;               // overrides Ctor1
00321 };
00322 
00323 struct ReadSMPermutation : public Ctor0<SMPermutation>
00324 {
00325   Ctor* copy( ) const { return new ReadSMPermutation; }      // overrides Ctor1
00326   SMObject* construct(Chars&, istream&) const;               // overrides Ctor1
00327 };
00328 
00329 struct ReadSMWord : public Ctor1<SMWord,SMFPGroup>, protected FEData
00330 {
00331   Ctor* copy( ) const { return new ReadSMWord; }             // overrides Ctor1
00332   SMObject* construct(SMObject* a1, Chars&, istream&) const; // overrides Ctor1
00333 };
00334 
00335 
00336 struct ReadSMEquation : public Ctor1<SMEquation,SMFPGroup>, protected FEData
00337 {
00338   Ctor* copy( ) const { return new ReadSMEquation; }         // overrides Ctor1
00339   SMObject* construct(SMObject* a1, Chars&, istream&) const; // overrides Ctor1
00340 };
00341 
00342 struct ReadSMEquation2 : public Ctor1<SMEquation2,SMFPGroup>, protected FEData
00343 {
00344   Ctor* copy( ) const { return new ReadSMEquation2; }         // overrides Ctor1
00345   SMObject* construct(SMObject* a1, Chars&, istream&) const; // overrides Ctor1
00346 };
00347 
00348 struct ReadSMEqSystem : public Ctor1<SMEqSystem,SMFPGroup>, protected FEData
00349 {
00350   Ctor* copy( ) const { return new ReadSMEqSystem; }         // overrides Ctor1
00351   SMObject* construct(SMObject* a1, Chars&, istream&) const; // overrides Ctor1
00352 };
00353 
00354 struct ReadSMSubgroup : public Ctor1<SMSubgroup,SMFPGroup>, protected FEData
00355 {
00356   Ctor* copy( ) const { return new ReadSMSubgroup; }         // overrides Ctor1
00357   SMObject* construct(SMObject* a1, Chars&, istream&) const; // overrides Ctor1
00358 };
00359 
00360 
00361 struct ReadSMSetOfWords : public Ctor1<SMSetOfWords,SMFPGroup>, 
00362                           protected FEData
00363 {
00364   Ctor* copy( ) const { return new ReadSMSetOfWords; }       // overrides Ctor1
00365   SMObject* construct(SMObject* a1, Chars&, istream&) const; // overrides Ctor1
00366 };
00367 
00368 struct ReadSMVectorOfWords : public Ctor1<SMVectorOfWords,SMFPGroup>, 
00369                           protected FEData
00370 {
00371   Ctor* copy( ) const { return new ReadSMVectorOfWords; }       // overrides Ctor1
00372   SMObject* construct(SMObject* a1, Chars&, istream&) const; // overrides Ctor1
00373 };
00374 
00375 
00376 struct ReadSMMap : public Ctor1<SMMap,SMFPGroup>, protected FEData
00377 {
00378   Ctor* copy( ) const { return new ReadSMMap; }              // overrides Ctor1
00379   SMObject* construct(SMObject* a1, Chars&, istream&) const; // overrides Ctor1
00380 };
00381 
00382 
00383 struct ReadSMMap2 : public Ctor2<SMMap,SMFPGroup,SMFPGroup>, protected FEData
00384 {
00385   ReadSMMap2(bool transpose = false)
00386     : Ctor2<SMMap,SMFPGroup,SMFPGroup>( transpose )
00387   { }
00388   Ctor* copy( ) const { return new ReadSMMap2( transposeARGS ); }
00389   // overrides Ctor1
00390   SMObject* construct(SMObject* a1, SMObject* a2, Chars&, istream&) const;
00391   // overrides Ctor1
00392 };
00393 
00394 
00395 struct ReadSymmetricGroup : public Ctor0<SMFPGroup>, protected FEData
00396 {
00397   ReadSymmetricGroup() : Ctor0<SMFPGroup>( ) { }
00398   Ctor* copy( ) const { return new ReadSymmetricGroup(); }
00399   // overrides Ctor0
00400   SMObject* construct(Chars&, istream&) const;
00401   // overrides Ctor0
00402 };
00403 
00404 struct ReadSMMagnusBreakdown : public Ctor1<SMMagnusBreakdown,SMFPGroup>, protected FEData
00405 {
00406   Ctor* copy( ) const { return new ReadSMMagnusBreakdown; } // overrides Ctor1
00407   SMObject* construct(SMObject* a1, Chars&, istream&) const;
00408   // overrides Ctor1
00409 };
00410 
00411 
00412 // The following special case those menu items which require an
00413 // additional int parameter.
00414 
00415 
00416 struct ReadPowerOfMapItem : public Ctor1<PowerOfMap,SMMap>, protected FEData
00417 {
00418   Ctor* copy( ) const { return new ReadPowerOfMapItem; }     // overrides Ctor1
00419   SMObject* construct(SMObject* a1, Chars&, istream&) const; // overrides Ctor1
00420 };
00421 
00422 
00423 struct ReadHomologyItem : public Ctor1<HomologyProblem,SMFPGroup>, protected FEData
00424 {
00425   Ctor* copy( ) const { return new ReadHomologyItem; }       // overrides Ctor1
00426   SMObject* construct(SMObject* a1, Chars&, istream&) const; // overrides Ctor1
00427 };
00428 
00429 struct ReadHomologyItem1 : public Ctor1<AbelianIntegralHomologyProblem,SMFPGroup>, protected FEData
00430 {
00431   Ctor* copy( ) const { return new ReadHomologyItem1; }       // overrides Ctor1
00432   SMObject* construct(SMObject* a1, Chars&, istream&) const; // overrides Ctor1
00433 };
00434 
00435 struct ReadAutEnumItem : public Ctor1<AutEnumerator,SMFPGroup>, protected FEData
00436 {
00437   Ctor* copy( ) const { return new ReadAutEnumItem; }        // overrides Ctor1
00438   SMObject* construct(SMObject* a1, Chars&, istream&) const; // overrides Ctor1
00439 };
00440 
00441 
00442 struct ReadFinAutEnumItem : public Ctor1<AutEnumerator,SMFPGroup>, protected FEData
00443 {
00444   Ctor* copy( ) const { return new ReadFinAutEnumItem; }     // overrides Ctor1
00445   SMObject* construct(SMObject* a1, Chars&, istream&) const; // overrides Ctor1
00446 };
00447 
00448 
00449 struct ReadInitialSegmentItem : public Ctor1<InitialSegmentOfWord,SMWord>, 
00450        protected FEData
00451 {
00452   Ctor* copy( ) const { return new ReadInitialSegmentItem; } // overrides Ctor1
00453   SMObject* construct(SMObject* a1, Chars&, istream&) const; // overrides Ctor1
00454 };
00455 
00456 struct ReadPHeight : public Ctor1<AbelianPHeightOfEltProblem,SMWord>, 
00457        protected FEData
00458 {
00459   Ctor* copy( ) const { return new ReadPHeight; } // overrides Ctor1
00460   SMObject* construct(SMObject* a1, Chars&, istream&) const; // overrides Ctor1
00461 };
00462 
00463 struct ReadTerminalSegmentItem : public Ctor1<TerminalSegmentOfWord,SMWord>, 
00464        protected FEData
00465 {
00466   Ctor* copy( ) const { return new ReadTerminalSegmentItem; } // overrides Ctor1
00467   SMObject* construct(SMObject* a1, Chars&, istream&) const; // overrides Ctor1
00468 };
00469 
00470 struct ReadSegmentOfWordItem : public Ctor1<SegmentOfWord,SMWord>, 
00471        protected FEData
00472 {
00473   Ctor* copy( ) const { return new ReadSegmentOfWordItem; } // overrides Ctor1
00474   SMObject* construct(SMObject* a1, Chars&, istream&) const; // overrides Ctor1
00475 };
00476 
00477 
00478 struct ReadFreeGetN_thElementItem : 
00479   public Ctor1<FreeGetN_thElement,SMFPGroup>, 
00480   protected FEData
00481 {
00482   Ctor* copy( ) const { return new ReadFreeGetN_thElementItem; } // overrides Ctor1
00483   SMObject* construct(SMObject* a1, Chars&, istream&) const; // overrides Ctor1
00484 };
00485 
00486 struct ReadFreeGetNextN_thElementItem : 
00487   public Ctor1<FreeGetNextN_thElement,SMWord>, 
00488   protected FEData
00489 {
00490   Ctor* copy( ) const { return new ReadFreeGetNextN_thElementItem; } // overrides Ctor1
00491   SMObject* construct(SMObject* a1, Chars&, istream&) const; // overrides Ctor1
00492 };
00493 
00494 
00495 struct ReadMakeNilpotentQuotientItem : 
00496     public Ctor1<MakeNilpotentQuotient,SMFPGroup>, protected FEData
00497 {
00498   Ctor* copy( ) const { return new ReadMakeNilpotentQuotientItem; } 
00499   // overrides Ctor1
00500   
00501   SMObject* construct(SMObject* a1, Chars&, istream&) const; 
00502   // overrides Ctor1
00503 };
00504 
00505 
00506 struct ReadMakeQuotientItem : 
00507     public Ctor1<MakeQuotient, SMFPGroup>, protected FEData
00508 {
00509   Ctor* copy( ) const { return new ReadMakeQuotientItem; } 
00510   // overrides Ctor1
00511   
00512   SMObject* construct(SMObject* a1, Chars&, istream&) const; 
00513   // overrides Ctor1
00514 };
00515 
00516 
00517 struct ReadIsNilpotentProblemItem : 
00518     public Ctor1<IsNilpotentProblem, SMFPGroup>, protected FEData
00519 {
00520   Ctor* copy( ) const { return new ReadIsNilpotentProblemItem; } 
00521   // overrides Ctor1
00522   
00523   SMObject* construct(SMObject* a1, Chars&, istream&) const; 
00524   // overrides Ctor1
00525 };
00526 
00527 
00528 
00529 
00530 struct ReadIsSGNilpotentItem : 
00531     public Ctor1<IsSGNilpotent, SMSubgroup>, protected FEData
00532 {
00533   Ctor* copy( ) const { return new ReadIsSGNilpotentItem; } 
00534   // overrides Ctor1
00535   
00536   SMObject* construct(SMObject* a1, Chars&, istream&) const; 
00537   // overrides Ctor1
00538 };
00539 
00540 struct ReadLCStermProblem : 
00541     public Ctor1<NGLCStermGensProblem, SMFPGroup>, protected FEData
00542 {
00543   Ctor* copy( ) const { return new ReadLCStermProblem; } 
00544   // overrides Ctor1
00545   
00546   SMObject* construct(SMObject* a1, Chars&, istream&) const; 
00547   // overrides Ctor1
00548 };
00549 
00550 // --------- Package managment ------------------//
00551 
00552 struct ReadPackage : 
00553   public Ctor0<AddPackage>, protected FEData
00554 {
00555   Ctor* copy( ) const { return new ReadPackage; } 
00556   // overrides Ctor0
00557   
00558   SMObject* construct( Chars&, istream&) const; 
00559   // overrides Ctor0
00560 };
00561 
00562 struct ReadEditPackage : 
00563   public Ctor0<EditPackage>, protected FEData
00564 {
00565   Ctor* copy( ) const { return new ReadEditPackage; } 
00566   // overrides Ctor0
00567   
00568   SMObject* construct( Chars&, istream&) const; 
00569   // overrides Ctor0
00570 };
00571 
00572 struct ReadGroupPackageID : 
00573   public Ctor1<RunPackage, SMFPGroup>, protected FEData
00574 {
00575   Ctor* copy( ) const { return new ReadGroupPackageID; } 
00576   // overrides Ctor0
00577   
00578   SMObject* construct(SMObject* a1, Chars&, istream&) const; 
00579   // overrides Ctor0
00580 };
00581 
00582 struct ReadWordPackageID : 
00583   public Ctor1<RunPackage, SMWord>, protected FEData
00584 {
00585   Ctor* copy( ) const { return new ReadWordPackageID; } 
00586   // overrides Ctor0
00587   
00588   SMObject* construct(SMObject* a1, Chars&, istream&) const; 
00589   // overrides Ctor0
00590 };
00591 
00592 struct ReadSubgroupPackageID : 
00593   public Ctor1<RunPackage, SMSubgroup>, protected FEData
00594 {
00595   Ctor* copy( ) const { return new ReadSubgroupPackageID; } 
00596   // overrides Ctor0
00597   
00598   SMObject* construct(SMObject* a1, Chars&, istream&) const; 
00599   // overrides Ctor0
00600 };
00601 
00602 struct ReadTuplePackageID : 
00603   public Ctor1<RunPackage, SMVectorOfWords>, protected FEData
00604 {
00605   Ctor* copy( ) const { return new ReadTuplePackageID; } 
00606   // overrides Ctor0
00607   
00608   SMObject* construct(SMObject* a1, Chars&, istream&) const; 
00609   // overrides Ctor0
00610 };
00611 
00612 struct ReadMapPackageID : 
00613   public Ctor1<RunPackage, SMMap>, protected FEData
00614 {
00615   Ctor* copy( ) const { return new ReadMapPackageID; } 
00616   // overrides Ctor0
00617   
00618   SMObject* construct(SMObject* a1, Chars&, istream&) const; 
00619   // overrides Ctor0
00620 };
00621 
00622 struct ReadHomoPackageID : 
00623   public Ctor1<RunPackage, SMHomomorphism>, protected FEData
00624 {
00625   Ctor* copy( ) const { return new ReadHomoPackageID; } 
00626   // overrides Ctor0
00627   
00628   SMObject* construct(SMObject* a1, Chars&, istream&) const; 
00629   // overrides Ctor0
00630 };
00631 
00632 struct ReadWordWordPackageID : 
00633   public Ctor2<RunPackage,SMWord,SMWord>, protected FEData
00634 {
00635   Ctor* copy( ) const { return new ReadWordWordPackageID; }
00636   // overrides Ctor1
00637   SMObject* construct(SMObject* a1, SMObject* a2, Chars&, istream&) const;
00638   // overrides Ctor1
00639 };
00640 
00641 struct ReadSubgroupSubgroupPackageID : 
00642   public Ctor2<RunPackage,SMSubgroup,SMSubgroup>, protected FEData
00643 {
00644   Ctor* copy( ) const { return new ReadSubgroupSubgroupPackageID; }
00645   // overrides Ctor1
00646   SMObject* construct(SMObject* a1, SMObject* a2, Chars&, istream&) const;
00647   // overrides Ctor1
00648 };
00649 
00650 struct ReadSubgroupWordPackageID : 
00651   public Ctor2<RunPackage,SMSubgroup,SMWord>, protected FEData
00652 {
00653   Ctor* copy( ) const { return new ReadSubgroupWordPackageID; }
00654   // overrides Ctor1
00655   SMObject* construct(SMObject* a1, SMObject* a2, Chars&, istream&) const;
00656   // overrides Ctor1
00657 };
00658 
00659 
00660 //---------------------------------------------------------------------------//
00661 //------------------------------ Menu ---------------------------------------//
00662 //---------------------------------------------------------------------------//
00663 
00664 
00665 class Menu : public FEData
00666 {
00667 public:
00668 
00669   enum MenuKind { CHECKIN, TOOLS, MAKE, PACKAGES, DATABASE, TESTING };
00670 
00671   void startItemGroup( );
00672   void startItemGroup(const Expression& condition);
00673 
00674   void startCascade(const Text& text);
00675   void closeCascade( );
00676 
00677   void addDisabled(const Text& text);
00678 
00679   void separator( );
00680 
00681   void done( );
00682 
00683   //-------------------------------------------------------------------------//
00684   //---------------------------- Action -------------------------------------//
00685   //-------------------------------------------------------------------------//
00686 
00687   struct Action
00688   {
00689          virtual void print(ostream& ostr) const { }
00690   };
00691 
00692   struct DefineFPGroup : public Action
00693   {
00694          void print(ostream& ostr) const;      // overrides Action
00695   };
00696 
00697   struct DefineFreeGroup : public Action
00698   {
00699          void print(ostream& ostr) const;      // overrides Action
00700   };
00701 
00702   struct DefineAbelianGroup : public Action
00703   {
00704          void print(ostream& ostr) const;      // overrides Action
00705   };
00706 
00707   struct DefineNilpotentGroup : public Action
00708   {
00709          void print(ostream& ostr) const;      // overrides Action
00710   };
00711   struct DefineFreeNilpotentGroup : public Action
00712   {
00713          void print(ostream& ostr) const;      // overrides Action
00714   };
00715 
00716   struct DefineSmallCancGroup : public Action
00717   {
00718          void print(ostream& ostr) const;      // overrides Action
00719   };
00720 
00721   struct DefineORGroup : public Action
00722   {
00723          void print(ostream& ostr) const;      // overrides Action
00724   };
00725 
00726   struct DefinePermutation : public Action
00727   {
00728          void print(ostream& ostr) const;      // overrides Action
00729   };
00730 
00731   struct DefineWord : public Action
00732   {
00733          void print(ostream& ostr) const;      // overrides Action
00734   };
00735 
00736   struct DefineEquation : public Action
00737   {
00738          void print(ostream& ostr) const;      // overrides Action
00739   };
00740 
00741   struct DefineEquation2 : public Action
00742   {
00743          void print(ostream& ostr) const;      // overrides Action
00744   };
00745 
00746   struct DefineEqSystem : public Action
00747   {
00748          void print(ostream& ostr) const;      // overrides Action
00749   };
00750 
00751   struct DefineSubgroup : public Action
00752   {
00753          void print(ostream& ostr) const;      // overrides Action
00754   };
00755 
00756 
00757   struct DefineSetOfWords : public Action
00758   {
00759          void print(ostream& ostr) const;      // overrides Action
00760   };
00761 
00762   struct DefineVectorOfWords : public Action
00763   {
00764          void print(ostream& ostr) const;      // overrides Action
00765   };
00766 
00767   
00768   struct DefineMap : public Action
00769   {
00770     void print(ostream& ostr) const;      // overrides Action
00771 
00772   };
00773 
00774 
00775   struct DefineMap2 : public Action
00776   {
00777          void print(ostream& ostr) const;      // overrides Action
00778   };
00779 
00780 
00781   struct DefineInverseMap2 : public Action
00782   {
00783          void print(ostream& ostr) const;      // overrides Action
00784   };
00785 
00786 
00787   struct DefineInt : public Action
00788   {
00789          DefineInt(const char* p, int l)
00790            : prompt(p), lower(l), suppliedUpper(false)
00791          { }
00792 
00793          DefineInt(const char* p, int l, int u)
00794            : prompt(p), lower(l), upper(u), suppliedUpper(true)
00795          { }
00796 
00797          void print(ostream& ostr) const;      // overrides Action
00798 
00799   private:
00800          const char* prompt;
00801          int lower, upper;
00802          bool suppliedUpper;
00803   };
00804 
00805   struct DefinePackage : public Action
00806   {
00807     DefinePackage() { }
00808     void print(ostream& ostr) const;      // overrides Action
00809 
00810 
00811   };
00812 
00813   struct DefineEditPackage : public Action
00814   {
00815     DefineEditPackage() { }
00816     void print(ostream& ostr) const;      // overrides Action
00817 
00818 
00819   };
00820 
00821  struct PackageID : public Action
00822   {
00823     PackageID( int id):theID( id ) { }
00824     void print(ostream& ostr) const;      // overrides Action
00825     private:
00826     int theID;
00827 
00828   };
00829 
00830   struct BoundedInteger 
00831   {
00832     BoundedInteger() 
00833       : lowerBound(0), upperBound(0),
00834         haveLowerBound(false), haveUpperBound(false)
00835     { }
00836 
00837     BoundedInteger(int lower) 
00838       : lowerBound(lower), upperBound(0), 
00839         haveLowerBound(true), haveUpperBound(false) 
00840     { }
00841 
00842     BoundedInteger(int lower, int upper) 
00843       : lowerBound(lower), upperBound(upper), 
00844         haveLowerBound(true), haveUpperBound(true) 
00845     { }
00846 
00847     int lowerBound, upperBound;
00848     bool haveLowerBound, haveUpperBound;
00849   };
00850   //@db need to change location of that class
00851 
00852   struct DefineInt2 : public Action
00853   {
00854     DefineInt2( const char* p0, const BoundedInteger& bi0,
00855                 const char* p1, const BoundedInteger& bi1 )
00856     {
00857       prompt[0] = p0;
00858       prompt[1] = p1;
00859       boundInt[0] = bi0;
00860       boundInt[1] = bi1;
00861     }
00862     
00863     void print(ostream& ostr) const;      // overrides Action
00864 
00865   private:      
00866     const char* prompt[2];
00867     BoundedInteger boundInt[2];
00868   };
00869   //@db temporary implementation, to eliminate in the future.
00870 
00871   struct DefineSetOfRelators : public Action
00872   {
00873     void print(ostream& ostr) const;      // overrides Action
00874   };
00875 
00876 protected:
00877 
00878   Menu(MenuKind);
00879 
00880   void add(Ctor* ctor, const Text& text, const Action& action);
00881 
00882 private:
00883 
00884   enum StateType { INIT, ITEM_GROUP, DONE };
00885 
00886   StateType state;
00887 };
00888 
00889 
00890 //@rn We inline all of the Menu<n> member functions, probably
00891 //@rn inappropriately, to avoid having to do explicit instantiation.
00892 //@rn This can be improved when gcc supports template repositories.
00893 
00894 
00895 class Menu0 : public Menu
00896 {
00897 public:
00898 
00899   Menu0(MenuKind mk) : Menu( mk ) {
00900          cout << "} itemGroups {";
00901   }
00902 
00903   void add(const CtorArgs0& ctor,
00904                           const Text& text,
00905                           const Action& action = Action()
00906                           )
00907   {
00908          Menu::add( ctor.copy(), text, action );
00909   }
00910 
00911 };
00912 
00913 
00914 template <class A1>
00915 class Menu1 : public Menu
00916 {
00917 public:
00918 
00919   Menu1(MenuKind mk) : Menu( mk ) {
00920          cout << A1::type();
00921          cout << "} itemGroups {";
00922   }
00923 
00924   void add(const CtorArgs1<A1>& ctor,
00925                           const Text& text,
00926                           const Action& action = Action()
00927                           )
00928   {
00929          Menu::add( ctor.copy(), text, action );
00930   }
00931 
00932 };
00933 
00934 
00935 template <class A1, class A2>
00936 class Menu2 : public Menu
00937 {
00938 public:
00939 
00940   Menu2(MenuKind mk) : Menu( mk ) {
00941          cout << A1::type() << ' ' << A2::type();
00942          cout << "} itemGroups {";
00943   }
00944 
00945   void add(const CtorArgs2<A1,A2>& ctor,
00946                           const Text& text,
00947                           const Action& action = Action()
00948                           )
00949   {
00950          Menu::add( ctor.copy(), text, action );
00951   }
00952 
00953 };
00954 
00955 
00956 template <class A1, class A2, class A3>
00957 class Menu3 : public Menu
00958 {
00959 public:
00960 
00961   Menu3(MenuKind mk) : Menu( mk )
00962   {
00963     cout << A1::type() << ' ' << A2::type() << ' ' << A3::type();
00964     cout << "} itemGroups {";
00965   }
00966 
00967   void add( const CtorArgs3<A1,A2,A3>& ctor,
00968             const Text& text,
00969             const Action& action = Action()
00970             )
00971   {
00972     Menu::add( ctor.copy(), text, action );
00973   }
00974 
00975 };
00976 
00977 
00978 template <class A1, class A2, class A3, class A4>
00979 class Menu4 : public Menu
00980 {
00981 public:
00982 
00983   Menu4(MenuKind mk) : Menu( mk )
00984   {
00985     cout << A1::type() << ' ' << A2::type() << ' ' << A3::type() << ' '
00986          << A4::type();
00987     cout << "} itemGroups {";
00988   }
00989 
00990   void add( const CtorArgs4<A1,A2,A3,A4>& ctor,
00991             const Text& text,
00992             const Action& action = Action()
00993             )
00994   {
00995     Menu::add( ctor.copy(), text, action );
00996   }
00997 
00998 };
00999 
01000 
01001 #endif

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