CoriEngine
Loading...
Searching...
No Matches
Event.hpp File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  Cori::Core::Event
 An abstract class that is ment to be used as a template for defining events. More...
class  Cori::Core::EventDispatcher
 Used in OnEvent methods to dispatch and handle Events. More...

Namespaces

namespace  Cori
 Global engine namespace.
namespace  Cori::Core
 Core systems of the engine are here.

Macros

#define EVENT_CLASS_TYPE(type)
 Assigns an EventType to the custom event type derived from the Event class. Use it in the public field of the derived class.
#define EVENT_CLASS_CATEGORY(category)
 Assigns an EventCategory to the custom event type derived from the Event class. Use it in the public field of the derived class.

Typedefs

using Cori::Core::EventCallbackFn = std::function<void(Event&)>

Enumerations

enum  Cori::Core::EventCategory {
  Cori::Core::None = 0 , Cori::Core::EventCategoryApplication = 1 << 0 , Cori::Core::EventCategoryGameplay = 1 << 1 , Cori::Core::EventCategoryInput = 1 << 2 ,
  Cori::Core::EventCategoryKeyboard = 1 << 3 , Cori::Core::EventCategoryMouse = 1 << 4 , Cori::Core::EventCategoryMouseButton = 1 << 5
}

Functions

std::ostream & Cori::Core::operator<< (std::ostream &os, const Event &e)
 Needed for CoriError.
std::string Cori::Core::format_as (const Event &e)
 Needed for fmt/spadlog.

Macro Definition Documentation

◆ EVENT_CLASS_CATEGORY

#define EVENT_CLASS_CATEGORY ( category)
Value:
uint32_t GetCategoryFlags() const override { return category; }

Assigns an EventCategory to the custom event type derived from the Event class. Use it in the public field of the derived class.

Note
Several EventCategories can be assigned to the derived class using an bitwise or operator.
Parameters
categoryEventCategories to be assigned.

Definition at line 132 of file Event.hpp.

◆ EVENT_CLASS_TYPE

#define EVENT_CLASS_TYPE ( type)
Value:
constexpr std::type_index GetEventType() const override { return std::type_index(typeid(type)); }\
const char* GetName() const override { return CORI_CLEAN_TYPE_NAME(type); }
#define CORI_CLEAN_TYPE_NAME(tn)

Assigns an EventType to the custom event type derived from the Event class. Use it in the public field of the derived class.

Parameters
typeDerived from Event typename. @detals Example:
class PlayerDied final : public Cori::Core::Event
EVENT_CLASS_TYPE(PlayerDied)

Definition at line 124 of file Event.hpp.