1 | /* |
---|
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: |
---|
12 | main-programmer: Patrick Boenzli |
---|
13 | co-programmer: ... |
---|
14 | */ |
---|
15 | |
---|
16 | #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_EVENT |
---|
17 | |
---|
18 | #include "event_listener.h" |
---|
19 | #include "event_handler.h" |
---|
20 | |
---|
21 | /** |
---|
22 | * @brief standard constructor |
---|
23 | */ |
---|
24 | EventListener::EventListener () |
---|
25 | { |
---|
26 | this->setClassID(CL_EVENT_LISTENER, "EventListener"); |
---|
27 | } |
---|
28 | |
---|
29 | |
---|
30 | /** |
---|
31 | * @brief standard deconstructor |
---|
32 | * |
---|
33 | * Unsubscribes all Subscribed Events, of this EventListener. |
---|
34 | */ |
---|
35 | EventListener::~EventListener () |
---|
36 | { |
---|
37 | /* unsubscribes itself from the event listener */ |
---|
38 | EventHandler::getInstance()->unsubscribe(this, ES_ALL); |
---|
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 | |
---|