meeeerged
This commit is contained in:
@@ -18,6 +18,7 @@ namespace Input
|
||||
|
||||
class Event
|
||||
{
|
||||
|
||||
public:
|
||||
Event(char address, char priority, std::string name) :
|
||||
address(address), priority(priority), name(name)
|
||||
@@ -30,15 +31,16 @@ public:
|
||||
return this->name == other.name;
|
||||
}
|
||||
|
||||
bool operator<(const Event& other)
|
||||
friend bool operator<(const Event& left, const Event& right)
|
||||
{
|
||||
return this->priority < other.priority;
|
||||
return left.priority < right.priority;
|
||||
}
|
||||
|
||||
private:
|
||||
const char address;
|
||||
const char priority;
|
||||
const std::string name;
|
||||
char address;
|
||||
char priority;
|
||||
std::string name;
|
||||
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -12,13 +12,20 @@
|
||||
#ifndef INPUTEVENTHANDLER_H_
|
||||
#define INPUTEVENTHANDLER_H_
|
||||
|
||||
#include "InputDriver.hpp"
|
||||
#include "Event.hpp"
|
||||
#include "Detector.h"
|
||||
#include "../utilities/config.h"
|
||||
|
||||
#include "Event.hpp"
|
||||
|
||||
namespace Input
|
||||
{
|
||||
class EventHandler;
|
||||
|
||||
class InputDriver
|
||||
{
|
||||
public:
|
||||
void register_event_handler(EventHandler* handler);
|
||||
void unregister_event_handler(EventHandler* handler);
|
||||
};
|
||||
|
||||
class EventHandler
|
||||
{
|
||||
|
||||
@@ -56,7 +56,7 @@ void EventNotifier::notify()
|
||||
std::lock_guard<std::mutex> event_handler_guard(event_handler_mutex);
|
||||
for(auto handler : event_handler)
|
||||
{
|
||||
boost::thread handler_caller(handler, &EventHandler::handle, event);
|
||||
boost::thread handler_caller(boost::bind(&EventHandler::handle, handler, event));
|
||||
|
||||
if(!handler_caller.timed_join(boost::posix_time::milliseconds(HANDLER_TIMEOUT)))
|
||||
{
|
||||
|
||||
@@ -4,25 +4,18 @@
|
||||
* Created on: May 31, 2018
|
||||
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert, Rafael Vinci, Dr. Franca Rupprecht
|
||||
*/
|
||||
|
||||
#include "../utilities/config.h"
|
||||
#include "Detector.h"
|
||||
|
||||
|
||||
#ifndef SRC_INPUT_INPUTDRIVER_HPP_
|
||||
#define SRC_INPUT_INPUTDRIVER_HPP_
|
||||
|
||||
#include "../utilities/config.h"
|
||||
|
||||
#include "EventHandler.h"
|
||||
#include "EventNotifier.h"
|
||||
#include "Detector.h"
|
||||
|
||||
namespace Input
|
||||
{
|
||||
|
||||
class EventHandler
|
||||
{
|
||||
public:
|
||||
void handle(Event& event);
|
||||
};
|
||||
|
||||
class InputDriver
|
||||
{
|
||||
|
||||
|
||||
Reference in New Issue
Block a user