00001 00002 // 00003 // CLASS AlephInteractiveHandler.h 00004 // handles the communication with the external world 00005 // for interactive sessions 00006 // 00007 // Author : C. Delaere 00008 // 00010 00011 00012 #ifndef _ALEPHINTERACTIVEHANDLER_H_ 00013 #define _ALEPHINTERACTIVEHANDLER_H_ 00014 00015 #include <vector> 00016 00017 class AlphaBanks; 00018 class AlephAbstractInteractiveFunction; 00019 00020 class AlephInteractiveHandler 00021 { 00022 public: 00023 // the instance function of the Singleton 00024 static AlephInteractiveHandler* TheAlephInteractiveHandler(); 00025 // the list of interactive functions 00026 static vector<AlephAbstractInteractiveFunction*> InteractiveFunctionsList; 00027 // configure the communications 00028 void ConfigureProtocol(string myname, string yourname); 00029 // prepare the run (send list of user's functions, finish with ready 00030 void InitiateConnection(int& ier); 00031 // communicate with the external world using driver and user's functions 00032 int HandleEvent(AlphaBanks& bb); 00033 // terminate the session by sending the 999 message. 00034 void CloseConnection(); 00035 // Do we want all the events or just selected ones ? 00036 bool KeepAllEvents() {return kae;} 00037 00038 protected: 00039 // constructor and destructor 00040 AlephInteractiveHandler(); 00041 ~AlephInteractiveHandler(); 00042 00043 private: 00044 // the pointer to the single static instance 00045 static AlephInteractiveHandler* _theAlephInteractiveHandler; 00046 // reset the InteractiveFunctionsList 00047 void ClearAll(); 00048 // the protocol 00049 void SendMessage(int code, vector<float>& options, string comment); 00050 vector<float> ReceiveMessage(int& code, string& comment); 00051 // Do we want all the events or just selected ones ? 00052 bool kae; 00053 // some parameters for the communication 00054 string me, you; 00055 friend class AlephAbstractInteractiveFunction; 00056 }; 00057 00058 #endif