refactored InputName
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* InputEventNotifier.cpp
|
||||
* EventNotifier.cpp
|
||||
*
|
||||
* Created on: May 17, 2018
|
||||
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert, Rafael Vinci, Dr. Franca Rupprecht
|
||||
@@ -10,41 +10,41 @@
|
||||
namespace Input
|
||||
{
|
||||
|
||||
InputEventNotifier::InputEventNotifier()
|
||||
EventNotifier::EventNotifier()
|
||||
: is_running(true)
|
||||
{
|
||||
notify_thread = std::thread(&InputEventNotifier::notify, this);
|
||||
notify_thread = std::thread(&EventNotifier::notify, this);
|
||||
}
|
||||
|
||||
InputEventNotifier::~InputEventNotifier()
|
||||
EventNotifier::~EventNotifier()
|
||||
{
|
||||
is_running = false;
|
||||
|
||||
notify_thread.join();
|
||||
}
|
||||
|
||||
void InputEventNotifier::register_input_event_handler(InputEventHandler* handler)
|
||||
void EventNotifier::register_event_handler(EventHandler* handler)
|
||||
{
|
||||
std::lock_guard<std::mutex> event_handler_guard(event_handler_mutex);
|
||||
event_handler.insert(handler);
|
||||
}
|
||||
|
||||
void InputEventNotifier::unregister_input_event_handler(InputEventHandler* handler)
|
||||
void EventNotifier::unregister_event_handler(EventHandler* handler)
|
||||
{
|
||||
std::lock_guard<std::mutex> event_handler_guard(event_handler_mutex);
|
||||
event_handler.erase(handler);
|
||||
}
|
||||
|
||||
void InputEventNotifier::distribute_event(InputEvent& event)
|
||||
void EventNotifier::distribute_event(Event& event)
|
||||
{
|
||||
event_queue.push(event);
|
||||
}
|
||||
|
||||
void InputEventNotifier::notify()
|
||||
void EventNotifier::notify()
|
||||
{
|
||||
while(is_running)
|
||||
{
|
||||
InputEvent event = event_queue.pop();
|
||||
Event event = event_queue.pop();
|
||||
|
||||
// getting a guard and calling all registered handlers
|
||||
std::lock_guard<std::mutex> event_handler_guard(event_handler_mutex);
|
||||
|
||||
Reference in New Issue
Block a user