00001 //===========================================================================// 00002 // 00003 // Description: interface for user defined event handling classes 00004 // Filename: colcows/ColCOWS_EventHandler.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_HH__ 00028 #define __COLCOWS_EVENT_HANDLER_HH__ 00029 00030 //---------------------------------------------------------------------------// 00031 #include "ColCOWS_Include.hh" 00032 #include "ColCOWS_Debug.hh" 00033 //---------------------------------------------------------------------------// 00034 00035 namespace ColCOWS { 00036 class EventHandlerManager; 00037 class Node; 00038 } 00039 00040 __COLCOWS_BEGIN__ 00041 00042 //! ColCOWS event handler 00043 /** 00044 * The EventHandler allows the user to catch and react to events of workspace life-cycle 00045 * (activation, connection, disconnection). 00046 * 00047 * The user must declare a class inheriting from EventHandler and implement the event methods 00048 * called by the ColCOWS nodes. Then he must register his event handler to the node with 00049 * Node::setEventHandler( ... ). 00050 * 00051 * \todo Allow several event handlers to be connected on one workspace 00052 */ 00053 class EventHandler 00054 { 00055 00056 //================================================// 00057 //=========== class standard interface ===========// 00058 public: 00059 friend class EventHandlerManager; 00060 00061 //! constructor 00062 EventHandler(): _key(0) {}; 00063 00064 //! destructor 00065 virtual ~EventHandler() {}; 00066 00067 //============================================// 00068 //=========== protected interface ===========// 00069 protected: 00070 00071 //! treatment on the activation of the workspace 00072 virtual void onActivation() {} 00073 00074 //! treatment on the deactivation of the workspace 00075 virtual void onDeactivation() {} 00076 00077 //! treatment on the connection of a workspace 00078 virtual void onConnection( unsigned long num_connection, bool initiator ) {} 00079 00080 //! treatment on a disconnection 00081 virtual void onDisconnection( unsigned long num_connection ) {} 00082 00083 //========================================// 00084 //============== Accessors ===============// 00085 public: 00086 00087 //! get key of this event handler in its event handler manager ( 0 => not registred to an event handler manager ) 00088 inline unsigned int getKey() const { return _key; } 00089 00090 //! set key of this event handler in its event handler manager ( 0 => not registred to an event handler manager ) 00091 inline void setKey( unsigned int key) { _key = key; } 00092 00093 //! get event handler manager pointer 00094 inline EventHandlerManager * getEventHandlerManager( ) const { return _event_handler_manager; } 00095 00096 //! set event handler manager pointer 00097 inline void setEventHandlerManager( EventHandlerManager * event_handler_manager) { _event_handler_manager = event_handler_manager; } 00098 00099 //! get ColCOWS Node pointer 00100 Node * getColCOWSNode( ) const; 00101 00102 protected: 00103 //! associated EventHandlerManager 00104 EventHandlerManager * _event_handler_manager; 00105 00106 //! key in the event handler manager 00107 unsigned int _key; 00108 }; 00109 00110 __COLCOWS_END__ 00111 00112 #endif // __COLCOWS_EVENT_HANDLER_HH__ 00113 00114 // EOF 00115