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

#ifndef FLIPPR_DRIVER_ITEMFACTORY_H
#define FLIPPR_DRIVER_ITEMFACTORY_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 port_extenders[] = "port_extenders";

  const char deactivation_time[] = "deactivation_time_milliseconds";

  const char sound_path[] = "sounds";
  const char fire_pin[] = "fire_pin";

  const char flipper_path[] = "flippers";

  const char solenoid_path[] = "solenoids";

  const char lamps_path[] = "lamps";
  const char address_pins[] = "address_pins";
  const char enable_pins[] = "enable_pins";
  const char data_pin[] = "data_pin";

  const char display_board[] = "display_board";
  const char run_pin[] = "run";
  const char display_update_frequency[] = "update_frequency";
  const char display_select[] = "display_select";
  const char display_segement_select[] = "segment_select";
  const char display_digit_select[] = "digit_select";
  const char display_digits[] = "digits";
  const char display_list[] = "displays";
  const char display_lt_pin[] =  "lt";
}

class ItemFactory
{
public:
  ItemFactory(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_ITEMFACTORY_H
