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

/magnus/back_end/SessionManager/include/ComputationManager.h

Go to the documentation of this file.
00001 /*
00002  *   $Id: ComputationManager.h,v 1.9 2000/02/10 00:11:42 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: Declaration of class ComputationManager
00009 //
00010 // Principal Author: Roger Needham, Dmitry Bormotov
00011 //
00012 // Status: in progress
00013 //
00014 // Revision History:
00015 //
00016 // * 07/96 Dmitry B. made porting to gcc 2.7.2.
00017 //
00018 // * 06/97 @db added new functions:
00019 //
00020 //   bool crashed( ) const;
00021 //   virtual Chars getCrashMessage( ) const;
00022 //   virtual bool isSupervisor() const;
00023 //
00024 // * 03/98 @dp added new functions:
00025 //
00026 //    void attachClient( OID client );
00027 //    void detachClient( OID client );
00028 //    SetOf<OID> getClients( ) const;
00029 
00030 #ifndef _COMPUTATIONMANAGER_H_
00031 #define _COMPUTATIONMANAGER_H_
00032 
00033 
00034 #include "SMObject.h"
00035 #include "ResourceManager.h"
00036 #include "TheObjects.h"
00037 #include "ARCer.h"
00038 
00039 //---------------------------------------------------------------------------//
00040 //------------------------ ComputationManager -------------------------------//
00041 //---------------------------------------------------------------------------//
00042 
00043 class ARCer;
00044 
00045 
00046 class ComputationManager : public SMObject, public ResourceManager
00047 {
00048 
00049   friend class ARCer;
00050   friend class RelatorEnumeratorARCer;
00051   friend class ExternalARCer;
00052   friend class Supervisor;
00053 
00054 public:
00055 
00056   enum State { UNSTARTED, RUNNING, SUSPENDED, TERMINATED };
00057 
00058   /////////////////////////////////////////////////////////////////////////
00059   //                                                                     //
00060   // Constructors:                                                       //
00061   //                                                                     //
00062   /////////////////////////////////////////////////////////////////////////
00063 
00064   ComputationManager( bool display_in_fe = false );
00065 
00066   ~ComputationManager( );
00067 
00068   /////////////////////////////////////////////////////////////////////////
00069   //                                                                     //
00070   // Accessors:                                                          //
00071   //                                                                     //
00072   /////////////////////////////////////////////////////////////////////////
00073 
00074   State state( ) const;
00075 
00076   bool crashed( ) const { return isCrashed; }
00077 
00078   virtual Chars getCrashMessage( ) const { return ""; }
00079   // Override this function to change the default crash message 
00080   
00081   virtual bool isSupervisor() const { return false; }
00082   
00083   Chars helpID( const Chars& problemName, const SMFPGroup& parent ) const;
00084   // This function returns a standard helpID ( page reference in the
00085   // magnus manual). It can be given to FE by supervisors. It is a
00086   // function of the ComputationManager class, because some of CMs can
00087   // be supervisors to others.
00088 
00089 
00090   /////////////////////////////////////////////////////////////////////////
00091   //                                                                     //
00092   // Front End Interfacing:                                              //
00093   //                                                                     //
00094   /////////////////////////////////////////////////////////////////////////
00095 
00096   const char* typeID( ) const;                  // overrides SMObject
00097 
00098   const IconID iconID( ) const;                 // overrides SMObject
00099 
00100   void viewStructure(ostream& ostr) const;      // overrides SMObject
00101 
00102   void printProperties(ostream& ostr) const;    // overrides SMObject  
00103 
00104   void printDefinition(ostream& ostr) const;    // overrides SMObject
00105 
00106   bool displayInFE( ) const { return showMe; }  // overrides SMObject
00107 
00108   static void printGlobalMessageTemplates(ostream& ostr);
00109 
00110   /////////////////////////////////////////////////////////////////////////
00111   //                                                                     //
00112   // Control:                                                            //
00113   //                                                                     //
00114   /////////////////////////////////////////////////////////////////////////
00115 
00116   virtual void takeControl( ) = 0;
00117 
00118   bool fastResult( ) const { return amFast; }
00119   // A derivative's ctor may decide that the result can be gotten so
00120   // quickly that there is no need, e.g., to create a problem object.
00121 
00122   bool checkForStall( );
00123   // Checks whether this is stalled (returns true if so), and sends
00124   // StateTransition if necessary.
00125 
00126   void attachClient( const SMObject& client ); 
00127   void detachClient( const SMObject& client );
00128   SetOf<OID> getClients( ) const;
00129 
00130   /////////////////////////////////////////////////////////////////////////
00131   //                                                                     //
00132   // State Transitions:                                                  //
00133   //                                                                     //
00134   /////////////////////////////////////////////////////////////////////////
00135 
00136   // To move into any of the four States, there is an administrative
00137   // member which handles the invariant stuff like informing the front
00138   // end of the change. For each of these, there is a virtual
00139   // counterpart, which is overridden to do the actual work required
00140   // by the state change.
00141 
00142   void adminStart( );
00143 
00144   void adminSuspend( );
00145 
00146   void adminResume( );
00147 
00148   virtual void adminTerminate( );
00149 
00150   virtual void start( ) { }
00151 
00152   virtual void suspend( ) { }     // Probably no need to override
00153 
00154   virtual void resume( ) { }      // Probably no need to override
00155 
00156   virtual void terminate( ) { }
00157 
00158 
00159 protected:
00160 
00161   void readMessage(istream& istr);  // Overrides SMObject
00162 
00163   void resultIsFast( );
00164   // A derivative reports its quickness with this.
00165 
00166 
00167 private:
00168 
00169   void hireArcer( ARCer* arcer );
00170 
00171   void terminateArcers( );
00172 
00173   void setCrashState( );
00174   
00175 
00176   /////////////////////////////////////////////////////////////////////////
00177   //                                                                     //
00178   // Data Members:                                                       //
00179   //                                                                     //
00180   /////////////////////////////////////////////////////////////////////////
00181 
00182   ListOf<ARCer*> theArcers;
00183 
00184   SetOf<OID> theClients;
00185 
00186   bool amFast;
00187 
00188   bool showMe;
00189 
00190   State theState;
00191 
00192   bool isCrashed;
00193   // true when arcer reported about it's crash
00194 
00195   bool wasStalled;
00196   // Used to prevent repeated stall messages.
00197 
00198   // These are the tags for messages handled by objects in this class:
00199 
00200   enum MessageTag {
00201          VIEW_REQUEST, ARC_UPDATE, START, SUSPEND, RESUME, TERMINATE, PARAMETER
00202   };
00203 
00204 };
00205 
00206 #endif
00207 

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