#pragma once

#include "memory"
#include "json.hpp"

#include <filesystem>
#include <iostream>
#include <iomanip>
#include <fstream>

#include "Input.h"
#include "Output.h"

#include <Registration.h>

#include <ProcessorStandard.h>

namespace mdd {
	class Connector {

	private:
		Registration regi = Registration();
		IProcessor::Ptr _root;
		IOptimizer::Ptr _opt;
		const std::map<const std::string, std::function<json(const json&)>> _ops = {//const std::map<const std::string, const json& (Connector::*)(const json&)> _ops = {
			{"add", std::bind(&Connector::add,this,std::placeholders::_1) },
			{"change", std::bind(&Connector::change,this,std::placeholders::_1)},
			{"load", std::bind(&Connector::load,this,std::placeholders::_1)},
			{"remove", std::bind(&Connector::remove,this,std::placeholders::_1)},
			{"save", std::bind(&Connector::save,this,std::placeholders::_1)},
			{"state", std::bind(&Connector::state,this,std::placeholders::_1)}
        };

		std::function <json(const json&)> _callback;

		/**
		*subject
		*object
		**/
		//refernece funktioniert nicht!????
		json add(const json& args);
		/**
		*subject
		*object
		**/
		json remove(const json& args);
		/**
		*subject
		*object
		**/
		json change(const json& args);
		/**
		*subject
		*object
		**/
		json state(const json& args);



		json save(const json& args);

		json load(const json& args);

		json optimizerCallback(const json& callback);

	public:
		Connector();
		json decode(const json& request);
		json encode();
		void attachCallback(std::function<json(const json&)> callback);
	};
}