/* * ProcessTTCatToParam.cc * * Created on: Jan 31, 2019 * Author: AKKA */ #include #include #include "DicError.hh" #include "AMDA_exception.hh" #include "Operation.hh" #include "ParameterManager.hh" #include "ProcessTTCatToParam.hh" #include "TTCatToParam.hh" #include "TimeTableCatalogFactory.hh" #include "Catalog.hh" using namespace std; using namespace boost; using namespace log4cxx; namespace AMDA { namespace Parameters { ProcessTTCatToParam::ProcessTTCatToParam(Parameter ¶meter) : SingleParamProcess_CRTP(parameter) { } ProcessTTCatToParam::ProcessTTCatToParam(const ProcessTTCatToParam& pProcess, Parameter ¶meter) : SingleParamProcess_CRTP(pProcess,parameter) { } ProcessTTCatToParam::~ProcessTTCatToParam() { } TimeStamp ProcessTTCatToParam::init() { if (_attributList.size() < 1) { BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_PROCESS_ERR) << AMDA::ex_msg(std::string("ProcessTTCatToParam::init required at least one attribute to define TimeTable or Catalog location'"))); } std::string ttOrCatPath = _attributList[0]; // Load TT or Catalog std::string lReaderType = TimeTableCatalog::TimeTableCatalogFactory::getInstance().getReaderType(ttOrCatPath); if(lReaderType.empty()){ BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_PROCESS_ERR) << AMDA::ex_msg(std::string("ProcessTTCatToParam::init Unknown TimeTable or Catalog format") + ttOrCatPath)); } TimeTableCatalog::Catalog inputTTOrCat; inputTTOrCat.read(ttOrCatPath, lReaderType); std::string paramName = ""; int paramComp = 0; if (_attributList.size() > 1) { paramName = _attributList[1]; std::size_t foundComp = paramName.find("["); if (foundComp != std::string::npos) { std::string compPart = paramName.substr(foundComp + 1); std::size_t endCompFound = compPart.find("]"); if (endCompFound != std::string::npos) { compPart = compPart.substr(0,endCompFound); } try { paramComp = boost::lexical_cast(compPart); } catch (const boost::bad_lexical_cast &e) { paramComp = 0; } paramName = paramName.substr(0,foundComp); } } TimeStamp timeStamp = _parameterInput->init( this, _timeIntervalList); Parameter::InfoList lInfoList = _parameterInput->getInfoList(); _parameter.getInfoList().insert(lInfoList.begin(), lInfoList.end()); _paramInput = _parameterInput->getParamData(this).get(); _operation = new TTCatToParam(*this,*_paramInput, inputTTOrCat.getIntervals(), paramName, paramComp); _paramData = ParamDataSPtr(_operation->getParamOutput()); _paramData->setMinSampling(_paramInput->getMinSampling()); return timeStamp; } } /* namespace Parameters */ } /* namespace AMDA */