Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/event/event_handler.h @ 7426

Last change on this file since 7426 was 7256, checked in by bensch, 19 years ago

orxonox/trunk: merged the preferences back to the trunk
merged with command:
svn merge https://svn.orxonox.net/orxonox/branches/preferences . -r7233:HEAD
no conflicts… nice work

File size: 2.2 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#include <stack>
14
15// FORWARD DECLARATION
16class EventListener;
17
18//! The one Event Handler from Orxonox
19class EventHandler : public BaseObject {
20
21 public:
22  virtual ~EventHandler();
23  /** @returns a Pointer to the only object of this Class */
24  inline static EventHandler* getInstance() { if (!singletonRef) singletonRef = new EventHandler();  return singletonRef; };
25  void init();
26
27  /** @param state: to which the event handler shall change */
28  inline void setState(elState state) { this->state = state; };
29  /** @returns the current state */
30  inline elState getState() const { return this->state; };
31
32  void pushState(elState state);
33  elState popState();
34
35  void subscribe(EventListener* el, elState state, int eventType);
36  void unsubscribe(elState state, int eventType);
37  void unsubscribe(EventListener* el, elState state = ES_ALL);
38  void flush(elState state);
39  /** @returns true, if the @param state has @param eventType subscribed?? */
40  inline bool isSubscribed(elState state, int eventType) { return(listeners[state][eventType] == NULL)?false:true; };
41
42
43  void withUNICODE(bool enableUNICODE);
44  void grabEvents(bool grabEvents);
45  bool grabbedEvents() const { return this->eventsGrabbed; };
46
47  void process();
48
49  static int eventFilter(const SDL_Event *event);
50  void debug() const;
51
52 private:
53  EventHandler();
54
55 private:
56  static EventHandler*       singletonRef;                    //!< the singleton reference
57
58  EventListener*             listeners[ES_NUMBER][EV_NUMBER]; //!< a list of registered listeners.
59  elState                    state;                           //!< the state of the event handlder.
60  std::stack<short>          stateStack;                      //!< a stack for the States we are in.
61  KeyMapper*                 keyMapper;                       //!< reference to the key mapper.
62
63  bool                       bUNICODE;                        //!< If unicode should be enabled.
64  bool                       eventsGrabbed;                   //!< If the events should be grabbed
65};
66
67
68#endif /* _EVENT_HANDLER_H */
Note: See TracBrowser for help on using the repository browser.