Refactores item factories

This commit is contained in:
Johannes Wendel
2020-01-06 14:38:21 +01:00
parent 4a520fb12a
commit 83fe8675da
22 changed files with 50 additions and 46 deletions

View File

@@ -18,15 +18,15 @@ LampFactory::LampFactory(nlohmann::json &object, std::shared_ptr<DriverBoardPinC
ItemFactory{object, pin_controller}
{}
std::map<std::string, std::shared_ptr<items::Item>> LampFactory::getItemMap()
std::map<std::string, std::shared_ptr<items::Lamp>> LampFactory::getItemMap()
{
auto lamps = this->object.at("lamps");
std::map<std::string, std::shared_ptr<items::Item>> lamp_map;
auto lamps = this->object.at(config_path::lamps_path);
std::map<std::string, std::shared_ptr<items::Lamp>> lamp_map;
for (auto lamp : lamps)
{
auto name = lamp.at("name").get<std::string>();
auto address = lamp.at("address").get<uint8_t >();
auto extender = lamp.at("extender").get<std::string>();
auto name = lamp.at(config_path::item_name).get<std::string>();
auto address = lamp.at(config_path::item_address).get<uint8_t >();
auto extender = lamp.at(config_path::item_extender).get<std::string>();
auto pin_base = this->get_extender_pin_base(extender);
auto lamp_item = std::make_shared<items::detail::Lamp>(std::static_pointer_cast<DriverBoardPinController>(this->pin_controller), address, pin_base, name);
lamp_map.emplace(name, lamp_item);