[4817] | 1 | /* |
---|
[4329] | 2 | orxonox - the future of 3D-vertical-scrollers |
---|
| 3 | |
---|
| 4 | Copyright (C) 2004 orx |
---|
| 5 | |
---|
| 6 | This program is free software; you can redistribute it and/or modify |
---|
| 7 | it under the terms of the GNU General Public License as published by |
---|
| 8 | the Free Software Foundation; either version 2, or (at your option) |
---|
| 9 | any later version. |
---|
| 10 | |
---|
| 11 | ### File Specific: |
---|
[4346] | 12 | main-programmer: Patrick Boenzli |
---|
[4329] | 13 | co-programmer: ... |
---|
| 14 | */ |
---|
| 15 | |
---|
[4346] | 16 | #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_EVENT |
---|
[4329] | 17 | |
---|
[4346] | 18 | #include "event_listener.h" |
---|
[4817] | 19 | #include "event_handler.h" |
---|
[4329] | 20 | |
---|
| 21 | /** |
---|
[7868] | 22 | * @brief standard constructor |
---|
| 23 | */ |
---|
[4817] | 24 | EventListener::EventListener () |
---|
[4329] | 25 | { |
---|
[4836] | 26 | this->setClassID(CL_EVENT_LISTENER, "EventListener"); |
---|
[4329] | 27 | } |
---|
| 28 | |
---|
| 29 | |
---|
| 30 | /** |
---|
[7868] | 31 | * @brief standard deconstructor |
---|
| 32 | * |
---|
| 33 | * Unsubscribes all Subscribed Events, of this EventListener. |
---|
| 34 | */ |
---|
[4817] | 35 | EventListener::~EventListener () |
---|
| 36 | { |
---|
| 37 | /* unsubscribes itself from the event listener */ |
---|
[4866] | 38 | EventHandler::getInstance()->unsubscribe(this, ES_ALL); |
---|
[4817] | 39 | } |
---|
[7868] | 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 | |
---|