Refactores Factory
This commit is contained in:
@@ -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}
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
@@ -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
|
||||
@@ -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()
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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())
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user