ParamTable.hh 4.62 KB
/**
 * ParamTable.hh
 *
 *  Created on: 10 oct. 2014
 *  Author: AKKA
 */

#ifndef PARAMTABLE_HH_
#define PARAMTABLE_HH_

#include "ParameterManager.hh"

#include "log4cxx/logger.h"

namespace AMDA {
namespace Info {

	using namespace AMDA::Parameters;

	/**
	 * @brief Structure that's define a table bound
	 */
	typedef struct {
		int index;
		double min;
		double max;
	} t_TableBound;

	/**
	 * @class ParamTable
	 * @brief Abstract class used to define a Parameter table .
	 * @details
	 */
	class ParamTable
	{
	public:
		ParamTable(const char *paramId);

		virtual ~ParamTable();

		virtual int getSize(ParameterManager *parameterManager) = 0;

		virtual t_TableBound getBound(ParameterManager *parameterManager, unsigned int index, std::map<std::string, std::vector<double>>* paramsTableData = NULL) = 0;

		void setParameterLink(ParameterSPtr parameter);

		void setName(std::string name);

		std::string getName(void);

		void setUnits(std::string name);

		std::string getUnits(void);

		void setIsVariable(bool isVariable);

		bool isVariable(void);

		void addTableParam(std::string key, std::string name);

		std::string getTableParamByKey(std::string key);

		std::map<std::string, std::string>& getTableParams();

	protected:
		/** logger of paramTable */
		static log4cxx::LoggerPtr _logger;

		std::string _paramId;

		std::string _tableName;

		std::string _tableUnits;

		bool _variable;

		std::map<std::string, std::string> _tableParams;

		std::vector<double> getTableParamValuesByKey(ParameterManager *parameterManager, std::map<std::string, std::vector<double>>* paramsTableData, std::string key);

		std::vector<double> getConstantTableParamValuesByKey(ParameterManager *parameterManager, std::string key);

		std::vector<double> getVariableTableParamValuesByKey(std::map<std::string, std::vector<double>>* paramsTableData, std::string key);
	};

	/**
	 * @class ParamBoundsTable
	 * @brief Implementation of a ParamTable for a table defined by a list
	 * @details
	 */
	class ParamBoundsTable : public ParamTable {
	public:
		ParamBoundsTable(const char *paramId);

		virtual int getSize(ParameterManager *parameterManager);

		virtual t_TableBound getBound(ParameterManager *parameterManager, unsigned int index, std::map<std::string, std::vector<double>>* paramsTableData = NULL);

		static std::string _boundsParamKey;
	};

	/**
	 * @class ParamCenterTable
	 * @brief Implementation of a ParamTable for a table defined by a list of center value and a size
	 * @details
	 */
	class ParamCenterTable : public ParamTable {
	public:
		ParamCenterTable(const char *paramId, double size);

		virtual int getSize(ParameterManager *parameterManager);

		virtual t_TableBound getBound(ParameterManager *parameterManager, unsigned int index, std::map<std::string, std::vector<double>>* paramsTableData = NULL);

		static std::string _centersParamKey;

	private:
		double _size;
	};

	/**
	 * @class ParamCenterWidthTable
	 * @brief Implementation of a ParamTable for a table defined by a list of center value and a list of band width
	 * @details
	 */
	class ParamCenterWidthTable : public ParamTable {
	public:
		ParamCenterWidthTable(const char *paramId);

		virtual int getSize(ParameterManager *parameterManager);

		virtual t_TableBound getBound(ParameterManager *parameterManager, unsigned int index, std::map<std::string, std::vector<double>>* paramsTableData = NULL);

		static std::string _centersParamKey;
		static std::string _widthsParamKey;
	};

	/**
	 * @class ParamCenterAutoTable
	 * @brief Implementation of a ParamTable for a table defined by a list of center value. Bounds automatically computed to be at the center of two consecutive channels
	 * @details
	 */
	class ParamCenterAutoTable : public ParamTable {
	public:
		ParamCenterAutoTable(const char *paramId, bool log);

		virtual int getSize(ParameterManager *parameterManager);

		virtual t_TableBound getBound(ParameterManager *parameterManager, unsigned int index, std::map<std::string, std::vector<double>>* paramsTableData = NULL);

		static std::string _centersParamKey;

	private:
		bool _log;
	};

	/**
	 * @class ParamMinMaxTable
	 * @brief Implementation of a ParamTable for a table defined by two list: one for min and one for max
	 * @details
	 */
	class ParamMinMaxTable : public ParamTable {
		public:
			ParamMinMaxTable(const char *paramId);

			virtual int getSize(ParameterManager *parameterManager);

			virtual t_TableBound getBound(ParameterManager *parameterManager, unsigned int index, std::map<std::string, std::vector<double>>* paramsTableData = NULL);

			static std::string _minParamKey;
			static std::string _maxParamKey;
	};
} /* namespace Info */
} /* namespace AMDA */

#endif /* PARAMTABLE_HH_ */