refactored inputfactory
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#include "DriverFactory.h"
|
#include "DriverFactory.h"
|
||||||
|
|
||||||
#include "input/InputDriverFactory.h"
|
#include "input/InputDriverFactory.h"
|
||||||
|
|
||||||
namespace flippR_driver
|
namespace flippR_driver
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
#include "Detector.h"
|
#include "Detector.h"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <math.h>
|
|
||||||
|
|
||||||
#include "utility/config.h"
|
#include "utility/config.h"
|
||||||
|
|
||||||
|
|||||||
@@ -7,8 +7,7 @@
|
|||||||
#include "InputDriver.h"
|
#include "InputDriver.h"
|
||||||
|
|
||||||
#include "utility/config.h"
|
#include "utility/config.h"
|
||||||
|
#include "ErrorEvent.hpp"
|
||||||
#include <input/ErrorEvent.hpp>
|
|
||||||
|
|
||||||
namespace flippR_driver
|
namespace flippR_driver
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -14,9 +14,7 @@
|
|||||||
|
|
||||||
#include "InputDriver.h"
|
#include "InputDriver.h"
|
||||||
#include "EventNotifier.h"
|
#include "EventNotifier.h"
|
||||||
|
#include "Detector.h"
|
||||||
using namespace nlohmann;
|
|
||||||
using namespace flippR_driver::utility;
|
|
||||||
|
|
||||||
namespace flippR_driver
|
namespace flippR_driver
|
||||||
{
|
{
|
||||||
@@ -25,8 +23,10 @@ namespace input
|
|||||||
namespace InputDriverFactory
|
namespace InputDriverFactory
|
||||||
{
|
{
|
||||||
|
|
||||||
std::shared_ptr<IInputDriver>
|
using namespace nlohmann;
|
||||||
get_InputDriver(std::istream &input_config_stream, std::istream &matrix_config_stream)
|
using namespace flippR_driver::utility;
|
||||||
|
|
||||||
|
std::shared_ptr<IInputDriver> get_InputDriver(std::istream& input_config_stream, std::istream& matrix_config_stream)
|
||||||
{
|
{
|
||||||
LoggerFactory::CreateInputLogger();
|
LoggerFactory::CreateInputLogger();
|
||||||
|
|
||||||
@@ -38,16 +38,17 @@ get_InputDriver(std::istream &input_config_stream, std::istream &matrix_config_s
|
|||||||
|
|
||||||
json matrix_config;
|
json matrix_config;
|
||||||
matrix_config_stream >> matrix_config;
|
matrix_config_stream >> matrix_config;
|
||||||
create_input_events(matrix_config, events, name_event_map, event_notifier);
|
create_events(matrix_config, events, name_event_map, event_notifier);
|
||||||
|
|
||||||
std::unique_ptr<IInputGPIOInterface> input_gpio_interface(new InputGPIOInterface(input_config_stream));
|
std::unique_ptr<IInputGPIOInterface> input_gpio_interface(new InputGPIOInterface(input_config_stream));
|
||||||
std::unique_ptr<IDetector> detector(new Detector(std::move(input_gpio_interface), events));
|
std::unique_ptr<IDetector> detector(new Detector(std::move(input_gpio_interface), events));
|
||||||
|
|
||||||
return std::shared_ptr<InputDriver>(new InputDriver(event_notifier, std::move(detector), name_event_map));
|
return std::shared_ptr<InputDriver>(new InputDriver(event_notifier, std::move(detector), name_event_map));
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
void create_input_events(json matrix_config, std::vector<std::shared_ptr<DistributingEvent>> &events,
|
void create_events(json matrix_config, std::vector<std::shared_ptr<DistributingEvent>> &events,
|
||||||
std::map<std::string, std::shared_ptr<Event>> &name_event_map,
|
std::map<std::string, std::shared_ptr<Event>> &name_event_map,
|
||||||
std::shared_ptr<IEventNotifier> event_notifier)
|
std::shared_ptr<IEventNotifier> event_notifier)
|
||||||
{
|
{
|
||||||
@@ -62,7 +63,7 @@ namespace
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::shared_ptr<DistributingEvent> create_event(json &json_event, std::shared_ptr<IEventNotifier> event_notifier, int bounce_time)
|
std::shared_ptr<DistributingEvent> create_event(json &json_event, std::shared_ptr<IEventNotifier> event_notifier, int bounce_time)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -81,7 +82,7 @@ namespace
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void set_individual_bounce_time(json &json_event, int &bounce_time)
|
void set_individual_bounce_time(json &json_event, int &bounce_time)
|
||||||
{
|
{
|
||||||
auto it_bounce_time = json_event.find("bounce_time");
|
auto it_bounce_time = json_event.find("bounce_time");
|
||||||
|
|
||||||
@@ -95,4 +96,3 @@ namespace
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|||||||
@@ -9,15 +9,11 @@
|
|||||||
#define INPUTFACTORY_H_
|
#define INPUTFACTORY_H_
|
||||||
|
|
||||||
#include <istream>
|
#include <istream>
|
||||||
#include <atomic>
|
|
||||||
|
|
||||||
#include <boost/optional.hpp>
|
|
||||||
|
|
||||||
#include "Detector.h"
|
|
||||||
#include "input/IInputDriver.h"
|
|
||||||
|
|
||||||
#include "InputGPIOInterface.h"
|
|
||||||
#include "json/json.hpp"
|
#include "json/json.hpp"
|
||||||
|
|
||||||
|
#include "input/IInputDriver.h"
|
||||||
|
#include "DistributingEvent.h"
|
||||||
|
#include "InputGPIOInterface.h"
|
||||||
#include "IEventNotifier.h"
|
#include "IEventNotifier.h"
|
||||||
|
|
||||||
namespace flippR_driver
|
namespace flippR_driver
|
||||||
@@ -26,11 +22,11 @@ namespace input
|
|||||||
{
|
{
|
||||||
namespace InputDriverFactory
|
namespace InputDriverFactory
|
||||||
{
|
{
|
||||||
static std::shared_ptr<IInputDriver> get_InputDriver(std::istream& input_config_stream, std::istream& matrix_config_stream);
|
std::shared_ptr<IInputDriver> get_InputDriver(std::istream& input_config_stream, std::istream& matrix_config_stream);
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
static void create_input_events(nlohmann::json matrix_config,
|
static void create_events(nlohmann::json matrix_config,
|
||||||
std::vector<std::shared_ptr<DistributingEvent>> &events,
|
std::vector<std::shared_ptr<DistributingEvent>> &events,
|
||||||
std::map<std::string, std::shared_ptr<Event>> &name_event_map,
|
std::map<std::string, std::shared_ptr<Event>> &name_event_map,
|
||||||
std::shared_ptr<IEventNotifier> event_notifier);
|
std::shared_ptr<IEventNotifier> event_notifier);
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "DisplayController.h"
|
#include "DisplayController.h"
|
||||||
#include "IOutputGPIOInterface.h"
|
|
||||||
|
|
||||||
#include "utility/config.h"
|
#include "utility/config.h"
|
||||||
|
|
||||||
|
|||||||
@@ -7,8 +7,6 @@
|
|||||||
|
|
||||||
#include "Solenoid.h"
|
#include "Solenoid.h"
|
||||||
|
|
||||||
#include <thread>
|
|
||||||
|
|
||||||
namespace flippR_driver
|
namespace flippR_driver
|
||||||
{
|
{
|
||||||
namespace output
|
namespace output
|
||||||
|
|||||||
@@ -7,8 +7,6 @@
|
|||||||
|
|
||||||
#include "Sound.h"
|
#include "Sound.h"
|
||||||
|
|
||||||
#include <thread>
|
|
||||||
|
|
||||||
namespace flippR_driver
|
namespace flippR_driver
|
||||||
{
|
{
|
||||||
namespace output
|
namespace output
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
#include "InputSocketHandler.h"
|
#include "InputSocketHandler.h"
|
||||||
|
|
||||||
#include "boost/date_time/posix_time/posix_time.hpp"
|
#include "boost/date_time/posix_time/posix_time.hpp"
|
||||||
#include <chrono>
|
|
||||||
|
|
||||||
namespace flippR_driver
|
namespace flippR_driver
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,8 +4,6 @@
|
|||||||
|
|
||||||
#include "LoggerFactory.h"
|
#include "LoggerFactory.h"
|
||||||
|
|
||||||
#include "config.h"
|
|
||||||
|
|
||||||
#ifndef EASYLOGGING_IS_INITIALIZED
|
#ifndef EASYLOGGING_IS_INITIALIZED
|
||||||
#define EASYLOGGING_IS_INITIALIZED
|
#define EASYLOGGING_IS_INITIALIZED
|
||||||
INITIALIZE_EASYLOGGINGPP
|
INITIALIZE_EASYLOGGINGPP
|
||||||
|
|||||||
Reference in New Issue
Block a user