ShishGL  1.0
A simple modular cross-platform graphics library
EventManager.hpp
Go to the documentation of this file.
1 /*============================================================================*/
2 #ifndef SHISHGL_EVENT_MANAGER_HPP
3 #define SHISHGL_EVENT_MANAGER_HPP
4 /*============================================================================*/
5 #include <type_traits>
6 #include <queue>
7 
8 #include "Event.hpp"
9 /*============================================================================*/
10 namespace Sh {
11 
12  class EventManager {
13  private:
14 
15  template <typename SomeEvent, typename T>
16  using Helper =
17  std::enable_if_t<std::is_base_of<Event, SomeEvent>::value, T>;
18 
19  public:
20 
21  template <typename SomeEvent, typename... Args>
22  static Helper<SomeEvent, void> postEvent(Args&&... args);
23 
24  virtual ~EventManager() = default;
25 
26  private:
27 
28  EventManager() = default;
29 
30  using EventQueue = std::queue<Event*>;
31 
32  static EventQueue& Events();
33 
34  static void flush();
35 
36  friend class EventSystem;
37  friend class CoreApplication;
38  };
39 
40 }
41 /*============================================================================*/
42 #include "EventManager.ipp"
43 /*============================================================================*/
44 #endif //SHISHGL_EVENT_MANAGER_HPP
45 /*============================================================================*/
Sh::CoreApplication
Definition: CoreApplication.hpp:15
Sh::EventManager::postEvent
static Helper< SomeEvent, void > postEvent(Args &&... args)
Definition: EventManager.ipp:9
EventManager.ipp
Event.hpp
Sh::EventManager
Definition: EventManager.hpp:12
Sh::EventSystem
Definition: EventSystem.hpp:9
Sh
Definition: CoreApplication.hpp:10
Sh::EventManager::~EventManager
virtual ~EventManager()=default