My Project
EventsCenter.h
1 #pragma once
2 #include "EventHandler.h"
3 #include "util/mutex.h"
4 #include <list>
5 #include <vector>
6 
7 namespace ParaEngine
8 {
9  //class CEventHandler;
10  using namespace std;
11 
29  {
30  public:
31  CEventsCenter(void);
32  ~CEventsCenter(void);
36  static CEventsCenter* GetInstance();
37  public:
39  void Reset();
40 
53  void RegisterEvent(const string& sID, const string& sScript);
60  void RegisterEvent(DWORD nEventType, const string& sID, const string& sScript);
61 
66  void AddEventHandler(CEventHandler* pEventHandler);
67 
69  void UnregisterEvent(const string& sID);
71  void UnregisterAllEvent();
72 
82  int FireEvent(const IEvent& e);
83 
92  bool PostEvent(const Event& e, bool bUnique = true);
93 
97  void FireAllUnhandledEvents();
98  private:
99 
105  CEventHandler* GetEventHandlerByID(const string& sID);
106  void InvalidateEventCounts();
107  private:
108  typedef std::vector<Event> EventHandler_Pool_t;
109  typedef std::vector<CEventHandler*> EventHandler_List_t;
110 
112  EventHandler_Callback_t m_events[EVENT_LAST];
113 
114  EventHandler_List_t m_sEventHandlerList;
115  EventHandler_Pool_t m_unhandledEventPool;
117  int m_nMaxPoolSize;
119  int m_eventCounts[EVENT_LAST];
121  ParaEngine::mutex m_mutex;
122  };
123 
132  extern string GenerateOnMouseScript(int MouseState, int X, int Y);
138  extern string GenerateOnKeyboardScript(int option);
139 }
140 
a global pool for user registered custom events.
Definition: EventsCenter.h:28
string GenerateOnMouseScript(int MouseState, int X, int Y)
the string format is given below: mouse_button="{left|middle|right|}";mouse_x=X;mouse_y=Y; ...
Definition: EventsCenter.cpp:43
different physics engine has different winding order.
Definition: EventBinding.h:32
string GenerateOnKeyboardScript(int option)
Not implemented.
Definition: EventsCenter.cpp:90
event handler
Definition: EventHandler.h:11
the event interface
Definition: IEvent.h:8
boost::signals2::signal< void(const IEvent *, const std::string &)> EventHandler_Callback_t
sync file call back function or class.
Definition: IEvent.h:25
a general event
Definition: EventClasses.h:8
cross platform mutex
Definition: mutex.h:95