Finished LampFactory

This commit is contained in:
Johannes Wendel
2019-12-28 21:51:32 +01:00
parent 2e37542467
commit 989f532c6d
4 changed files with 55 additions and 7 deletions

View File

@@ -5,22 +5,33 @@
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert
*/
#include <output/items/Lamp.h>
#include "LampFactory.h"
#include "output/items/detail/Lamp.h"
namespace flippR_driver
{
namespace output
{
LampFactory::LampFactory(nlohmann::json &object) : Factory(object)
{
}
LampFactory::LampFactory(nlohmann::json &object) :
Factory(object)
{}
std::map<std::string, std::shared_ptr<items::Item>> LampFactory::getItemMap()
{
return std::map<std::string, std::shared_ptr<items::Item>>();
auto lamps = object.at("lamps");
std::map<std::string, std::shared_ptr<items::Item>> 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 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);
}
return lamp_map;
}
}