| 
                Last change
                  on this file since 4690 was
                  4519,
                  checked in by bensch, 20 years ago
           | 
        
        
          | 
               
orxonox/trunk: changed all getInstances into inline functions to save some (minor) time 
 
           | 
        
        | 
            File size:
            1.2 KB
           | 
      
      
        
  | Line |   | 
|---|
| 1 | /*!  | 
|---|
| 2 |     \file event_handler.h | 
|---|
| 3 |     \brief 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 | class EventListener; | 
|---|
| 15 |  | 
|---|
| 16 |  | 
|---|
| 17 | //! The one Event Handler from Orxonox | 
|---|
| 18 | class EventHandler : public BaseObject { | 
|---|
| 19 |  | 
|---|
| 20 |  public: | 
|---|
| 21 |   virtual ~EventHandler(void); | 
|---|
| 22 |   /** \returns a Pointer to the only object of this Class */ | 
|---|
| 23 |   inline static EventHandler* getInstance(void) { if (!singletonRef) singletonRef = new EventHandler();  return singletonRef; }; | 
|---|
| 24 |   void init(); | 
|---|
| 25 |  | 
|---|
| 26 |   void setState(elState state); | 
|---|
| 27 |  | 
|---|
| 28 |   void subscribe(EventListener* el, elState state, int eventType); | 
|---|
| 29 |   void unsubscribe(elState state, int eventType); | 
|---|
| 30 |   void unsubscribe(EventListener* el, elState state = ES_ALL); | 
|---|
| 31 |   void flush(elState state); | 
|---|
| 32 |  | 
|---|
| 33 |   void process(); | 
|---|
| 34 |  | 
|---|
| 35 |  private: | 
|---|
| 36 |   EventHandler(void); | 
|---|
| 37 |   | 
|---|
| 38 |  | 
|---|
| 39 |  private: | 
|---|
| 40 |   static EventHandler* singletonRef;                  //!< the singleton reference | 
|---|
| 41 |   EventListener*** listeners;                         //!< a list of registered listeners | 
|---|
| 42 |   elState state;                                      //!< the state of the event handlder | 
|---|
| 43 |   KeyMapper* keyMapper;                               //!< reference to the key mapper | 
|---|
| 44 | }; | 
|---|
| 45 |  | 
|---|
| 46 | #endif /* _EVENT_HANDLER_H */ | 
|---|
       
      
      Note: See 
TracBrowser
        for help on using the repository browser.