Changeset 7868 in orxonox.OLD for trunk/src/lib/event
- Timestamp:
- May 26, 2006, 1:21:32 PM (19 years ago)
- Location:
- trunk/src/lib/event
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/event/event_def.h
r5553 r7868 12 12 #include "SDL/SDL_keysym.h" 13 13 #endif 14 #include "stdincl.h"15 14 16 15 -
trunk/src/lib/event/event_handler.cc
r7756 r7868 171 171 unsubscribe(EventListener* el, elState state) function 172 172 */ 173 void EventHandler::unsubscribe( elState state, int eventType)173 void EventHandler::unsubscribe(EventListener* el, elState state, int eventType) 174 174 { 175 175 PRINTF(4)("Unsubscribing event type nr: %i\n", eventType); 176 176 if (state == ES_ALL) 177 177 for (unsigned int i = 0; i < ES_NUMBER; i++) 178 this->listeners[i][eventType].clear(); 179 else 180 this->listeners[state][eventType].clear(); 181 } 182 183 184 /** 185 * unsubscribe all events from a specific listener 178 { 179 std::vector<EventListener*>::iterator listener = 180 std::find(this->listeners[i][eventType].begin(), 181 this->listeners[i][eventType].end(), 182 el); 183 if (listener != this->listeners[i][eventType].end()) 184 this->listeners[i][eventType].erase(listener); 185 } 186 else 187 { 188 std::vector<EventListener*>::iterator listener = 189 std::find(this->listeners[state][eventType].begin(), 190 this->listeners[state][eventType].end(), 191 el); 192 if (listener != this->listeners[state][eventType].end()) 193 this->listeners[state][eventType].erase(listener); 194 } 195 } 196 197 198 /** 199 * @brief unsubscribe all events from a specific listener 186 200 * @param el: the listener that wants to unsubscribe itself 187 201 * @param state: the state in which the events shall be unsubscribed 188 189 */ 202 */ 190 203 void EventHandler::unsubscribe(EventListener* el, elState state) 191 204 { -
trunk/src/lib/event/event_handler.h
r7756 r7868 35 35 36 36 void subscribe(EventListener* el, elState state, int eventType); 37 void unsubscribe( elState state, int eventType);37 void unsubscribe(EventListener* el, elState state, int eventType); 38 38 void unsubscribe(EventListener* el, elState state = ES_ALL); 39 39 void flush(elState state); -
trunk/src/lib/event/event_listener.cc
r4866 r7868 19 19 #include "event_handler.h" 20 20 21 using namespace std;22 23 24 21 /** 25 * standard constructor26 */22 * @brief standard constructor 23 */ 27 24 EventListener::EventListener () 28 25 { … … 32 29 33 30 /** 34 * standard deconstructor 35 */ 31 * @brief standard deconstructor 32 * 33 * Unsubscribes all Subscribed Events, of this EventListener. 34 */ 36 35 EventListener::~EventListener () 37 36 { … … 39 38 EventHandler::getInstance()->unsubscribe(this, ES_ALL); 40 39 } 40 41 bool EventListener::isEventSubscribed(elState state, int eventType) const 42 { 43 return EventHandler::getInstance()->isSubscribed(state, eventType); 44 } 45 46 47 /** 48 * @brief Subscribes an Events to this EventListener. 49 * @param state the state to subscribe to. 50 * @param eventType the Type of Event to subscribe. 51 */ 52 void EventListener::subscribeEvent(elState state, int eventType) 53 { 54 EventHandler::getInstance()->subscribe(this, state, eventType); 55 } 56 57 58 /** 59 * @brief Unubscribes an Event from this EventListener. 60 * @param state the state to unsubscribe from. 61 * @param eventType the Type of Event to unsubscribe. 62 */ 63 void EventListener::unsubscribeEvent(elState state, int eventType) 64 { 65 EventHandler::getInstance()->unsubscribe(this, state, eventType); 66 } 67 68 void EventListener::unsubscribeEvents(elState state) 69 { 70 EventHandler::getInstance()->unsubscribe(this, state); 71 } 72 -
trunk/src/lib/event/event_listener.h
r5291 r7868 9 9 #include "base_object.h" 10 10 #include "event.h" 11 #include "event_def.h" 11 12 12 13 //! A class for event listener … … 17 18 virtual ~EventListener(); 18 19 20 bool isEventSubscribed(elState state, int eventType) const; 21 22 void subscribeEvent(elState state, int eventType); 23 void unsubscribeEvent(elState state, int eventType); 24 void unsubscribeEvents(elState state = ES_ALL); 25 19 26 /** 20 * abstract function that processes events from the handler27 * @brief abstract function that processes events from the handler 21 28 * @param event: the event 22 29 */ 23 30 virtual void process(const Event &event) = 0; 31 24 32 }; 25 33
Note: See TracChangeset
for help on using the changeset viewer.