working on big refactor
This commit is contained in:
@@ -8,13 +8,13 @@
|
||||
#include <istream>
|
||||
#include <memory>
|
||||
|
||||
#include "input/IInputDriver.h"
|
||||
#include "output/IOutputDriver.h"
|
||||
#include "input/InputDriver.h"
|
||||
#include "output/OutputDriver.h"
|
||||
|
||||
namespace flippR_driver
|
||||
{
|
||||
std::shared_ptr<input::IInputDriver> get_InputDriver(std::istream& input_config_stream, std::istream& matrix_config_stream);
|
||||
std::shared_ptr<output::IOutputDriver> get_OutputDriver(std::istream &output_pin_config,
|
||||
std::shared_ptr<input::InputDriver> get_InputDriver(std::istream& input_config_stream, std::istream& matrix_config_stream);
|
||||
std::shared_ptr<output::OutputDriver> get_OutputDriver(std::istream &output_pin_config,
|
||||
std::istream &lamp_config,
|
||||
std::istream &solenoid_config,
|
||||
std::istream &sound_config,
|
||||
|
||||
@@ -13,30 +13,30 @@
|
||||
#include <chrono>
|
||||
|
||||
namespace flippR_driver {
|
||||
namespace input {
|
||||
namespace input {
|
||||
|
||||
class Event {
|
||||
public:
|
||||
Event(char address, int priority, std::string name);
|
||||
class Event {
|
||||
public:
|
||||
Event(uint8_t 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;
|
||||
uint8_t address;
|
||||
int priority;
|
||||
std::chrono::time_point<std::chrono::high_resolution_clock> last_activation;
|
||||
|
||||
};
|
||||
|
||||
bool operator==(const Event &left, const Event &right);
|
||||
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;
|
||||
uint8_t address;
|
||||
int priority;
|
||||
std::chrono::time_point<std::chrono::high_resolution_clock> last_activation;
|
||||
|
||||
};
|
||||
|
||||
bool operator==(const Event &left, const Event &right);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
#endif /* INPUTEVENT_H_ */
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* IEventHandler.h
|
||||
* EventHandler.h
|
||||
*
|
||||
* Created on: Jun 13, 2018
|
||||
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert
|
||||
@@ -10,12 +10,19 @@
|
||||
|
||||
#include "input/Event.h"
|
||||
|
||||
class IEventHandler
|
||||
namespace flippR_driver
|
||||
{
|
||||
namespace input
|
||||
{
|
||||
|
||||
class EventHandler
|
||||
{
|
||||
public:
|
||||
virtual ~IEventHandler(){};
|
||||
virtual ~EventHandler() = default;
|
||||
|
||||
virtual void handle(flippR_driver::input::Event& event) = 0;
|
||||
virtual void handle(flippR_driver::input::Event &event) = 0;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
#endif /* SRC_IEVENTHANDLER_H_ */
|
||||
@@ -1,32 +0,0 @@
|
||||
/*
|
||||
* IInputDriver.h
|
||||
*
|
||||
* Created on: Jun 14, 2018
|
||||
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert
|
||||
*/
|
||||
|
||||
#ifndef SRC_INPUT_IINPUTDRIVER_H_
|
||||
#define SRC_INPUT_IINPUTDRIVER_H_
|
||||
|
||||
#include <memory>
|
||||
#include <boost/optional.hpp>
|
||||
|
||||
#include "input/IEventHandler.h"
|
||||
|
||||
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 boost::optional<std::shared_ptr<Event>> get_event(std::string name) = 0;
|
||||
};
|
||||
}
|
||||
}
|
||||
#endif /* SRC_INPUT_IINPUTDRIVER_H_ */
|
||||
34
FlippR-Driver/include/input/InputDriver.h
Normal file
34
FlippR-Driver/include/input/InputDriver.h
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* InputDriver.h
|
||||
*
|
||||
* Created on: Jun 14, 2018
|
||||
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert
|
||||
*/
|
||||
|
||||
#ifndef SRC_INPUT_IINPUTDRIVER_H_
|
||||
#define SRC_INPUT_IINPUTDRIVER_H_
|
||||
|
||||
#include <memory>
|
||||
#include <boost/optional.hpp>
|
||||
|
||||
#include "input/EventHandler.h"
|
||||
|
||||
namespace flippR_driver
|
||||
{
|
||||
namespace input
|
||||
{
|
||||
|
||||
class InputDriver {
|
||||
public:
|
||||
virtual ~InputDriver() = default;
|
||||
|
||||
virtual void register_event_handler(EventHandler *handler) = 0;
|
||||
|
||||
virtual void unregister_event_handler(EventHandler *handler) = 0;
|
||||
|
||||
virtual boost::optional<std::shared_ptr<Event>> get_event(std::string name) = 0;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
#endif /* SRC_INPUT_IINPUTDRIVER_H_ */
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* IOutputDriver.h
|
||||
* OutputDriver.h
|
||||
*
|
||||
* Created on: Aug 2, 2018
|
||||
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert
|
||||
@@ -22,10 +22,10 @@ namespace flippR_driver
|
||||
namespace output
|
||||
{
|
||||
|
||||
class IOutputDriver
|
||||
class OutputDriver
|
||||
{
|
||||
public:
|
||||
virtual ~IOutputDriver() = default;
|
||||
virtual ~OutputDriver() = default;
|
||||
|
||||
virtual std::vector<std::shared_ptr<items::ILamp>> get_lamps() = 0;
|
||||
virtual std::vector<std::shared_ptr<items::ISolenoid>> get_solenoids() = 0;
|
||||
Reference in New Issue
Block a user