gaze  0.1.0
Perform gaze tracking with common webcams.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
event_manager.cpp
1 #include "gaze/gui/event_manager.h"
2 
3 #include <vector>
4 
5 #include "dlib/gui_core.h"
6 
7 
8 namespace gaze {
9 
10 namespace gui {
11 
12 EventManager::EventManager() {
13 }
14 
16  static EventManager event_manager;
17  return event_manager;
18 }
19 
20 void EventManager::publish(void* data, Events event) {
21  for (dlib::base_window* subscriber : this->subscribers) {
22  subscriber->trigger_user_event(data, event);
23  }
24 }
25 
26 void EventManager::subscribe(dlib::base_window* subscriber) {
27  this->subscribers.push_back(subscriber);
28 }
29 
30 void EventManager::unsubscribe(dlib::base_window* subscriber) {
31  this->subscribers.erase(
32  std::remove(this->subscribers.begin(),
33  this->subscribers.end(),
34  subscriber),
35  this->subscribers.end());
36 }
37 
38 } // namespace gui
39 
40 } // namespace gaze
41 
42 
static EventManager & instance()
iterator erase(const_iterator __position)
void publish(void *data, Events event)
_ForwardIterator remove(_ForwardIterator __first, _ForwardIterator __last, const _Tp &__value)
void unsubscribe(dlib::base_window *subscriber)
iterator end() noexcept
Handles communication between non-gui and gui processes in a safe way.
Definition: event_manager.h:37
iterator begin() noexcept
void push_back(const value_type &__x)
void subscribe(dlib::base_window *subscriber)
An enum of events to make it easy to distinguish them with names instead of numbers.