From 3fe8b83d124e3c3c6664ee1a6169277653434a8e Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Tue, 6 Sep 2016 17:15:22 +0200 Subject: [PATCH] Get parameter info (name & unit) for a variable table if not defined in the table definition --- src/Info/ParamTable.cc | 42 ++++++++++++++++++++++++++++++++++++++++++ src/Info/ParamTable.hh | 10 ++++++++++ 2 files changed, 52 insertions(+), 0 deletions(-) diff --git a/src/Info/ParamTable.cc b/src/Info/ParamTable.cc index 896136a..32deb12 100644 --- a/src/Info/ParamTable.cc +++ b/src/Info/ParamTable.cc @@ -8,6 +8,8 @@ #include "Parameter.hh" #include "ParamData.hh" +#include "ParamInfo.hh" +#include "ParamMgr.hh" using namespace log4cxx; @@ -25,6 +27,10 @@ ParamTable::~ParamTable() { } +std::string ParamTable::getTableParamKeyForInfo() { + return ""; +} + /* * @brief Get param id */ @@ -46,6 +52,16 @@ void ParamTable::setName(std::string name) */ std::string ParamTable::getName(void) { + if (_tableName.empty() && _variable) { + std::string paramKeyForInfo = getTableParamKeyForInfo(); + if (!paramKeyForInfo.empty()) { + std::string tableParam = getTableParamByKey(paramKeyForInfo); + AMDA::Info::ParamInfoSPtr paramTableInfo = AMDA::Info::ParamMgr::getInstance()->getParamInfoFromId(tableParam); + if (paramTableInfo != nullptr) + return paramTableInfo->getName(); + } + } + return _tableName; } @@ -62,6 +78,16 @@ void ParamTable::setUnits(std::string units) */ std::string ParamTable::getUnits(void) { + if (_tableName.empty() && _variable) { + std::string paramKeyForInfo = getTableParamKeyForInfo(); + if (!paramKeyForInfo.empty()) { + std::string tableParam = getTableParamByKey(paramKeyForInfo); + AMDA::Info::ParamInfoSPtr paramTableInfo = AMDA::Info::ParamMgr::getInstance()->getParamInfoFromId(tableParam); + if (paramTableInfo != nullptr) + return paramTableInfo->getUnits(); + } + } + return _tableUnits; } @@ -137,6 +163,10 @@ ParamBoundsTable::ParamBoundsTable(const char *paramId) : { } +std::string ParamBoundsTable::getTableParamKeyForInfo() { + return ParamBoundsTable::_boundsParamKey; +} + /* * @brief Get size of the table */ @@ -183,6 +213,10 @@ ParamCenterTable::ParamCenterTable(const char *paramId, double size) : { } +std::string ParamCenterTable::getTableParamKeyForInfo() { + return ParamCenterTable::_centersParamKey; +} + /* * @brief Get size of the table */ @@ -239,6 +273,10 @@ ParamCenterWidthTable::ParamCenterWidthTable(const char *paramId) : { } +std::string ParamCenterWidthTable::getTableParamKeyForInfo() { + return ParamCenterWidthTable::_centersParamKey; +} + /* * @brief Get size of the table */ @@ -295,6 +333,10 @@ ParamCenterAutoTable::ParamCenterAutoTable(const char *paramId, bool log) : { } +std::string ParamCenterAutoTable::getTableParamKeyForInfo() { + return ParamCenterAutoTable::_centersParamKey; +} + /* * @brief Get size of the table */ diff --git a/src/Info/ParamTable.hh b/src/Info/ParamTable.hh index d3231e1..bea63f1 100644 --- a/src/Info/ParamTable.hh +++ b/src/Info/ParamTable.hh @@ -40,6 +40,8 @@ namespace Info { virtual int getSize(ParameterManager *parameterManager) = 0; + virtual std::string getTableParamKeyForInfo(); + virtual t_TableBound getBound(ParameterManager *parameterManager, unsigned int index, std::map>* paramsTableData = NULL) = 0; void setParameterLink(ParameterSPtr parameter); @@ -94,6 +96,8 @@ namespace Info { public: ParamBoundsTable(const char *paramId); + virtual std::string getTableParamKeyForInfo(); + virtual int getSize(ParameterManager *parameterManager); virtual t_TableBound getBound(ParameterManager *parameterManager, unsigned int index, std::map>* paramsTableData = NULL); @@ -110,6 +114,8 @@ namespace Info { public: ParamCenterTable(const char *paramId, double size); + virtual std::string getTableParamKeyForInfo(); + virtual int getSize(ParameterManager *parameterManager); virtual t_TableBound getBound(ParameterManager *parameterManager, unsigned int index, std::map>* paramsTableData = NULL); @@ -129,6 +135,8 @@ namespace Info { public: ParamCenterWidthTable(const char *paramId); + virtual std::string getTableParamKeyForInfo(); + virtual int getSize(ParameterManager *parameterManager); virtual t_TableBound getBound(ParameterManager *parameterManager, unsigned int index, std::map>* paramsTableData = NULL); @@ -146,6 +154,8 @@ namespace Info { public: ParamCenterAutoTable(const char *paramId, bool log); + virtual std::string getTableParamKeyForInfo(); + virtual int getSize(ParameterManager *parameterManager); virtual t_TableBound getBound(ParameterManager *parameterManager, unsigned int index, std::map>* paramsTableData = NULL); -- libgit2 0.21.2