#pragma once #include #include #include #include "Event.h" template using EventHandler = std::function; class IEventHandlerWrapper { public: virtual ~IEventHandlerWrapper() = default; bool exec(const Event & e); virtual std::string get_type() const = 0; private: virtual bool call(const Event & e) = 0; }; template class EventHandlerWrapper : public IEventHandlerWrapper { public: explicit EventHandlerWrapper(const EventHandler & handler) : m_handler(handler), m_handler_type(m_handler.target_type().name()) { } private: bool call(const Event & e) override { return m_handler(static_cast(e)); } std::string get_type() const override { return m_handler_type; } EventHandler m_handler; const std::string m_handler_type; };