Enigma
3.2.2
A Simple, Reliable and Efficient Encryption Tool
Loading...
Searching...
No Matches
EventDispatcher.hpp
Go to the documentation of this file.
1
#pragma once
2
#ifndef ENIGMA_EVENT_DISPATCHER_H
3
#define ENIGMA_EVENT_DISPATCHER_H
4
5
#include <
Core/Core.hpp
>
6
#include <
Core/Types.hpp
>
7
8
#include <functional>
9
10
#include "
Event.hpp
"
11
12
NS_ENIGMA_BEGIN
13
15
class
EventDispatcher
{
16
template
<
typename
T>
17
using
EventFun = std::function<bool(
T
&)>;
18
19
public
:
20
explicit
EventDispatcher
(
Event
& event)
21
: m_event(event) {
22
}
23
24
template
<
typename
T>
25
bool
Dispatch
(EventFun<T> func) {
26
if
(m_event.
GetEventType
() == T::GetStaticType()) {
27
m_event.
SetHandled
(func(*(
T
*) &m_event));
28
return
true
;
29
}
30
return
false
;
31
}
32
33
private
:
34
Event
& m_event;
35
};
36
NS_ENIGMA_END
37
38
#endif
// !ENIGMA_EVENT_DISPATCHER_H
Core.hpp
Event.hpp
KeyCode::T
@ T
NS_ENIGMA_BEGIN
#define NS_ENIGMA_BEGIN
Enable/Disable Assertions.
Definition
Macros.hpp:13
NS_ENIGMA_END
#define NS_ENIGMA_END
Definition
Macros.hpp:14
Types.hpp
EventDispatcher
Definition
EventDispatcher.hpp:15
EventDispatcher::Dispatch
bool Dispatch(EventFun< T > func)
Definition
EventDispatcher.hpp:25
EventDispatcher::EventDispatcher
EventDispatcher(Event &event)
Definition
EventDispatcher.hpp:20
Event
Definition
Event.hpp:66
Event::SetHandled
void SetHandled(const bool handled) noexcept
Definition
Event.hpp:78
Event::GetEventType
virtual EventType GetEventType() const =0
src
Events
EventDispatcher.hpp
Generated on Sat Apr 12 2025 16:55:01 for Enigma by
1.9.8