
#include "Registration.h"
#include <map>
#include <string>

#include "ModuleHTTP.cpp"
#include "ModuleMath.cpp"
#include "ModuleMerge.cpp"
#include "ModuleSplitt.cpp"
#include "ModuleSQL.cpp"
#include "ModuleSwitch.cpp"

#include "ProcessorStandard.h"

#include "OptimizerEvolutionary.h"

namespace mdd
{
	Registration::Registration()
	{
		REGISTER_MODULE(ModuleHTTP);
		REGISTER_MODULE(ModuleMath);
		REGISTER_MODULE(ModuleMerge);
		//REGISTER_MODULE(ModuleSplitt);
		REGISTER_MODULE(ModuleSQL);
		REGISTER_MODULE(ModuleSwitch);
		//REGISTER_MODULE(Parameter);

		REGISTER_MODULE(ProcessorStandard);

		REGISTER_PROCESSOR(ProcessorStandard);

		REGISTER_OPTIMIZER(OptimizerEvolutionary);
	}
	IModule::Ptr Registration::generateModule(const std::string& name)
	{
		auto it = _modules.find(name);
		if (it != _modules.end())
		{
			return it->second->generate();
		}
		return nullptr;
	}

	std::vector<std::string> Registration::getModules() 
	{
		std::vector<std::string> ret;
		for (auto it = _modules.begin(); it != _modules.end(); ++it)
		{
			ret.push_back(it->first);
		}
		return ret;
	}

	IProcessor::Ptr Registration::generateProcessor(const std::string& name) 
	{
		auto it = _processors.find(name);
		if (it != _processors.end())
		{
			return it->second->generate();
		}
		return nullptr;
	}
	std::vector<std::string> Registration::getProcessors() 
	{
		std::vector<std::string> ret;
		for (auto it = _processors.begin(); it != _processors.end(); ++it)
		{
			ret.push_back(it->first);
		}
		return ret;
	}

	IOptimizer::Ptr Registration::generateOptimizer(const std::string& name)
	{
		auto it = _optimizers.find(name);
		if (it != _optimizers.end())
		{
			return it->second->generate();
		}
		return nullptr;
	}
	std::vector<std::string> Registration::getOptimizers() 
	{
		std::vector<std::string> ret;
		for (auto it = _optimizers.begin(); it != _optimizers.end(); ++it)
		{
			ret.push_back(it->first);
		}
		return ret;
	}
}