/*
 * Factory.h
 *
 *  Created on: December 28, 2019
 *      Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert
 */

#ifndef FLIPPR_DRIVER_FACTORY_H
#define FLIPPR_DRIVER_FACTORY_H

#include <PinController.h>
#include "utility/config.h"
#include "json/json.hpp"
#include "output/items/Item.h"

namespace flippR_driver
{
namespace output
{

namespace config_path
{
  const char item_name[] = "name";
  const char item_address[] = "address";
  const char item_extender[] = "extender";
  const char item_identifier[] = "id";
  const char deactivation_time[] = "deactivation_time_milliseconds";
  const char sound_path[] = "sounds";
}

class Factory
{
public:
  Factory(nlohmann::json &object, std::shared_ptr<PinController> pin_controller);

  virtual std::map<std::string, std::shared_ptr<items::Item>> getItemMap() = 0;

protected:
  void initialize_port_extender(nlohmann::json & extender);
  void initialize_port_extenders();
  uint8_t get_extender_pin_base(std::string & name);

protected:
  nlohmann::json object;
  std::shared_ptr<PinController> pin_controller;

private:
  nlohmann::json port_extenders;
};

}
}


#endif //FLIPPR_DRIVER_FACTORY_H
