#pragma once #include "event.h" #include #include template using EventHandler = std::function; class IEventHandlerWrapper{ public: void Exec(const Event& e) { Call(e); } virtual std::string GetType() const = 0; private: virtual void Call(const Event& e) = 0; }; template class EventHandlerWrapper : public IEventHandlerWrapper { public: explicit EventHandlerWrapper(const EventHandler& handler) : m_handler(handler) , m_handlerType(m_handler.target_type().name()) {}; private: void Call(const Event& e) override { if (e.GetEventType() == EventType::GetStaticEventType()) { m_handler(static_cast(e)); } } std::string GetType() const override { return m_handlerType; } EventHandler m_handler; const std::string m_handlerType; };