/* * ParamInfo.cc * * Created on: Oct 8, 2014 * Author: m.mazel */ #include "ParamInfo.hh" #include "Parameter.hh" #include #include #include #include #include #include namespace AMDA { namespace Info { std::ostream& operator<<(std::ostream& out, const ParamInfo& pi){ out << "[ParamInfo]" << std::endl; out << "{"<(key,value)) std::vector> ParamInfo::getInfoMap(ParameterManager * parameterManager) { std::vector> infoMap; PUSHINFO(infoMap, PARAMETER_ID, getId()); PUSHINFO(infoMap, PARAMETER_NAME,getName()); PUSHINFO(infoMap, PARAMETER_SHORT_NAME,getShortName()); if (getProcessInfo().empty() ) { //not a processed param PUSHINFO(infoMap, PARAMETER_COMPONENTS, getComponents()); PUSHINFO(infoMap, PARAMETER_UNITS, getUnits()); PUSHINFO(infoMap, PARAMETER_COORDSYS, getCoordinatesSystem()); std::stringstream tensorOrder; tensorOrder << getTensorOrder(); PUSHINFO(infoMap, PARAMETER_TENSOR, tensorOrder.str()); PUSHINFO(infoMap, PARAMETER_SICONV, getSiConversion()); std::stringstream fillVal; fillVal << getFillValue(); PUSHINFO(infoMap, PARAMETER_FILLVALUE, fillVal.str()); PUSHINFO(infoMap, PARAMETER_UCD, getUcd()); //push status if defined if (!_statusDef.empty()) { for (int i = 0; i < (int)_statusDef.size(); ++i) { std::stringstream statusIndex; statusIndex << i; std::stringstream crtVal; std::stringstream infoKey; infoKey.str(""); infoKey << PARAMETER_STATUS_NAME << "[" << statusIndex.str() << "]"; PUSHINFO(infoMap, infoKey.str(),_statusDef[i].getName()); infoKey.str(""); infoKey << PARAMETER_STATUS_MIN << "[" << statusIndex.str() << "]"; crtVal.str(""); crtVal << _statusDef[i].getMinValue(); PUSHINFO(infoMap, infoKey.str(),crtVal.str()); infoKey.str(""); infoKey << PARAMETER_STATUS_MAX << "[" << statusIndex.str() << "]"; crtVal.str(""); crtVal << _statusDef[i].getMaxValue(); PUSHINFO(infoMap, infoKey.str(),crtVal.str()); } } } else { //processed parameter PUSHINFO(infoMap, PARAMETER_PROCESS_INFO, getProcessInfo()); PUSHINFO(infoMap, PARAMETER_PROCESS_DESC, getProcessDescription()); std::stringstream linkedParam; bool isFirst = true; for (auto param : _linkedParamList) { if (!isFirst) linkedParam << ","; isFirst = false; linkedParam << param; } PUSHINFO(infoMap, PARAMETER_LINKED_PARAM, linkedParam.str()); } if (_tables.empty()) { //no table defined //PUSHINFO(infoMap, PARAMETER_TABLE, std::string("None")); } else { //push tables definition for (auto table : _tables) { table.second->addTableInfo(parameterManager, table.first, infoMap); } } //adjout des info de tables ParameterSPtr param = parameterManager->getParameter(getId()); std::map>> infoList =param->getInfoList(); if(! infoList.empty()){ for (auto inf : infoList){ if(! inf.second->empty()){ std::ostringstream values; // Convert all but the last element to avoid a trailing "," std::copy(inf.second->begin(), inf.second->end()-1, std::ostream_iterator(values, ",")); // Now add the last element with no delimiter values<< inf.second->back(); std::stringstream infoKey; infoKey.str(""); infoKey << PARAMETER_INFO<< "[" << inf.first << "]"; PUSHINFO(infoMap , infoKey.str() , values.str()); } } } infoList.clear(); return infoMap; } } /* namespace Info */ } /* namespace AMDA */