28 [[nodiscard]]
virtual constexpr std::type_index
GetEventType()
const = 0;
36 [[nodiscard]]
virtual const char*
GetName()
const = 0;
71 using EventFn = std::function<bool(T&)>;
86 if (m_Event.GetEventType() == std::type_index(
typeid(T))) {
87 m_Event.m_Handled = func(*
static_cast<T*
>(&m_Event));
124#define EVENT_CLASS_TYPE(type) constexpr std::type_index GetEventType() const override { return std::type_index(typeid(type)); }\
125 const char* GetName() const override { return CORI_CLEAN_TYPE_NAME(type); }
132#define EVENT_CLASS_CATEGORY(category) uint32_t GetCategoryFlags() const override { return category; }
bool Dispatch(EventFn< T > func)
Binds dispatch function that will handle a specific Event type.
EventDispatcher(Event &event)
An abstract class that is ment to be used as a template for defining events.
virtual std::string ToString() const
Returns the name of the Event.
virtual const char * GetName() const =0
This will give you the string version of EventType.
bool IsInCategory(const EventCategory category) const
Checks if the Event is in specific category.
virtual constexpr std::type_index GetEventType() const =0
Gives the return type of the Event.
virtual uint32_t GetCategoryFlags() const =0
Gives the flags of particular Event.
friend class EventDispatcher
Core systems of the engine are here.
std::function< void(Event &)> EventCallbackFn
@ EventCategoryApplication
@ EventCategoryMouseButton
std::ostream & operator<<(std::ostream &os, const Event &e)
Needed for CoriError.
std::string format_as(const Event &e)
Needed for fmt/spadlog.