Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/collision_detection/src/lib/event/event_handler.h @ 6675

Last change on this file since 6675 was 5388, checked in by bensch, 19 years ago

orxonox/trunk: implemented a t-Stack, for dynamic stacks, and integrated it into the Shell.

File size: 2.0 KB
Line 
1/*!
2 * @file event_handler.h
3 * Definition of the EventHandler
4 *
5 */
6
7#ifndef _EVENT_HANDLER_H
8#define _EVENT_HANDLER_H
9
10#include "base_object.h"
11#include "key_mapper.h"
12#include "event_def.h"
13
14// FORWARD DECLARATION
15class EventListener;
16template<class T> class tList;
17template<class T> class tStack;
18class IniParser;
19
20//! The one Event Handler from Orxonox
21class EventHandler : public BaseObject {
22
23 public:
24  virtual ~EventHandler();
25  /** @returns a Pointer to the only object of this Class */
26  inline static EventHandler* getInstance() { if (!singletonRef) singletonRef = new EventHandler();  return singletonRef; };
27  void init(IniParser* iniParser);
28
29  /** @param state: to which the event handler shall change */
30  inline void setState(elState state) { this->state = state; };
31  /** @returns the current state */
32  inline elState getState() const { return this->state; };
33
34  void pushState(elState state);
35  elState popState();
36
37  void subscribe(EventListener* el, elState state, int eventType);
38  void unsubscribe(elState state, int eventType);
39  void unsubscribe(EventListener* el, elState state = ES_ALL);
40  void flush(elState state);
41  /** @returns true, if the @param state has @param eventType subscribed?? */
42  inline bool isSubscribed(elState state, int eventType) { return(listeners[state][eventType] == NULL)?false:true; };
43
44  void process();
45
46  static int eventFilter(const SDL_Event *event);
47  void debug() const;
48
49 private:
50  EventHandler();
51
52
53 private:
54  static EventHandler*       singletonRef;                    //!< the singleton reference
55
56  EventListener*             listeners[ES_NUMBER][EV_NUMBER]; //!< a list of registered listeners.
57  elState                    state;                           //!< the state of the event handlder.
58  tStack<short>*             stateStack;                      //!< a stack for the States we are in.
59  KeyMapper*                 keyMapper;                       //!< reference to the key mapper.
60
61};
62
63
64#endif /* _EVENT_HANDLER_H */
Note: See TracBrowser for help on using the repository browser.