#include <event_handler.hpp>
Inheritance diagram for CEventHandler:


CEventHandler provides basic support for event handling. Event handling includes processing events and dispatching events. Processing involves recognizing an event of the particular type and invoking a corresponding callback. CEventHandler provide support for mapping events to callback by means of Event Maps (see macros in this file). A class can define its own Event Map that can be inherited from the Event map of the base class. Dispatching is a process of forwarding an event to other CEventHandler-s subscribed as listeners to the current handler. Dispatching algorithm can be controlled by specifying a strategy (EDispatch enumeration). All events are dispatched within pools. Pools are isolated networks of listeners subscribed to each other. An event sent to a pool will reach only listeners added to this particular pool, all other listeners will be ignored. CEventHandler has several entry points: OnEvent() – processes an event, locates a callback corresponding to it and executes the callback. Dispatch() – dispatches an event to listeners. Send() – synchronously handles events by calling OnEvent() and Dispatch(). Post() – posts an event to the event queue. Events are retrieved from the queue by HandlePostRequest() and then sent to the handler.
Definition at line 194 of file event_handler.hpp.
Public Types | |
| typedef vector< CEventHandler * > | TListeners |
| typedef map< int, TListeners > | TPools |
| typedef list< SPostRequest * > | TPostRequests |
| typedef hash_map< CEventHandler *, int > | THandlerToCount |
| typedef void(* | FOnPostCallback )() |
| enum | EDispatch { eDispatch_SelfOnly, eDispatch_AllHandlers, eDispatch_FirstHandler, eDispatch_Default = eDispatch_AllHandlers } |
| enum controlling dispatching strategies More... | |
| enum | EPoolName { ePool_Default = 0, ePool_Parent, ePool_Child, ePool_Sibling, ePool_NextAvailable } |
| Identifiers for standard pools. More... | |
Public Member Functions | |
| CEventHandler () | |
| CEventHandler. | |
| virtual | ~CEventHandler () |
| virtual void | FireEvent (CEvent *evt, EDispatch disp_how=eDispatch_Default, int pool_name=ePool_Default) |
| FireEvent - depricated, TODO - remove. | |
Event Dispatching Interface | |
| virtual void | AddListener (CEventHandler *listener, int pool_name=ePool_Default) |
| Add a listener. | |
| virtual void | RemoveListener (CEventHandler *listener) |
| Remove a listener. | |
| virtual void | RemoveAllListeners (void) |
| virtual bool | HasListener (CEventHandler *listener, int pool_name=ePool_Default) const |
| returns "true" if the given listener belongs to the specified pool | |
| virtual const TListeners * | GetListeners (int pool_name=ePool_Default) const |
| returns a set of listeners fro the specified pool | |
| virtual bool | OnEvent (CEvent *evt) |
| Processes en event. Returns "true" if event has been processed. | |
| virtual bool | Dispatch (CEvent *evt, EDispatch disp_how=eDispatch_Default, int pool_name=ePool_Default) |
| Dispatches an event to the listeners (but does not handle it). | |
| virtual bool | Send (CEvent *evt, EDispatch disp_how=eDispatch_Default, int pool_name=ePool_Default) |
| Sends an event synchronously. | |
| virtual bool | Send (CEvent *evt, int pool_name) |
| virtual void | Post (CRef< CEvent > evt, EDispatch disp_how=eDispatch_Default, int pool_name=ePool_Default) |
| Handles an event asynchronously (process and/or dispatch). | |
Static Public Member Functions | |
Static API | |
extracts the next request from the Post Queue and sends it to the target returns true if the Queue is empty | |
| static void | SetPostCallback (FOnPostCallback callback) |
| static bool | HandlePostRequest () |
| static void | ClearPostQueue () |
| erases all events from the queue | |
| static void | DestroyPostQueue () |
Protected Member Functions | |
| virtual const SEvtMap * | GetEventMap () const |
| virtual void | x_DeclareDead () |
| Removes itself unavailable for async event delivery. | |
| void | x_AddListenerToPool (CEventHandler *listener, int pool_name) |
Protected Attributes | |
| TPools | m_Pools |
Static Protected Attributes | |
| static const SEvtMap | sm_EvtMap |
Private Attributes | |
| CRef< CPostQueue > | m_Queue |
Static Private Attributes | |
| static const SEvtMapEntry | sm_EvtMapEntries [] |
| static FOnPostCallback | sm_PostCallback = NULL |
| the queue will not be destroyed until the Last handler is destroyed | |
Friends | |
| class | CPostQueue |
Classes | |
| class | CPostQueue |
| CPostQueue - singleton queue for asynchronous events all methods are synchronized. More... | |
| struct | SPostRequest |
|
|
Definition at line 230 of file event_handler.hpp. |
|
|
Definition at line 229 of file event_handler.hpp. |
|
|
Definition at line 217 of file event_handler.hpp. |
|
|
Definition at line 227 of file event_handler.hpp. |
|
|
Definition at line 228 of file event_handler.hpp. |
|
|
enum controlling dispatching strategies
Definition at line 198 of file event_handler.hpp. |
|
|
Identifiers for standard pools. Set of pools is extandable, programmers can define their own pools but need to make sure that pool identifiers are unique.
Definition at line 208 of file event_handler.hpp. |
|
|
Definition at line 46 of file event_handler.cpp. |
|
|
disconnect our listeners Definition at line 51 of file event_handler.cpp. References map_checker< Container >::end(), m_Pools, NON_CONST_ITERATE, and x_DeclareDead(). |
|
||||||||||||
|
|
erases all events from the queue
Definition at line 400 of file event_handler.cpp. References CEventHandler::CPostQueue::GetInstance(). Referenced by CGBenchApp::x_RunMessageLoop(). |
|
|
Definition at line 407 of file event_handler.cpp. References CEventHandler::CPostQueue::DestroyInstance(). Referenced by CGBenchApp::x_RunMessageLoop(). |
|
||||||||||||||||
|
Dispatches an event to the listeners (but does not handle it). Returns "true" if event has been dispatched and handled by a listener. Definition at line 285 of file event_handler.cpp. References _ASSERT, eDispatch_AllHandlers, eDispatch_FirstHandler, eDispatch_SelfOnly, map_checker< Container >::end(), map_checker< Container >::find(), handler(), ITERATE, m_Pools, and CEvent::Visit(). Referenced by CView::BroadcastVisibleRange(), CWindowManager::Dispatch(), Dispatcher::FireEvent(), Send(), CTreeBrowser::x_OnFluEvent(), and CSequenceGotoDlg::x_OnGoto(). |
|
||||||||||||||||
|
FireEvent - depricated, TODO - remove.
Definition at line 384 of file event_handler.cpp. References LOG_POST, and Send(). Referenced by CFilterBar::x_FireFilterChanged(). |
|
|
Definition at line 128 of file event_handler.cpp. References sm_EvtMap. Referenced by OnEvent(). |
|
|
returns a set of listeners fro the specified pool
Definition at line 210 of file event_handler.cpp. References map_checker< Container >::end(), map_checker< Container >::find(), and m_Pools. Referenced by CGuiDiagHandler::Post(). |
|
|
Definition at line 392 of file event_handler.cpp. References CEventHandler::CPostQueue::GetInstance(). Referenced by BOOST_AUTO_TEST_CASE(), CWorkspaceApp::Run(), CWinManagerApp::Run(), CAppJobTestApplication::Run(), s_FltkGBenchIdleFunc(), CSnpViewUI::Show(), CSeqGraphicDemoUI::Show(), CMultiDemoUI::Show(), and TestPostVersusSend(). |
|
||||||||||||
|
returns "true" if the given listener belongs to the specified pool
Definition at line 196 of file event_handler.cpp. References map_checker< Container >::end(), map_checker< Container >::find(), and m_Pools. Referenced by CWindowManager::Dispatch(), and CViewComposite::Dispatch(). |
|
|
Processes en event. Returns "true" if event has been processed.
Definition at line 220 of file event_handler.cpp. References _ASSERT, CEvent::eEvent_Command, CEvent::eEvent_CommandUpdate, ERR_POST, SEvtMapEntry::evt_class, FindEventMapEntry(), CEvent::GetAttachment(), CEvent::GetEventClass(), GetEventMap(), CEvent::GetID(), CException::GetMsg(), CEvent::GetTypeInfo(), handler(), SEvtMapEntry::handler, SEvtMapEntry::id, kOnEventException, SEvtMapEntry::last_id, and CEvent::Visit(). Referenced by Send(). |
|
||||||||||||||||
|
|
Definition at line 190 of file event_handler.cpp. References map_checker< Container >::clear(), and m_Pools. Referenced by CGBDocument::Clear(), CColorButtonPanel::~CColorButtonPanel(), CDataMiningView::~CDataMiningView(), CGradientColorPanel::~CGradientColorPanel(), CObjectListWidget::~CObjectListWidget(), and COpenViewDlg::~COpenViewDlg(). |
|
|
||||||||||||
|
Definition at line 361 of file event_handler.cpp. References eDispatch_Default, and Send(). |
|
||||||||||||||||
|
|
Definition at line 416 of file event_handler.cpp. References sm_PostCallback. Referenced by CGBenchApp::Run(). |
|
||||||||||||
|
Definition at line 154 of file event_handler.cpp. References _ASSERT, and m_Pools. Referenced by AddListener(). |
|
|
Removes itself unavailable for async event delivery. This function is called from the destructor, but derived classes may need to do it before destructor is called. Definition at line 72 of file event_handler.cpp. References m_Queue. Referenced by ~CEventHandler(). |
|
|
Definition at line 345 of file event_handler.hpp. Referenced by CEventHandler::CPostQueue::GetInstance(). |
|
|
Definition at line 313 of file event_handler.hpp. Referenced by Dispatch(), GetListeners(), HasListener(), RemoveAllListeners(), RemoveListener(), x_AddListenerToPool(), and ~CEventHandler(). |
|
|
Definition at line 348 of file event_handler.hpp. Referenced by Post(), and x_DeclareDead(). |
|
|
Initial value:
{
NULL,
&CEventHandler::sm_EvtMapEntries[0]
}
Definition at line 303 of file event_handler.hpp. Referenced by GetEventMap(). |
|
|
Initial value:
{
{ CEvent::eEvent_Unknown, typeid(void).name(),
CEvent::eEvent_InvalidID, CEvent::eEvent_InvalidID, 0 }
}
Definition at line 303 of file event_handler.hpp. |
|
|
the queue will not be destroyed until the Last handler is destroyed
Definition at line 350 of file event_handler.hpp. Referenced by CEventHandler::CPostQueue::Post(), and SetPostCallback(). |
1.4.6
Modified on Mon Nov 23 19:55:36 2009 by modify_doxy.py rev. 173732