refactored inputfactory
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user