aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/api/EventHandler.hpp
blob: 9c47da242301637a88e8f235413a0447c014a231 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#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