/*
 * InputFactory.h
 *
 *  Created on: Apr 5, 2018
 *      Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert
 */

#ifndef INPUTFACTORY_H_
#define INPUTFACTORY_H_

#include <istream>
#include "json/json.hpp"

#include "input/InputDriver.h"
#include "DistributingEvent.h"
#include "input/detail/InputPinController.h"
#include "input/EventNotifier.h"

namespace flippR_driver
{
namespace input
{
namespace InputDriverFactory
{
  std::shared_ptr<InputDriver> get_InputDriver(std::istream &input_pin_stream, std::istream &matrix_config_stream);

  namespace
  {
  static void create_events(std::istream &matrix_config,
                                  std::vector<std::shared_ptr<DistributingEvent>> &events,
                                  std::map<std::string, std::shared_ptr<Event>> &name_event_map,
                                  std::shared_ptr<EventNotifier> event_notifier);

  static std::shared_ptr<DistributingEvent> create_event(nlohmann::json &json_event, std::shared_ptr<EventNotifier> event_notifier, int bounce_time);
  static void set_individual_bounce_time(nlohmann::json &json_event, int &bounce_time);

  static std::map<std::string, uint8_t> create_pin_map(std::istream &input_pin_stream);
  }
};
}
}
#endif
