diff options
author | WBoerenkamps <wrj.boerenkamps@student.avans.nl> | 2024-11-16 13:55:47 +0100 |
---|---|---|
committer | WBoerenkamps <wrj.boerenkamps@student.avans.nl> | 2024-11-16 13:55:47 +0100 |
commit | 6e7003c73110cf9ad7e4c72de703dfdc2292d8ca (patch) | |
tree | 124818d404aab746cfd36a544f5c8241a4306b15 /src/crepe/api/EventHandler.hpp | |
parent | 337a957a9e605f16287506b6afda56950e562db3 (diff) |
added hpp files and auto
Diffstat (limited to 'src/crepe/api/EventHandler.hpp')
-rw-r--r-- | src/crepe/api/EventHandler.hpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/crepe/api/EventHandler.hpp b/src/crepe/api/EventHandler.hpp new file mode 100644 index 0000000..1b5702e --- /dev/null +++ b/src/crepe/api/EventHandler.hpp @@ -0,0 +1,25 @@ + +#include <typeindex> + +#include "EventHandler.h" + +namespace crepe { + +// Implementation of EventHandlerWrapper constructor +template <typename EventType> +EventHandlerWrapper<EventType>::EventHandlerWrapper(const EventHandler<EventType> & handler) + : m_handler(handler), m_handler_type(m_handler.target_type().name()) {} + +// Implementation of EventHandlerWrapper::call +template <typename EventType> +bool EventHandlerWrapper<EventType>::call(const Event & e) { + return m_handler(static_cast<const EventType &>(e)); +} + +// Implementation of EventHandlerWrapper::get_type +template <typename EventType> +std::string EventHandlerWrapper<EventType>::get_type() const { + return m_handler_type; +} + +} //namespace crepe |