59 lines
1.1 KiB
C++
59 lines
1.1 KiB
C++
/*
|
|
* InputEventNotifier.h
|
|
*
|
|
* Created on: May 17, 2018
|
|
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert
|
|
*/
|
|
|
|
#ifndef INPUT_IMPL_EVENTNOTIFIER_H_
|
|
#define INPUT_IMPL_EVENTNOTIFIER_H_
|
|
|
|
#include <set>
|
|
#include <thread>
|
|
#include <mutex>
|
|
|
|
#include "input/EventNotifier.h"
|
|
|
|
#include "input/Event.h"
|
|
#include "input/EventHandler.h"
|
|
|
|
#include "utility/BlockingQueue.hpp"
|
|
#include "utility/IBlockingQueue.h"
|
|
|
|
|
|
namespace flippR_driver
|
|
{
|
|
namespace input
|
|
{
|
|
namespace detail
|
|
{
|
|
|
|
class EventNotifier : public input::EventNotifier
|
|
{
|
|
|
|
public:
|
|
explicit EventNotifier(utility::IBlockingQueue<Event> *queue);
|
|
~EventNotifier() override;
|
|
|
|
void register_event_handler(std::shared_ptr<EventHandler> handler) override;
|
|
void unregister_event_handler(std::shared_ptr<EventHandler> handler) override;
|
|
|
|
void distribute_event(const Event &event) override;
|
|
|
|
private:
|
|
void notify();
|
|
|
|
private:
|
|
utility::IBlockingQueue<Event> *event_queue;
|
|
std::set<std::shared_ptr<EventHandler>> event_handlers;
|
|
|
|
bool is_running;
|
|
std::thread notify_thread;
|
|
std::mutex event_handler_mutex;
|
|
};
|
|
|
|
}
|
|
}
|
|
}
|
|
#endif
|