00001 //===========================================================================// 00002 // 00003 // Description: interface for user defined event handling classes 00004 // Filename: colcows/ColCOWS_EventHandlerManager.hh 00005 // Authors: Michael Dussere and Aurélien Esnard 00006 // 00007 //===========================================================================// 00008 // 00009 // Copyright (C) 2003 INRIA and CNRS 00010 // 00011 // This library is free software; you can redistribute it and/or 00012 // modify it under the terms of the GNU Lesser General Public 00013 // License as published by the Free Software Foundation; either 00014 // version 2.1 of the License, or (at your option) any later version. 00015 // 00016 // This library is distributed in the hope that it will be useful, 00017 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00019 // Lesser General Public License for more details. 00020 // 00021 // You should have received a copy of the GNU Lesser General Public 00022 // License along with this library; if not, write to the Free Software 00023 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00024 // 00025 //===========================================================================// 00026 00027 #ifndef __COLCOWS_EVENT_HANDLER_MANAGER_HH__ 00028 #define __COLCOWS_EVENT_HANDLER_MANAGER_HH__ 00029 00030 //---------------------------------------------------------------------------// 00031 #include "ColCOWS_Include.hh" 00032 #include "ColCOWS_Debug.hh" 00033 //---------------------------------------------------------------------------// 00034 00035 namespace ColCOWS { 00036 class EventHandler; 00037 } 00038 00039 __COLCOWS_BEGIN__ 00040 00041 class Node; 00042 00043 //! ColCOWS event handler manger 00044 /** 00045 * The EventHandlers allow the user to catch and react to events of workspace life-cycle 00046 * (activation, connection, disconnection). This class manages several event handlers and 00047 * forwards them the ColCOWS events. 00048 * 00049 */ 00050 class EventHandlerManager : public std::map<unsigned int, EventHandler * > 00051 { 00052 00053 //================================================// 00054 //=========== class standard interface ===========// 00055 public: 00056 friend class Node; 00057 00058 //! constructor 00059 EventHandlerManager(); 00060 00061 //! destructor 00062 virtual ~EventHandlerManager(); 00063 00064 //=========================================// 00065 //=========== public interface ===========// 00066 public: 00067 00068 //! add an event handler in the manager 00069 unsigned int addEventHandler( EventHandler * event_handler ); 00070 00071 //! remove an event handler from the manager 00072 void removeEventHandler( unsigned int key ); 00073 00074 //! get ColCOWS Node pointer 00075 inline Node * getColCOWSNode( ) const { return _colcows_node; } 00076 00077 //! get ColCOWS Node pointer 00078 inline void setColCOWSNode( Node * colcows_node ) { _colcows_node = colcows_node; } 00079 00080 // //============ Activation =================// 00081 // 00082 // //! wait end of activation 00083 // bool waitActivation() ; 00084 // 00085 // //! wait end of activation 00086 // bool waitDeactivation() ; 00087 // 00088 // //=========== Connection ==================// 00089 // 00090 // //! wait the connection of a remote workspace 00091 // unsigned long waitConnection( const char* ws_id, const char * ws_kind ) ; 00092 // 00093 // //! wait the disconnection of a remote workspace 00094 // unsigned long waitDisconnection( const char* ws_id, const char * ws_kind ) ; 00095 00096 //=========================================// 00097 //=========== public interface ===========// 00098 protected: 00099 00100 //! treatment on the activation of the workspace 00101 void onActivation(); 00102 00103 //! treatment on the deactivation of the workspace 00104 void onDeactivation(); 00105 00106 //! treatment on the connection of a workspace 00107 void onConnection( unsigned long num_connection, bool initiator ); 00108 00109 //! treatment on a disconnection 00110 void onDisconnection( unsigned long num_connection ); 00111 00112 protected: 00113 00114 //! associated Node 00115 Node * _colcows_node; 00116 00117 //! max key 00118 unsigned int _max_key; 00119 00120 }; 00121 00122 __COLCOWS_END__ 00123 00124 #endif // __COLCOWS_EVENT_HANDLER_HH__ 00125 00126 // EOF 00127