40 return os <<
event.to_string();
49 template<
typename T,
typename F>
51 if (m_event.
getType() == T::getStaticType()) {
52 m_event.
m_handled = func(
static_cast<T&
>(m_event));
61#define EVENT_CLASS_TYPE(type) static EventType getStaticType() { return EventType::type; } \
62 EventType getType() const override { return getStaticType(); } \
63 const char* getName() const override { return #type; }
EventDispatcher(Event &event)
Definition: event.hpp:46
bool dispatch(const F &func)
Definition: event.hpp:50
bool isHandled() const
Definition: event.hpp:31
virtual std::string to_string() const
Definition: event.hpp:30
virtual EventType getType() const =0
virtual const char * getName() const =0
bool m_handled
Definition: event.hpp:33
constexpr Code T
Definition: key_codes.hpp:56
constexpr Code F
Definition: key_codes.hpp:42
std::ostream & operator<<(std::ostream &os, const Event &event)
Definition: event.hpp:38
EventType
Definition: event.hpp:15