Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 6690 was 6054, checked in by bensch, 19 years ago

orxonox/trunk: multiple new Reparenting modes in PNode.
Testing the stuff in GuidedMissile
Projectile has a PNode as reference not as pointer
some minor weapon changes

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