#include <event_server.h>
Nevrax France
Definition at line 52 of file event_server.h.
Public Member Functions | |
void | addEmitter (IEventEmitter *emitter) |
void | addListener (CClassId id, IEventListener *listener) |
void | postEvent (CEvent *event) |
void | pump (bool allWindows=false) |
void | removeEmitter (IEventEmitter *emitter) |
void | removeListener (CClassId id, IEventListener *listener) |
virtual | ~CEventServer () |
Protected Member Functions | |
virtual bool | pumpEvent (CEvent *event) |
Private Attributes | |
std::list< IEventEmitter * > | _Emitters |
std::list< CEvent * > | _Events |
mapListener | _Listeners |
|
Definition at line 59 of file event_server.h.
00059 {} |
|
Add an Emitter to the server
Definition at line 136 of file event_server.cpp. Referenced by NL3D::CDriverUser::setDisplay().
00137 { 00138 _Emitters.push_back(emitter); 00139 } |
|
Add a callback (associated with an id)
Definition at line 105 of file event_server.cpp. References _Listeners. Referenced by NL3D::CEvent3dMouseListener::addToServer(), and NLMISC::CEventListenerAsync::addToServer().
00106 { 00107 _Listeners.insert( mapListener::value_type(id, listener)); 00108 } |
|
add event to the list
Definition at line 41 of file event_server.cpp.
00042 { 00043 _Events.push_back(event); 00044 } |
|
get call every callbacks associated with event id
Definition at line 51 of file event_server.cpp. References pumpEvent().
00052 { 00053 std::list<IEventEmitter*>::iterator item = _Emitters.begin(); 00054 00055 // getting events from emitters 00056 while(item!=_Emitters.end()) 00057 { 00058 // ask emitters to submit their events to server 00059 (*item)->submitEvents(*this, allWindows); 00060 item++; 00061 } 00062 00063 00064 std::list<CEvent*>::iterator itev = _Events.begin(); 00065 00066 while(itev!=_Events.end()) 00067 { 00068 // pump event 00069 bool bDelete=pumpEvent(*itev); 00070 if (bDelete) 00071 delete *itev; 00072 itev=_Events.erase (itev); 00073 } 00074 } |
|
call every callbacks associated with event id
Definition at line 80 of file event_server.cpp. References _Listeners, and uint64. Referenced by pump().
00081 { 00082 // taking id 00083 uint64 id = (uint64) *event; 00084 00085 // looking for the first occurence of id 00086 mapListener::iterator it = _Listeners.find(id); 00087 00088 // calling every callbacks 00089 while(it!=_Listeners.end() && (uint64)(*it).first == id) 00090 { 00091 IEventListener *a = (IEventListener *)((*it).second); 00092 (*a) (*event); 00093 it++; 00094 } 00095 00096 // delete the pointer 00097 return true; 00098 } |
|
Remove an Emitter from the server
Definition at line 145 of file event_server.cpp. Referenced by NL3D::CDriverUser::release().
00146 { 00147 _Emitters.remove(emitter); 00148 } |
|
Remove a callback
Definition at line 114 of file event_server.cpp. References _Listeners. Referenced by NL3D::CEvent3dMouseListener::removeFromServer(), and NLMISC::CEventListenerAsync::removeFromServer().
00115 { 00116 // looking for the first occurence of id 00117 mapListener::iterator it = _Listeners.find(id); 00118 00119 // looking for occurence with the right callback 00120 while(it!=_Listeners.end() && (*it).first == id) 00121 { 00122 if((*it).second==listener) 00123 { 00124 // erasing pair 00125 _Listeners.erase(it); 00126 return; 00127 } 00128 it++; 00129 } 00130 } |
|
Definition at line 55 of file event_server.h. |
|
Definition at line 56 of file event_server.h. |
|
Definition at line 54 of file event_server.h. Referenced by addListener(), pumpEvent(), and removeListener(). |