GUI
include
EventEmitter.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2017 by Maciej Wiecierzewski
3
*/
4
5
#ifndef EVENTEMITTER_H
6
#define EVENTEMITTER_H
7
8
#include <string>
9
#include <functional>
10
#include <map>
11
12
#include "
Event.h
"
13
#include "
EventListener.h
"
14
#include "
events.h
"
15
16
namespace
gui
17
{
18
19
class
GUISystem
;
20
21
typedef
std::function<void(Event&&, EventListener)>
AddToQueue
;
22
24
25
class
EventEmitter
26
{
27
public
:
28
typedef
std::multimap<EventType, EventListener>
Map
;
29
30
EventEmitter
();
31
virtual
~EventEmitter
();
32
38
void
setQueue
(AddToQueue addFunction);
39
46
EventListener::Id
addEventListener
(
EventType
eventType,
EventListener::Function
listenerFunc);
47
52
void
removeEventListener
(
EventListener::Id
listenerId);
53
58
void
emitEvent
(
Event
& event);
59
60
protected
:
61
GUISystem
*
guiSystem
;
62
63
private
:
64
struct
MapPredicate
:
public
std::unary_function<EventListener, bool>
65
{
66
MapPredicate
(
EventListener::Id
id
) : id(id) {}
67
68
bool
operator()
(Map::value_type value)
69
{
70
return
value.second.id ==
id
;
71
}
72
73
EventListener::Id
id
;
74
};
75
76
Map
eventListeners
;
77
AddToQueue
addToQueue
;
78
int
lastListenerId
;
79
80
friend
class
EventQueue
;
81
};
82
83
}
84
85
#endif // EVENTEMITTER_H
Generated on Sat Feb 11 2017 20:22:31 for GUI by
1.8.13