/* * ParamInfo.hh * * Created on: Oct 6, 2014 * Author: m.mazel */ #ifndef PARAMINFO_HH_ #define PARAMINFO_HH_ #include #include #include #include #include #include "log4cxx/logger.h" #include "InfoLogger.hh" #include "ParamTable.hh" #include "StatusInfo.hh" #include "ParameterIndexesTool.hh" namespace AMDA { namespace Info { //Info keys for params #define PARAMETER_ID "PARAMETER_ID" #define PARAMETER_NAME "PARAMETER_NAME" #define PARAMETER_SHORT_NAME "PARAMETER_SHORT_NAME" #define PARAMETER_COMPONENTS "PARAMETER_COMPONENTS" #define PARAMETER_UNITS "PARAMETER_UNITS" #define PARAMETER_COORDSYS "PARAMETER_COORDINATE_SYSTEM" #define PARAMETER_TENSOR "PARAMETER_TENSOR_ORDER" #define PARAMETER_SICONV "PARAMETER_SI_CONVERSION" #define PARAMETER_FILLVALUE "PARAMETER_FILL_VALUE" #define PARAMETER_UCD "PARAMETER_UCD" #define PARAMETER_STATUS_NAME "PARAMETER_STATUS_NAME" #define PARAMETER_STATUS_MIN "PARAMETER_STATUS_MIN" #define PARAMETER_STATUS_MAX "PARAMETER_STATUS_NAX" #define PARAMETER_PROCESS_INFO "PARAMETER_PROCESS_INFO" #define PARAMETER_PROCESS_DESC "PARAMETER_PROCESS_DESC" #define PARAMETER_LINKED_PARAM "PARAMETER_LINKED_PARAMS" #define TABLES_DESCRIPTION "TABLES_DESCRIPTION" #define PARAMETER_INFO "INFO_TABLE" #define UNSPECIFIED_UNIT "unspecified" /** * @class ParamInfo * @brief Information about a parameter. * @details */ class ParamInfo { public: ParamInfo () : _id(""), _name(""), _short_name(""), _components(""), _units(""), _coordinates_system(""), _tensor_order(0), _si_conversion(""), _original_fill_value(NAN), _fill_value(NAN), _ucd(""), _statusDef(), _processInfo(""), _processDesc(""), _linkedParamList(), _dataset_id(""), _instrument_id("") {} ParamInfo(const ParamInfo& info) : _id(info._id), _name(info._name), _short_name(info._short_name), _components(info._components), _units(info._units), _coordinates_system(info._coordinates_system), _tensor_order(info._tensor_order), _si_conversion(info._si_conversion), _tables(info._tables), _original_fill_value(info._original_fill_value), _fill_value(info._fill_value), _ucd(info._ucd), _statusDef(info._statusDef), _processInfo(info._processInfo), _processDesc(info._processDesc), _linkedParamList(info._linkedParamList), _dataset_id(info._dataset_id), _instrument_id(info._instrument_id) {} friend std::ostream& operator<<(std::ostream& out_, const ParamInfo& dsi); /* * @brief Get parameter Id */ const std::string& getId() const { return _id; } /* * @brief Set parameter Id */ void setId(const std::string& id) { _id = id; } /* * @brief Get parameter name */ const std::string& getName() const { return _name; } /* * @brief Set parameter name */ void setName(const std::string& name) { _name = name; } /* * @brief Get parameter short name */ const std::string& getShortName() const { return _short_name; } /* * @brief Set parameter short name */ void setShortName(const std::string& shortName) { _short_name = shortName; } /* * @brief Get parameter components */ std::string getComponents(AMDA::Common::ParameterIndexComponent componentIndex=AMDA::Common::ParameterIndexComponent(-1,-1)) { if ((componentIndex.getDim1Index() == -1) && (componentIndex.getDim2Index() == -1)) { return _components; } else { if (_components.empty() == false) { // Extract values separated by a comma std::stringstream sStream(_components); std::vector componentList; std::string element; if (componentIndex.getDim2Index() == -1) { while (std::getline(sStream, element, ',')) { componentList.push_back(element); } // Return the componenet associated with the index if (((int) componentList.size()) > componentIndex.getDim1Index()) { return componentList.at (componentIndex.getDim1Index()); } else { return std::string(); } } else { while (std::getline(sStream, element, ';')) { componentList.push_back(element); } if ((componentIndex.getDim1Index() < 0) || (componentIndex.getDim1Index() > (int) componentList.size())) return componentList.at (componentIndex.getDim1Index()); sStream.str(componentList.at(componentIndex.getDim1Index())); componentList.clear(); while (std::getline(sStream, element, ',')) { componentList.push_back(element); } // Return the componenet associated with the index if (((int) componentList.size()) > componentIndex.getDim2Index()) { return componentList.at (componentIndex.getDim2Index()); } else { return std::string(); } } } else { return std::string(); } } } /* * @brief Set parameter components */ void setComponents(const std::string& components) { _components = components; } /* * @brief Get parameter units */ const std::string& getUnits() const { return _units; } /* * @brief Set parameter units */ void setUnits(const std::string& units) { _units = units; } /* * @brief Get parameter cordinate system */ const std::string& getCoordinatesSystem() const { return _coordinates_system; } /* * @brief Set parameter coordinate system */ void setCoordinatesSystem(const std::string& coordinatesSystem) { _coordinates_system = coordinatesSystem; } /* * @brief Get parameter tensor order */ int getTensorOrder() const { return _tensor_order; } /* * @brief Set parameter tensor order */ void setTensorOrder(int tensorOrder) { _tensor_order = tensorOrder; } /* * @brief Get parameter SI conversion */ const std::string& getSiConversion() const { return _si_conversion; } /* * @brief Set parameter SI conversion */ void setSiConversion(const std::string& siConversion) { _si_conversion = siConversion; } /* * @brief Get parameter table from dimension */ boost::shared_ptr getTable(int dim) { return _tables[dim]; } /* * @brief Add a table to the parameter for a given dimension */ void addTable(int dim, boost::shared_ptr& tableSPtr) { _tables[dim] = tableSPtr; } /* * @brief Get all parameter tables */ std::map>& getTables() { return _tables; } /* * @brief Get parameter original fill value (fill value defined in the parameter XML file) */ double getOriginalFillValue() const { return _original_fill_value; } /* * @brief Set parameter original fill value (fill value defined in the parameter XML file) */ void setOriginalFillValue(double fillValue) { _original_fill_value = fillValue; } /* * @brief Get parameter fill value */ double getFillValue() const { return _fill_value; } /* * @brief Set parameter fill value */ void setFillValue(double fillValue) { _fill_value = fillValue; } /* * @brief Get parameter UCD */ const std::string& getUcd() const { return _ucd; } /* * @brief Set parameter UCD */ void setUcd(const std::string& ucd) { _ucd = ucd; } /* * @brief Add parameter status for a given min/max values */ void addStatus(double minVal, double maxVal, std::string name, std::string color = "") { StatusInfo info; info.setRange(minVal,maxVal); info.setName(name); info.setColor(color); _statusDef.push_back(info); } /* * @brief Get list of parameter status */ const std::vector& getStatusDef() const { return _statusDef; } /* * @brief Set information about parameter process */ void setProcessInfo(const std::string& processInfo) { _processInfo = processInfo; } /* * @brief Get information about parameter process */ const std::string& getProcessInfo() const { return _processInfo; } void addAdditionalInfo(std::string key, std::string value) { _additionalInfo[key] = value; } /* * @brief Get information about parameter process */ const std::map getAdditionInfo() const { return _additionalInfo; } /* * @brief Set a description of the parameter process */ void setProcessDescription(const std::string& processDesc) { _processDesc = processDesc; } /* * @brief Get the description of the parameter process */ const std::string& getProcessDescription() const { return _processDesc; } /* * @brief Get a list of linked parameters to this parameter */ const std::vector& getLinkedParamList() const { return _linkedParamList; } /* * @brief Add a parameter id to the linked parameter list */ void addLinkedParamId(const std::string& paramId) { _linkedParamList.push_back(paramId); } /* * @brief Get the associated dataset id */ const std::string& getDatasetId() const { return _dataset_id; } /* * @brief Set the associated dataset id */ void setDatasetId(const std::string& datasetId) { _dataset_id = datasetId; } /* * @brief Get the associated instrument id (for informational purposes, can be used to write in a legend for example) */ const std::string& getInstrumentId() const { return _instrument_id; } /* * @brief Set the associated instrument id (for informational purposes, can be used to write in a legend for example) */ void setInstrumentId(const std::string& instrumentId) { _instrument_id = instrumentId; } /* * @brief Get a map with parameter info */ std::vector> getInfoMap(ParameterManager *parameterManager); /* * @brief Get a map with variable table info */ std::vector> getTableInfoMap(ParameterManager *parameterManager); protected: std::string _id; std::string _name; std::string _short_name; std::string _components; std::string _units; std::string _coordinates_system; int _tensor_order; std::string _si_conversion; std::map> _tables; double _original_fill_value; double _fill_value; std::string _ucd; std::vector _statusDef; std::string _processInfo; std::string _processDesc; std::vector _linkedParamList; std::string _dataset_id; std::string _instrument_id; std::map _additionalInfo; static log4cxx::LoggerPtr _logger; }; typedef boost::shared_ptr ParamInfoSPtr; typedef std::map ParamInfoMap; } /* namespace Info */ } /* namespace AMDA */ #endif /* PARAMINFO_HH_ */