1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206
|
// Copyright (C) 1995 The New York Group Theory Cooperative
// See magnus/doc/COPYRIGHT for the full notice.
//
// Contents: Declaration of class ComputationManager
//
// Principal Author: Roger Needham, Dmitry Bormotov
//
// Status: in progress
//
// Revision History:
//
// * 07/96 Dmitry B. made porting to gcc 2.7.2.
//
// * 06/97 @db added new functions:
//
// bool crashed( ) const;
// virtual Chars getCrashMessage( ) const;
// virtual bool isSupervisor() const;
//
// * 03/98 @dp added new functions:
//
// void attachClient( OID client );
// void detachClient( OID client );
// SetOf<OID> getClients( ) const;
#ifndef _COMPUTATIONMANAGER_H_
#define _COMPUTATIONMANAGER_H_
#include "SMObject.h"
#include "ResourceManager.h"
#include "TheObjects.h"
#include "ARCer.h"
//---------------------------------------------------------------------------//
//------------------------ ComputationManager -------------------------------//
//---------------------------------------------------------------------------//
class ARCer;
//@njz: added to avoid complain of GCC-4.0.1
class SMFPGroup;
//
class ComputationManager : public SMObject, public ResourceManager
{
friend class ARCer;
friend class RelatorEnumeratorARCer;
friend class ExternalARCer;
friend class Supervisor;
public:
enum State { UNSTARTED, RUNNING, SUSPENDED, TERMINATED };
/////////////////////////////////////////////////////////////////////////
// //
// Constructors: //
// //
/////////////////////////////////////////////////////////////////////////
ComputationManager( bool display_in_fe = false );
~ComputationManager( );
/////////////////////////////////////////////////////////////////////////
// //
// Accessors: //
// //
/////////////////////////////////////////////////////////////////////////
State state( ) const;
bool crashed( ) const { return isCrashed; }
virtual Chars getCrashMessage( ) const { return ""; }
// Override this function to change the default crash message
virtual bool isSupervisor() const { return false; }
Chars helpID( const Chars& problemName, const SMFPGroup& parent ) const;
// This function returns a standard helpID ( page reference in the
// magnus manual). It can be given to FE by supervisors. It is a
// function of the ComputationManager class, because some of CMs can
// be supervisors to others.
/////////////////////////////////////////////////////////////////////////
// //
// Front End Interfacing: //
// //
/////////////////////////////////////////////////////////////////////////
const char* typeID( ) const; // overrides SMObject
const IconID iconID( ) const; // overrides SMObject
void viewStructure(ostream& ostr) const; // overrides SMObject
void printProperties(ostream& ostr) const; // overrides SMObject
void printDefinition(ostream& ostr) const; // overrides SMObject
bool displayInFE( ) const { return showMe; } // overrides SMObject
static void printGlobalMessageTemplates(ostream& ostr);
/////////////////////////////////////////////////////////////////////////
// //
// Control: //
// //
/////////////////////////////////////////////////////////////////////////
virtual void takeControl( ) = 0;
bool fastResult( ) const { return amFast; }
// A derivative's ctor may decide that the result can be gotten so
// quickly that there is no need, e.g., to create a problem object.
bool checkForStall( );
// Checks whether this is stalled (returns true if so), and sends
// StateTransition if necessary.
void attachClient( const SMObject& client );
void detachClient( const SMObject& client );
SetOf<OID> getClients( ) const;
/////////////////////////////////////////////////////////////////////////
// //
// State Transitions: //
// //
/////////////////////////////////////////////////////////////////////////
// To move into any of the four States, there is an administrative
// member which handles the invariant stuff like informing the front
// end of the change. For each of these, there is a virtual
// counterpart, which is overridden to do the actual work required
// by the state change.
void adminStart( );
void adminSuspend( );
void adminResume( );
virtual void adminTerminate( );
virtual void start( ) { }
virtual void suspend( ) { } // Probably no need to override
virtual void resume( ) { } // Probably no need to override
virtual void terminate( ) { }
protected:
void readMessage(istream& istr); // Overrides SMObject
void resultIsFast( );
// A derivative reports its quickness with this.
private:
void hireArcer( ARCer* arcer );
void terminateArcers( );
void setCrashState( );
/////////////////////////////////////////////////////////////////////////
// //
// Data Members: //
// //
/////////////////////////////////////////////////////////////////////////
ListOf<ARCer*> theArcers;
SetOf<OID> theClients;
bool amFast;
bool showMe;
State theState;
bool isCrashed;
// true when arcer reported about it's crash
bool wasStalled;
// Used to prevent repeated stall messages.
// These are the tags for messages handled by objects in this class:
enum MessageTag {
VIEW_REQUEST, ARC_UPDATE, START, SUSPEND, RESUME, TERMINATE, PARAMETER
};
};
#endif
|