Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/event/event_listener.cc @ 7868

Last change on this file since 7868 was 7868, checked in by bensch, 18 years ago

trunk: merge Check in the Event-changes:
r7867 | bensch | 2006-05-26 13:19:46 +0200 (Fri, 26 May 2006) | 1 line

Events better subscribed


r7866 | bensch | 2006-05-26 13:11:10 +0200 (Fri, 26 May 2006) | 1 line

Events are subscribed at the EventListener, and not the EventHandler

File size: 1.7 KB
Line 
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 */
24EventListener::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 */
35EventListener::~EventListener ()
36{
37  /* unsubscribes itself from the event listener */
38  EventHandler::getInstance()->unsubscribe(this, ES_ALL);
39}
40
41bool 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 */
52void 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 */
63void EventListener::unsubscribeEvent(elState state, int eventType)
64{
65  EventHandler::getInstance()->unsubscribe(this, state, eventType);
66}
67
68void EventListener::unsubscribeEvents(elState state)
69{
70  EventHandler::getInstance()->unsubscribe(this, state);
71}
72
Note: See TracBrowser for help on using the repository browser.