GUI
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 
26 {
27  public:
28  typedef std::multimap<EventType, EventListener> Map;
29 
30  EventEmitter();
31  virtual ~EventEmitter();
32 
38  void setQueue(AddToQueue addFunction);
39 
47 
52  void removeEventListener(EventListener::Id listenerId);
53 
58  void emitEvent(Event& event);
59 
60  protected:
62 
63  private:
64  struct MapPredicate : public std::unary_function<EventListener, bool>
65  {
67 
68  bool operator() (Map::value_type value)
69  {
70  return value.second.id == id;
71  }
72 
74  };
75 
77  AddToQueue addToQueue;
79 
80  friend class EventQueue;
81 };
82 
83 }
84 
85 #endif // EVENTEMITTER_H