gaze  0.1.0
Perform gaze tracking with common webcams.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
Public Member Functions | Static Public Member Functions | List of all members
gaze::gui::EventManager Class Reference

Handles communication between non-gui and gui processes in a safe way. More...

#include "gaze/gui/event_manager.h"

Public Member Functions

void publish (void *data, Events event)
 
void subscribe (dlib::base_window *subscriber)
 
void unsubscribe (dlib::base_window *subscriber)
 

Static Public Member Functions

static EventManagerinstance ()
 

Detailed Description

Handles communication between non-gui and gui processes in a safe way.

This EventManager performs no sophisticated distinction about subcribers to specific events, from specific callers, etc., instead it just passes all published events to all subscribers.

Note
The EventManager is implemented as a singleton, it should be accessed via EventManager::instance().

Definition at line 37 of file event_manager.h.

Member Function Documentation

EventManager & gaze::gui::EventManager::instance ( )
static
Returns
a reference to a global static instance of the event manager.

Definition at line 15 of file event_manager.cpp.

Referenced by gaze::gui::DebugWindow::DebugWindow().

15  {
16  static EventManager event_manager;
17  return event_manager;
18 }
void gaze::gui::EventManager::publish ( void *  data,
Events  event 
)

Publishes an event with the given data to all subscribers using dlib::base_window::trigger_user_event(void*,int).

Parameters
datathe data to pass along
eventthe event identifier

Definition at line 20 of file event_manager.cpp.

20  {
21  for (dlib::base_window* subscriber : this->subscribers) {
22  subscriber->trigger_user_event(data, event);
23  }
24 }
void gaze::gui::EventManager::subscribe ( dlib::base_window *  subscriber)

Subscribes the new subscriber to all events.

Parameters
subscriberThe new subscriber.

Definition at line 26 of file event_manager.cpp.

References std::vector< _Tp, _Alloc >::push_back().

Referenced by gaze::gui::DebugWindow::DebugWindow().

26  {
27  this->subscribers.push_back(subscriber);
28 }
void push_back(const value_type &__x)
void gaze::gui::EventManager::unsubscribe ( dlib::base_window *  subscriber)

Unsubscribes the subscriber from all events.

Parameters
subscriberThe unsubscriber.

Definition at line 30 of file event_manager.cpp.

References std::vector< _Tp, _Alloc >::begin(), std::vector< _Tp, _Alloc >::end(), std::vector< _Tp, _Alloc >::erase(), and std::remove().

30  {
31  this->subscribers.erase(
32  std::remove(this->subscribers.begin(),
33  this->subscribers.end(),
34  subscriber),
35  this->subscribers.end());
36 }
iterator erase(const_iterator __position)
_ForwardIterator remove(_ForwardIterator __first, _ForwardIterator __last, const _Tp &__value)
iterator end() noexcept
iterator begin() noexcept

The documentation for this class was generated from the following files: