refactored inputfactory
This commit is contained in:
@@ -8,7 +8,6 @@
|
||||
#include "Detector.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <math.h>
|
||||
|
||||
#include "utility/config.h"
|
||||
|
||||
|
||||
@@ -7,8 +7,7 @@
|
||||
#include "InputDriver.h"
|
||||
|
||||
#include "utility/config.h"
|
||||
|
||||
#include <input/ErrorEvent.hpp>
|
||||
#include "ErrorEvent.hpp"
|
||||
|
||||
namespace flippR_driver
|
||||
{
|
||||
|
||||
@@ -14,9 +14,7 @@
|
||||
|
||||
#include "InputDriver.h"
|
||||
#include "EventNotifier.h"
|
||||
|
||||
using namespace nlohmann;
|
||||
using namespace flippR_driver::utility;
|
||||
#include "Detector.h"
|
||||
|
||||
namespace flippR_driver
|
||||
{
|
||||
@@ -25,8 +23,10 @@ namespace input
|
||||
namespace InputDriverFactory
|
||||
{
|
||||
|
||||
std::shared_ptr<IInputDriver>
|
||||
get_InputDriver(std::istream &input_config_stream, std::istream &matrix_config_stream)
|
||||
using namespace nlohmann;
|
||||
using namespace flippR_driver::utility;
|
||||
|
||||
std::shared_ptr<IInputDriver> get_InputDriver(std::istream& input_config_stream, std::istream& matrix_config_stream)
|
||||
{
|
||||
LoggerFactory::CreateInputLogger();
|
||||
|
||||
@@ -38,16 +38,17 @@ get_InputDriver(std::istream &input_config_stream, std::istream &matrix_config_s
|
||||
|
||||
json 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<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));
|
||||
}
|
||||
|
||||
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::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
|
||||
{
|
||||
@@ -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");
|
||||
|
||||
@@ -95,4 +96,3 @@ namespace
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,15 +9,11 @@
|
||||
#define INPUTFACTORY_H_
|
||||
|
||||
#include <istream>
|
||||
#include <atomic>
|
||||
|
||||
#include <boost/optional.hpp>
|
||||
|
||||
#include "Detector.h"
|
||||
#include "input/IInputDriver.h"
|
||||
|
||||
#include "InputGPIOInterface.h"
|
||||
#include "json/json.hpp"
|
||||
|
||||
#include "input/IInputDriver.h"
|
||||
#include "DistributingEvent.h"
|
||||
#include "InputGPIOInterface.h"
|
||||
#include "IEventNotifier.h"
|
||||
|
||||
namespace flippR_driver
|
||||
@@ -26,11 +22,11 @@ namespace input
|
||||
{
|
||||
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
|
||||
{
|
||||
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::map<std::string, std::shared_ptr<Event>> &name_event_map,
|
||||
std::shared_ptr<IEventNotifier> event_notifier);
|
||||
|
||||
Reference in New Issue
Block a user