DownloadProperties.hh 2.65 KB
/*
 * DownLoadProperties.hh
 *
 *  Created on: Oct 1, 2014
 *      Author: m.mazel
 */

#ifndef DOWNLOADPROPERTIES_HH_
#define DOWNLOADPROPERTIES_HH_

#include <string>

#include "OutputFormatTime.hh"
#include "ParamProperties.hh"

namespace AMDA {
namespace ParamOutputImpl {
namespace Download {

enum OutputFileFormat {
	ASCII_FILE_FORMAT,
	CDF_FILE_FORMAT,
	NETCDF_FILE_FORMAT,
	JSON_FILE_FORMAT,
	VOT_FILE_FORMAT
};

enum OutputStructure {
	ONE_FILE,
	ONE_FILE_REFPARAM,
	ONE_FILE_PER_INTERVAL,
	ONE_FILE_PER_INTERVAL_REFPARAM,
	ONE_FILE_PER_PARAMETER_PER_INTERVAL
};

static std::map<OutputStructure,std::string> ouputStructureToStr = {
		{OutputStructure::ONE_FILE, "all-in-one-file"},
		{OutputStructure::ONE_FILE_REFPARAM, "all-in-one-file-refparam"},
		{OutputStructure::ONE_FILE_PER_INTERVAL, "one-file-per-interval"},
		{OutputStructure::ONE_FILE_PER_INTERVAL_REFPARAM, "one-file-per-interval-refparam"},
		{OutputStructure::ONE_FILE_PER_PARAMETER_PER_INTERVAL, "one-file-per-parameter-per-interval"}
};

typedef std::vector<ParamProperties *> ParamPropertiesList;

/**
 * @class DownloadProperties
 * @brief Properties of a download request.
 * @details
 */
class DownloadProperties {
public:
	DownloadProperties();
	virtual ~DownloadProperties();
	OutputFileFormat getFileFormat() const;
	void setFileFormat(OutputFileFormat fileFormat);
	const std::string& getFileName() const;
	void setFileName(const std::string& fileName);
	OutputStructure getOutputStructure() const;
	void setOutputStructure(OutputStructure outputStructure);
	OutputFormatTime getTimeFormat() const;
	void setTimeFormat(OutputFormatTime timeFormat);
	double getTimeResolution() const;
	void setTimeResolution(double timeResolution);
	ParamPropertiesList& getParamPropertiesList();
	ParamProperties* getParamPropertiesFromOriginalId(std::string originalId);
	ParamProperties* getParamPropertiesFromOutputId(std::string outputId);
	void addParamProperties(ParamProperties *paramProperties);
	bool getPrecision(void) const;
	void setPrecision(bool precision);

private:
	/**
	 * format of time
	 */
	OutputFormatTime _timeFormat;

	/**
	 * File format (see OutputFileFormat for supported format definition)
	 */
	OutputFileFormat _fileFormat;

	/**
	 * File name
	 */
	std::string _fileName;

	/**
	 * Parameter properties list
	 */
	ParamPropertiesList	_paramPropertiesList;

	/**
	 * Time resolution
	 */
	double _timeResolution;

	/**
	 * Output structure :
	 * - One file
	 * - One file per interval
	 */
	OutputStructure _outputStructure;

	/*
	 * Increase precision in output file
	 */
	bool _precision;
};

} // namespace Download
} // namespace ParamOutputImpl
} // namespace AMDA

#endif /* DOWNLOADPROPERTIES_HH_ */