ParamOutputIntervalTrueFile.hh 2.76 KB
/**
 * ParamOutputIntervalTrueFile.hh
 *
 *  Created on: 18 oct. 2012
 *      Author: AKKA IS
 */

#ifndef ParamOutputIntervalTrueFile_HH_
#define ParamOutputIntervalTrueFile_HH_

#include <iostream>
#include <fstream>
#include <string>

#include "ParamOutput.hh"
#include "OutputFormatTime.hh"

namespace AMDA {
namespace Parameters {

class ParameterManager;
class ParamData;
template <typename Type>
	class ParamDataSpec;

} // namespace Parameters

namespace ParamOutputImpl {
		namespace Download {

class PrintIntervalTrue;
typedef boost::shared_ptr<PrintIntervalTrue> PrintIntervalTrueSPtr;
extern log4cxx::LoggerPtr gLogger;

/**
 * AMDA::Parameters::ParamOutputIntervalTrueFile
 */
class ParamOutputIntervalTrueFile: public AMDA::Parameters::ParamOutput {
public:

	typedef std::vector<unsigned int> IndexList;
	typedef std::vector<std::string> InfoNammeList;

	ParamOutputIntervalTrueFile(AMDA::Parameters::ParameterManager& pParameterManager);
	virtual ~ParamOutputIntervalTrueFile();

	// Getter methods
	AMDA::Parameters::ParameterSPtr getParameter()               { return _parameter; }
	const std::string& getParamName() const { return _paramName; }
	IndexList& getIndexList()               { return _indexList; }
	OutputFormatTime getTypeFormatTime() const { return _typeFormatTime; }
	InfoNammeList& getCalibrationInfoNameList() { return _infoNameList; }
	void addCalibrationName(std::string pName){ _infoNameList.push_back(pName);	}

	// Setter methods
	void setParameter(AMDA::Parameters::ParameterSPtr parameter) { _parameter = parameter; }
	void setTypeFormatTime(OutputFormatTime typeFormatTime) { _typeFormatTime = typeFormatTime; }
	void setParamName(const std::string& paramName) { _paramName = paramName; }
	void setCalibrationInfoNameList(const InfoNammeList& pInfoNameList) { _infoNameList.insert(_infoNameList.end(),pInfoNameList.begin(),pInfoNameList.end()); }

	// Others methods
	virtual void establishConnection();

protected:

	/**
	 * @overload ParamOutput::init()
	*/
	virtual void init();

	/**
	 * @overload ParamOutput::apply()
	*/
	 virtual void apply();

	/**
	 * @brief start print (create file)
	 */
	 virtual void initOutput() ;
	virtual void endOutput() ;

	virtual void createCurrentfile();


	//attributes
	PrintIntervalTrueSPtr _printIntervalTrue;
	AMDA::Parameters::ParameterSPtr 		 _parameter;
	std::ofstream    _currentfile;
	std::string      _paramName;
	OutputFormatTime _typeFormatTime;
	/**
	 * @brief Indexes of _parameter ParamData to write into  _currentfile.
	 */
	IndexList _indexList;
	bool _firstVisit;
	std::stringstream _lFileName;
	/**
	 * @brief List of Calibration info to write into _currentfile.
	 */
	InfoNammeList _infoNameList;
};

		} // namespace Download
	} // namespace ParamOutputImpl
} /* namespace AMDA */
#endif /* ParamOutputIntervalTrueFile_HH_ */