Refactores Factory

This commit is contained in:
Johannes Wendel
2020-01-06 09:05:13 +01:00
parent f00e10ea33
commit 06663751d7
17 changed files with 86 additions and 307 deletions

View File

@@ -56,7 +56,7 @@ file(GLOB_RECURSE SOURCES src/*.cpp)
if(BUILD_SHARED_LIB)
add_library(${PROJECT_NAME} SHARED ${SOURCES})
else()
add_library(${PROJECT_NAME} STATIC ${SOURCES} cli/OutputInterpreter.cpp cli/OutputInterpreter.h src/output/items/detail/DriverBoardItem.cpp src/output/items/detail/DriverBoardItem.h include/DriverFactory.h src/utility/Colors.h src/output/factories/SoundFactory.cpp src/output/factories/SoundFactory.h src/output/factories/Factory.cpp src/output/factories/Factory.h src/output/factories/FlipperFactory.cpp src/output/factories/FlipperFactory.h src/output/factories/LampFactory.cpp src/output/factories/LampFactory.h src/output/factories/DisplayFactory.cpp src/output/factories/DisplayFactory.h)
add_library(${PROJECT_NAME} STATIC ${SOURCES} cli/OutputInterpreter.cpp cli/OutputInterpreter.h src/output/items/detail/DriverBoardItem.cpp src/output/items/detail/DriverBoardItem.h include/DriverFactory.h src/utility/Colors.h src/output/factories/SoundFactory.cpp src/output/factories/SoundFactory.h src/output/factories/ItemFactory.cpp src/output/factories/ItemFactory.h src/output/factories/FlipperFactory.cpp src/output/factories/FlipperFactory.h src/output/factories/LampFactory.cpp src/output/factories/LampFactory.h src/output/factories/DisplayFactory.cpp src/output/factories/DisplayFactory.h)
endif(BUILD_SHARED_LIB)
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/src)

View File

@@ -12,23 +12,5 @@ using namespace std;
OutputInterpreter::OutputInterpreter(std::string output_lamp_config_file, std::string output_solenoid_config_file,
std::string output_sound_config_file, std::string output_display_config_file)
{
std::ifstream output_pin_config_stream;
std::ifstream lamp_config_stream;
std::ifstream solenoid_config_stream;
std::ifstream sound_config_stream;
std::ifstream display_config_stream;
try
{
lamp_config_stream.open(output_lamp_config_file);
solenoid_config_stream.open(output_solenoid_config_file);
sound_config_stream.open(output_sound_config_file);
display_config_stream.open(output_display_config_file);
}
catch(const std::exception& e)
{
cerr << e.what();
exit(EXIT_FAILURE);
}
output_driver = flippR_driver::get_OutputDriver(lamp_config_stream, solenoid_config_stream, sound_config_stream, display_config_stream);
output_driver = flippR_driver::get_OutputDriver(output_lamp_config_file, output_solenoid_config_file, output_sound_config_file, output_display_config_file);
}

View File

@@ -14,10 +14,10 @@
namespace flippR_driver
{
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& lamp_config,
std::istream& solenoid_config,
std::istream& sound_config,
std::istream& display_config);
std::shared_ptr<output::OutputDriver> get_OutputDriver(std::string & lamp_config_path,
std::string & solenoid_config_path,
std::string & sound_config_path,
std::string & display_config_path);
}
#endif //flippR_driver_DRIVERFACTORY_H

View File

@@ -124,17 +124,17 @@ void FlippRServer::initialize(Application &self)
void FlippRServer::initialize_output_driver()
{
std::ifstream lamp_config_stream;
std::ifstream solenoid_config_stream;
std::ifstream sound_config_stream;
std::ifstream display_config_stream;
std::string lamp_config_path;
std::string solenoid_config_path;
std::string sound_config_path;
std::string display_config_path;
try
{
lamp_config_stream.open(this->configs["lamp-config"].toString());
solenoid_config_stream.open(this->configs["solenoid-config"].toString());
sound_config_stream.open(this->configs["sound-config"].toString());
display_config_stream.open(this->configs["display-config"].toString());
lamp_config_path = this->configs["lamp-config"].toString();
solenoid_config_path = this->configs["solenoid-config"].toString();
sound_config_path = this->configs["sound-config"].toString();
display_config_path = this->configs["display-config"].toString();
}
catch(const std::exception& e)
{
@@ -142,10 +142,10 @@ void FlippRServer::initialize_output_driver()
exit(EXIT_FAILURE);
}
this->output_driver = flippR_driver::get_OutputDriver(solenoid_config_stream,
lamp_config_stream,
sound_config_stream,
display_config_stream);
this->output_driver = flippR_driver::get_OutputDriver(solenoid_config_path,
lamp_config_path,
sound_config_path,
display_config_path);
}
void FlippRServer::initialize_input_driver()

View File

@@ -16,11 +16,11 @@ namespace flippR_driver
return input::InputDriverFactory::get_InputDriver(input_config_stream, matrix_config_stream);
}
std::shared_ptr<output::OutputDriver> get_OutputDriver(std::istream& lamp_config,
std::istream& solenoid_config,
std::istream& sound_config,
std::istream& display_config)
std::shared_ptr<output::OutputDriver> get_OutputDriver(std::string & lamp_config_path,
std::string & solenoid_config_path,
std::string & sound_config_path,
std::string & display_config_path)
{
return output::OutputDriverFactory::get_OutputDriver(lamp_config, solenoid_config, sound_config, display_config);
return output::OutputDriverFactory::get_OutputDriver(lamp_config_path, solenoid_config_path, sound_config_path, display_config_path);
}
}

View File

@@ -26,64 +26,23 @@ namespace OutputDriverFactory
{
using namespace nlohmann;
namespace config {
namespace
{
json solenoids;
json lamps;
json sounds;
json displays;
}
}
std::shared_ptr<OutputDriver> get_OutputDriver(std::istream& solenoid_config,
std::istream& lamp_config,
std::istream& sound_config,
std::istream& display_config)
std::shared_ptr<OutputDriver> get_OutputDriver(const std::string & solenoid_config_path,
const std::string & lamp_config_path,
const std::string & sound_config_path,
const std::string & display_config_path)
{
utility::LoggerFactory::CreateOutputLogger();
solenoid_config >> config::solenoids;
lamp_config >> config::lamps;
sound_config >> config::sounds;
display_config >> config::displays;
auto output_pin_mutex = std::make_shared<std::mutex>();
std::shared_ptr<DriverBoardPinController> driver_board_pin_controller(new detail::DriverBoardPinController(output_pin_mutex));
FlipperFactory flipper_factory{config::solenoids, driver_board_pin_controller};
try
{
auto flippers = flipper_factory.getItemMap();
}
catch(json::exception &e)
{
CLOG(INFO, OUTPUT_LOGGER) << "File " << "solenoid_config.json" << " seems to be corrupted: " << ": " << e.what();
exit(EXIT_FAILURE);
}
LampFactory lamp_factory(config::lamps, driver_board_pin_controller);
try
{
auto lamps = lamp_factory.getItemMap();
}
catch(json::exception &e)
{
CLOG(INFO, OUTPUT_LOGGER) << "File " << "lamp_config.json" << " seems to be corrupted: " << ": " << e.what();
exit(EXIT_FAILURE);
}
auto flippers = get_items<FlipperFactory, detail::DriverBoardPinController>(solenoid_config_path, driver_board_pin_controller);
auto lamps = get_items<LampFactory, detail::DriverBoardPinController>(lamp_config_path, driver_board_pin_controller);
auto sound_board_pin_controller = create_SoundBoardPinController();
SoundFactory sound_factory{config::sounds, sound_board_pin_controller};
try
{
auto sounds = sound_factory.getItemMap();
}
catch(json::exception &e)
{
CLOG(INFO, OUTPUT_LOGGER) << "File " << "sound_config.json" << " seems to be corrupted: " << ": " << e.what();
exit(EXIT_FAILURE);
}
auto sounds = get_items<SoundFactory, detail::SoundBoardPinController>(sound_config_path, sound_board_pin_controller);
/*std::unique_ptr<DisplayBoardPinController> display_board_pin_controller(new detail::DisplayBoardPinController(parse_pins_display_board(display_config)));
@@ -94,110 +53,9 @@ std::shared_ptr<OutputDriver> get_OutputDriver(std::istream& solenoid_config,
return std::make_shared<OutputDriver>(std::move(display_controller), solenoids, lamps, sounds, flippers, display_map);*/
}
std::map<std::string, std::shared_ptr<items::Solenoid>> create_solenoids(std::shared_ptr<DriverBoardPinController> &pin_controller)
{
json port_extenders = get_element("port_extenders", config::solenoids, "");
initialize_port_extenders(port_extenders, pin_controller.get(), "solenoid_config.json");
json solenoids_json = get_element("solenoids", config::solenoids, "solenoid_config.json");
std::chrono::milliseconds deactivation_time{ get_value<int>("deactivation_time_milliseconds", config::solenoids, "solenoid_config.json") };
std::map<std::string, std::shared_ptr<items::Solenoid>> solenoids;
for(auto &solenoid_json : solenoids_json)
{
auto solenoid = create_solenoid(solenoid_json, port_extenders, pin_controller, deactivation_time);
solenoids.emplace(solenoid->get_name(), solenoid);
}
return solenoids;
}
std::shared_ptr<items::detail::Solenoid> create_solenoid(nlohmann::json &solenoid_json, nlohmann::json &port_extenders, std::shared_ptr<DriverBoardPinController> &pin_controller, std::chrono::milliseconds deactivation_time)
{
std::string config_file_name = "config::solenoid.json";
uint8_t pin_base = get_pin_base(solenoid_json, port_extenders, config_file_name);
auto name = get_value<std::string>("name", solenoid_json, config_file_name);
auto address = get_value<uint8_t>("address", solenoid_json, config_file_name);
if(solenoid_json.find("deactivation_time_milliseconds") != solenoid_json.end())
{
deactivation_time = std::chrono::milliseconds(get_value<uint8_t>("deactivation_time_milliseconds", solenoid_json, config_file_name));
}
return std::make_shared<items::detail::Solenoid>(pin_controller, address, pin_base, name, deactivation_time);
}
std::map<std::string, std::shared_ptr<items::Flipper>> create_flippers(std::shared_ptr<DriverBoardPinController> &pin_controller)
{
json port_extenders = get_element("port_extenders", config::solenoids, "solenoid_config.json");
json flippers_json = get_element("flippers", config::solenoids, "solenoid_config.json");
std::chrono::milliseconds deactivation_time{ get_value<int>("deactivation_time_milliseconds", config::solenoids, "solenoid_config.json") };
std::map<std::string, std::shared_ptr<items::Flipper>> flippers;
for(auto &flipper_json : flippers_json)
{
auto flipper = create_flipper(flipper_json, port_extenders, pin_controller);
flippers.emplace(flipper->get_name(), flipper);
}
return flippers;
}
std::shared_ptr<items::detail::Flipper> create_flipper(nlohmann::json &flipper_json, json &port_extenders, std::shared_ptr<DriverBoardPinController> &pin_controller)
{
std::string config_file_name = "solenoid_config.json";
uint8_t pin_base = get_pin_base(flipper_json, port_extenders, config_file_name);
auto address = get_value<uint8_t>("address", flipper_json, config_file_name);
auto name = get_value<std::string>("name", flipper_json, config_file_name);
return std::make_shared<items::detail::Flipper>(pin_controller, address, pin_base, name);
}
std::map<std::string, std::shared_ptr<items::Sound>> create_sounds(std::istream &sound_config, std::shared_ptr<SoundBoardPinController> &pin_controller)
{
json port_extenders = get_element("port_extenders", config::sounds, "sound_config.json");
initialize_port_extenders(port_extenders, pin_controller.get(), "sound_config.json");
std::chrono::milliseconds deactivation_time{ get_value<int>("deactivation_time_milliseconds", config::sounds, "solenoid_config.json") };
json sounds_json = get_element("sounds", config::sounds, "sound_config.json");
std::map<std::string, std::shared_ptr<items::Sound>> sounds;
for(auto &sound_json : sounds_json)
{
auto sound = create_sound(sound_json, port_extenders, pin_controller, deactivation_time);
sounds.emplace(sound->get_name(), sound);
}
return sounds;
}
std::shared_ptr<items::detail::Sound> create_sound(json &sound_json, json &port_extenders, std::shared_ptr<SoundBoardPinController> &pin_controller, std::chrono::milliseconds &deactivation_time)
{
std::string config_file_name = "sound_config.json";
uint8_t pin_base = get_pin_base(sound_json, port_extenders, config_file_name);
auto address = get_value<uint8_t>("address", sound_json, config_file_name);
auto name = get_value<std::string>("name", sound_json, config_file_name);
auto id = get_value<uint>("id", sound_json, config_file_name);
return std::make_shared<items::detail::Sound>(pin_controller, address, pin_base, name, deactivation_time, id);
}
uint8_t get_sound_fire_address()
{
json port_extenders = get_element("port_extenders", config::sounds, "sound_config.json");
json fire_pin = get_element("fire_pin", config::sounds, "sound_config.json");
auto pin_base = get_pin_base(fire_pin, port_extenders, "sound_config.json");
auto address = get_value<uint8_t>("address", fire_pin, "sound_config.json");
return address;
}
std::map<std::string, uint8_t> parse_pins_display_board(std::istream &display_config)
{
std::string config_file = "display_config.json";
/* std::string config_file = "display_config.json";
json display_board_config = get_element("display_board", config::displays, config_file);
@@ -222,12 +80,12 @@ std::map<std::string, uint8_t> parse_pins_display_board(std::istream &display_co
pins_display["digit_select_C"] = get_value<uint8_t>("C", digit_select, config_file);
pins_display["digit_select_D"] = get_value<uint8_t>("D", digit_select, config_file);;
return pins_display;
return pins_display;*/
}
std::vector<std::shared_ptr<items::OutputDisplay>> create_displays(std::istream &display_config)
{
json displays_json = get_element("displays", config::displays, "display_config.json");
/* json displays_json = get_element("displays", config::displays, "display_config.json");
std::vector<std::shared_ptr<items::OutputDisplay>> displays;
for(json &display_json : displays_json)
@@ -236,7 +94,7 @@ std::vector<std::shared_ptr<items::OutputDisplay>> create_displays(std::istream
displays.push_back(display);
}
return displays;
return displays;*/
}
std::shared_ptr<items::OutputDisplay> create_display(json & display_json)
@@ -267,81 +125,31 @@ std::map<uint8_t, std::shared_ptr<items::Display>> map_displays(const std::vecto
return display_map;
}
void initialize_port_extenders(json &port_extenders, PinController * pin_controller, const std::string & file_name)
{
for (auto & extender_json : port_extenders)
{
auto i2c_address = get_value<uint8_t>("i2c_address", extender_json, file_name);
auto pin_base = get_value<uint8_t>("pin_base", extender_json, file_name);
pin_controller->initialize_port_expander(i2c_address, pin_base);
}
}
uint8_t get_pin_base(json & object, json & port_extenders, const std::string & config_file_name)
{
if(object.find("extender") != object.end())
{
auto extender_name = get_value<std::string>("extender", object, config_file_name);
for (auto & extender : port_extenders)
{
auto actual_extender = get_value<std::string>("name", extender, config_file_name);
if (actual_extender == extender_name)
{
try
{
return extender.at("pin_base").get<uint8_t >();
}
catch(json::exception &e)
{
CLOG(INFO, OUTPUT_LOGGER) << "pin_base not set for " << extender_name << " in " << config_file_name;
return 0;
}
}
}
}
CLOG(INFO, OUTPUT_LOGGER) << "Extender not set for " << object << " in " << config_file_name;
return 0;
}
json get_element(const std::string & name, json & object, const std::string & file_name)
{
json sub_object;
try
{
sub_object = object.at(name);
}
catch(json::exception &e)
{
CLOG(ERROR, OUTPUT_LOGGER) << "File " << file_name << " seems to be corrupted at " << name << ": " << e.what();
exit(EXIT_FAILURE);
}
return sub_object;
}
template<typename type>
type get_value(const std::string & name, json & object, const std::string & file_name)
{
type element;
try
{
element = object.at(name).get<type>();
}
catch(json::exception &e)
{
/*CLOG(ERROR, OUTPUT_LOGGER)*/ std::cerr << "File " << file_name << " seems to be corrupted at " << name << ": " << e.what();
exit(EXIT_FAILURE);
}
return element;
}
std::shared_ptr<SoundBoardPinController> create_SoundBoardPinController()
{
return std::shared_ptr<SoundBoardPinController>();
}
template<typename FactoryType, typename ControllerType>
std::map<std::string, std::shared_ptr<items::Item>> get_items(const std::string &config_path, std::shared_ptr<PinController> pin_controller)
{
std::ifstream config_stream{config_path};
nlohmann::json config_json;
config_stream >> config_json;
FactoryType factory{config_json, std::static_pointer_cast<ControllerType>(pin_controller)};
std::map<std::string, std::shared_ptr<items::Item>> map;
try{
map = factory.getItemMap();
}
catch(json::exception & e)
{
CLOG(INFO, OUTPUT_LOGGER) << "File " << config_path << " seems to be corrupted: " << ": " << e.what();
exit(EXIT_FAILURE);
}
}
}
}
}

View File

@@ -23,32 +23,21 @@ namespace output
{
namespace OutputDriverFactory
{
std::shared_ptr<OutputDriver> get_OutputDriver(std::istream& solenoid_config,
std::istream& lamp_config,
std::istream& sound_config,
std::istream& display_config);
std::shared_ptr<OutputDriver> get_OutputDriver(const std::string & solenoid_config_path,
const std::string & lamp_config_path,
const std::string & sound_config_path,
const std::string & display_config_path);
std::map<std::string, std::shared_ptr<items::Solenoid>> create_solenoids(std::shared_ptr<DriverBoardPinController> &driverBoardPinController);
std::shared_ptr<items::detail::Solenoid> create_solenoid(nlohmann::json &solenoid_json, nlohmann::json &port_extenders, std::shared_ptr<DriverBoardPinController> &pin_controller, std::chrono::milliseconds deactivation_time);
std::map<std::string, std::shared_ptr<items::Flipper>> create_flippers(std::shared_ptr<DriverBoardPinController> &pin_controller);
std::shared_ptr<items::detail::Flipper> create_flipper(nlohmann::json &flipper_json, nlohmann::json &port_extenders, std::shared_ptr<DriverBoardPinController> &pin_controller);
template<typename FactoryType, typename ControllerType>
std::map<std::string, std::shared_ptr<items::Item>> get_items(const std::string & config_path, std::shared_ptr<PinController> pin_controller);
std::shared_ptr<SoundBoardPinController> create_SoundBoardPinController();
std::map<std::string, std::shared_ptr<items::Sound>> create_sounds(std::shared_ptr<SoundBoardPinController> &pin_controller);
std::shared_ptr<items::detail::Sound> create_sound(nlohmann::json &sound_json, nlohmann::json &port_extenders, std::shared_ptr<SoundBoardPinController> &pin_controller, std::chrono::milliseconds &deactivation_time);
uint8_t get_sound_fire_address(std::istream &sound_config);
std::map<std::string, uint8_t> parse_pins_display_board(std::istream & display_config);
std::vector<std::shared_ptr<items::OutputDisplay>> create_displays();
std::shared_ptr<items::OutputDisplay> create_display(nlohmann::json &display_json);
std::map<uint8_t, std::shared_ptr<items::Display>> map_displays(const std::vector<std::shared_ptr<items::OutputDisplay>> &displays);
void initialize_port_extenders(nlohmann::json &port_extenders, PinController * pin_controller, const std::string & file_name);
uint8_t get_pin_base(nlohmann::json & object, nlohmann::json & port_extenders, const std::string & config_file_name);
nlohmann::json get_element(const std::string & name, nlohmann::json & object, const std::string & file_name);
template<typename type>
type get_value(const std::string & name, nlohmann::json & object, const std::string & file_name);
}

View File

@@ -15,7 +15,7 @@ namespace output
{
DisplayFactory::DisplayFactory(nlohmann::json &object, std::shared_ptr<DisplayBoardPinController> pin_controller) :
Factory{object, pin_controller}
ItemFactory{object, pin_controller}
{
}

View File

@@ -8,14 +8,14 @@
#ifndef FLIPPR_DRIVER_DISPLAYFACTORY_H
#define FLIPPR_DRIVER_DISPLAYFACTORY_H
#include "Factory.h"
#include "ItemFactory.h"
namespace flippR_driver
{
namespace output
{
class DisplayFactory : Factory
class DisplayFactory : ItemFactory
{
public:
explicit DisplayFactory(nlohmann::json & object, std::shared_ptr<DisplayBoardPinController> pin_controller);

View File

@@ -15,7 +15,7 @@ namespace output
{
FlipperFactory::FlipperFactory(nlohmann::json &object, std::shared_ptr<DriverBoardPinController> pin_controller) :
Factory{object, pin_controller}
ItemFactory{object, pin_controller}
{}
std::map<std::string, std::shared_ptr<items::Item>> FlipperFactory::getItemMap()

View File

@@ -8,7 +8,7 @@
#ifndef FLIPPR_DRIVER_FLIPPERFACTORY_H
#define FLIPPR_DRIVER_FLIPPERFACTORY_H
#include "Factory.h"
#include "ItemFactory.h"
#include <string>
namespace flippR_driver
@@ -16,7 +16,7 @@ namespace flippR_driver
namespace output
{
class FlipperFactory : Factory
class FlipperFactory : ItemFactory
{
public:
explicit FlipperFactory(nlohmann::json & object, std::shared_ptr<DriverBoardPinController> pin_controller);

View File

@@ -1,18 +1,18 @@
/*
* Factory.cpp
* ItemFactory.cpp
*
* Created on: December 28, 2019
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert
*/
#include "Factory.h"
#include "ItemFactory.h"
namespace flippR_driver
{
namespace output
{
Factory::Factory(nlohmann::json &object, std::shared_ptr<PinController> pin_controller) :
ItemFactory::ItemFactory(nlohmann::json &object, std::shared_ptr<PinController> pin_controller) :
pin_controller{pin_controller}
{
this->object = object;
@@ -20,14 +20,14 @@ Factory::Factory(nlohmann::json &object, std::shared_ptr<PinController> pin_cont
this->port_extenders = object.at("port_extenders");
}
void Factory::initialize_port_extender(nlohmann::json &extender)
void ItemFactory::initialize_port_extender(nlohmann::json &extender)
{
auto i2c_address = extender.at("i2c_address").get<uint8_t>();
auto pin_base = extender.at("pin_base").get<uint8_t>();
this->pin_controller->initialize_port_expander(i2c_address, pin_base);
}
void Factory::initialize_port_extenders()
void ItemFactory::initialize_port_extenders()
{
for (auto extender : port_extenders)
{
@@ -35,7 +35,7 @@ void Factory::initialize_port_extenders()
}
}
uint8_t Factory::get_extender_pin_base(std::string &name)
uint8_t ItemFactory::get_extender_pin_base(std::string &name)
{
for (auto extender : port_extenders)
{

View File

@@ -1,12 +1,12 @@
/*
* Factory.h
* ItemFactory.h
*
* Created on: December 28, 2019
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert
*/
#ifndef FLIPPR_DRIVER_FACTORY_H
#define FLIPPR_DRIVER_FACTORY_H
#ifndef FLIPPR_DRIVER_ITEMFACTORY_H
#define FLIPPR_DRIVER_ITEMFACTORY_H
#include <PinController.h>
#include "utility/config.h"
@@ -31,10 +31,10 @@ namespace config_path
const char flipper_path[] = "flippers";
}
class Factory
class ItemFactory
{
public:
Factory(nlohmann::json &object, std::shared_ptr<PinController> pin_controller);
ItemFactory(nlohmann::json &object, std::shared_ptr<PinController> pin_controller);
virtual std::map<std::string, std::shared_ptr<items::Item>> getItemMap() = 0;
@@ -55,4 +55,4 @@ private:
}
#endif //FLIPPR_DRIVER_FACTORY_H
#endif //FLIPPR_DRIVER_ITEMFACTORY_H

View File

@@ -15,7 +15,7 @@ namespace output
{
LampFactory::LampFactory(nlohmann::json &object, std::shared_ptr<DriverBoardPinController> pin_controller) :
Factory{object, pin_controller}
ItemFactory{object, pin_controller}
{}
std::map<std::string, std::shared_ptr<items::Item>> LampFactory::getItemMap()

View File

@@ -9,14 +9,14 @@
#define FLIPPR_DRIVER_LAMPFACTORY_H
#include <output/DriverBoardPinController.h>
#include "Factory.h"
#include "ItemFactory.h"
namespace flippR_driver
{
namespace output
{
class LampFactory : Factory
class LampFactory : ItemFactory
{
public:
explicit LampFactory(nlohmann::json & object, std::shared_ptr<DriverBoardPinController> pin_controller);

View File

@@ -12,7 +12,7 @@ namespace output
{
SoundFactory::SoundFactory(nlohmann::json &object, std::shared_ptr<SoundBoardPinController> pin_controller) :
Factory{object, pin_controller},
ItemFactory{object, pin_controller},
deactivation_time{0}
{
if (object.find(config_path::deactivation_time) != object.end())

View File

@@ -8,7 +8,7 @@
#ifndef FLIPPR_DRIVER_SOUNDFACTORY_H
#define FLIPPR_DRIVER_SOUNDFACTORY_H
#include "Factory.h"
#include "ItemFactory.h"
#include "output/SoundBoardPinController.h"
@@ -17,7 +17,7 @@ namespace flippR_driver
namespace output
{
class SoundFactory : Factory
class SoundFactory : ItemFactory
{
public:
explicit SoundFactory(nlohmann::json & object, std::shared_ptr<SoundBoardPinController> pin_controller);