FileWriter.cc 1.95 KB
/**
 * FileWriter.cc
 *
 *  Created on: 02 oct. 2014
 *      Author: AKKA
 */

#include "FileWriter.hh"

namespace AMDA {
namespace ParamOutputImpl {
namespace Download {
namespace FileWriter {

FileWriter::FileWriter(AMDA::Parameters::ParameterManager& pParameterManager) :
		_parameterManager(pParameterManager)
{
}

FileWriter::~FileWriter(void)
{
}

void FileWriter::sortParametersInfoByType(std::string crtParamId,
			std::set<std::pair<std::string,AMDA::Info::ParamInfoSPtr>,cmpParamInfoStruct>& baseParamsInfoList,
			std::set<std::pair<std::string,AMDA::Info::ParamInfoSPtr>,cmpParamInfoStruct>& derivedParamsInfoList)
{
	//get current parameter
	AMDA::Parameters::ParameterSPtr crtParam = _parameterManager.getParameter(crtParamId);

	if (crtParam == nullptr)
		return;

	//get current param info
	AMDA::Info::ParamInfoSPtr paramInfo = AMDA::Info::ParamMgr::getInstance()->getParamInfoFromId(crtParam->getInfoId());

	if (paramInfo == nullptr)
		return;

	if (paramInfo->getProcessInfo().empty())
	{
		//it's a base parameter
		baseParamsInfoList.insert(std::pair<std::string,AMDA::Info::ParamInfoSPtr>(crtParamId,paramInfo));
                                        if(!paramInfo->getLinkedParamList().empty())
                                        {
                                                             for (auto linkedParamId : paramInfo->getLinkedParamList())
                                                                                sortParametersInfoByType(linkedParamId, baseParamsInfoList, derivedParamsInfoList);
                                        }
	}
	else
	{
		//it's a derived parameter
		derivedParamsInfoList.insert(std::pair<std::string,AMDA::Info::ParamInfoSPtr>(crtParamId,paramInfo));
		for (auto linkedParamId : paramInfo->getLinkedParamList())
			sortParametersInfoByType(linkedParamId, baseParamsInfoList, derivedParamsInfoList);
	}
}

} /* namespace FileWriter */
} /* namespace Download */
} /* namespace ParamOutputImpl */
} /* namespace AMDA */