some refactoring
This commit is contained in:
40
FlippR-Driver/include/input/Event.h
Normal file
40
FlippR-Driver/include/input/Event.h
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* InputEvent.h
|
||||
*
|
||||
* Created on: Apr 5, 2018
|
||||
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert, Rafael Vinci, Dr. Franca Rupprecht
|
||||
*/
|
||||
|
||||
#ifndef INPUTEVENT_H_
|
||||
#define INPUTEVENT_H_
|
||||
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <chrono>
|
||||
|
||||
namespace flippR_driver {
|
||||
namespace input {
|
||||
|
||||
class Event {
|
||||
public:
|
||||
Event(char address, int priority, std::string name);
|
||||
|
||||
friend bool operator==(const Event &left, const Event &right);
|
||||
|
||||
friend bool operator<(const Event &left, const Event &right) {
|
||||
return left.priority < right.priority;
|
||||
}
|
||||
|
||||
|
||||
public:
|
||||
std::string name;
|
||||
char address;
|
||||
int priority;
|
||||
};
|
||||
|
||||
bool operator==(const Event &left, const Event &right);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
#endif /* INPUTEVENT_H_ */
|
||||
40
FlippR-Driver/include/input/EventHandler.h
Normal file
40
FlippR-Driver/include/input/EventHandler.h
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* InputEventHandler.h
|
||||
*
|
||||
* This interface must be implemented to be informed about input events.
|
||||
*
|
||||
* Please be aware that handle must be implemented thread safe!
|
||||
*
|
||||
* Created on: Apr 5, 2018
|
||||
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert, Rafael Vinci, Dr. Franca Rupprecht
|
||||
*/
|
||||
|
||||
#ifndef INPUTEVENTHANDLER_H_
|
||||
#define INPUTEVENTHANDLER_H_
|
||||
|
||||
#include "IInputDriver.h"
|
||||
|
||||
#include "IEventHandler.h"
|
||||
#include "input/Event.h"
|
||||
|
||||
namespace flippR_driver
|
||||
{
|
||||
namespace input
|
||||
{
|
||||
class EventHandler;
|
||||
|
||||
class EventHandler : public IEventHandler
|
||||
{
|
||||
public:
|
||||
EventHandler(std::shared_ptr<IInputDriver> input_driver);
|
||||
virtual ~EventHandler();
|
||||
virtual void handle(Event& event);
|
||||
|
||||
private:
|
||||
std::shared_ptr<IInputDriver> input_driver;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
21
FlippR-Driver/include/input/IEventHandler.h
Normal file
21
FlippR-Driver/include/input/IEventHandler.h
Normal file
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* IEventHandler.h
|
||||
*
|
||||
* Created on: Jun 13, 2018
|
||||
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert, Rafael Vinci, Dr. Franca Rupprecht
|
||||
*/
|
||||
|
||||
#ifndef SRC_IEVENTHANDLER_H_
|
||||
#define SRC_IEVENTHANDLER_H_
|
||||
|
||||
#include "input/Event.h"
|
||||
|
||||
class IEventHandler
|
||||
{
|
||||
public:
|
||||
virtual ~IEventHandler(){};
|
||||
|
||||
virtual void handle(flippR_driver::input::Event& event) = 0;
|
||||
};
|
||||
|
||||
#endif /* SRC_IEVENTHANDLER_H_ */
|
||||
30
FlippR-Driver/include/input/IInputDriver.h
Normal file
30
FlippR-Driver/include/input/IInputDriver.h
Normal file
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* IInputDriver.h
|
||||
*
|
||||
* Created on: Jun 14, 2018
|
||||
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert, Rafael Vinci, Dr. Franca Rupprecht
|
||||
*/
|
||||
|
||||
#ifndef SRC_INPUT_IINPUTDRIVER_H_
|
||||
#define SRC_INPUT_IINPUTDRIVER_H_
|
||||
|
||||
#include "input/IEventHandler.h"
|
||||
#include <memory>
|
||||
|
||||
namespace flippR_driver
|
||||
{
|
||||
namespace input
|
||||
{
|
||||
class IInputDriver {
|
||||
public:
|
||||
virtual ~IInputDriver() {};
|
||||
|
||||
virtual void register_event_handler(IEventHandler *handler) = 0;
|
||||
|
||||
virtual void unregister_event_handler(IEventHandler *handler) = 0;
|
||||
|
||||
virtual std::shared_ptr<Event> get_event(std::string name) = 0;
|
||||
};
|
||||
}
|
||||
}
|
||||
#endif /* SRC_INPUT_IINPUTDRIVER_H_ */
|
||||
Reference in New Issue
Block a user