FileReaderASCII.hh 1.73 KB
/*
 * FileReaderASCII.hh
 *
 *  Created on: Nov 24, 2014
 *  Author: AKKA
 */

#ifndef FILEREADERASCII_HH_
#define FILEREADERASCII_HH_

#include <fstream>

#include "FileReaderAbstract.hh"

namespace AMDA {
namespace LocalFileInterface {

/*
 * @brief Implementation of the class FileReaderAbstract to load a ASCII file format
 */
class FileReaderASCII : public FileReaderAbstract
{
public:
	static int MaxLineSize;

	/*
	 * @brief Constructor
	 */
	FileReaderASCII();

	/*
	 * @brief Destructor
	 */
	virtual ~FileReaderASCII();

	/*
	 * @brief Open a ASCII file
	 */
	virtual bool open(std::string filePath);

	/*
	 * @brief Close the ASCII file
	 */
	virtual bool close(void);

	/*
	 * @brief Test if a ASCII file is currently opened
	 */
	virtual bool isOpened(void);

	/*
	 * @brief Get the id of the time param to use. For the ASCII format, it's the first column
	 */
	virtual std::string getTimeParamId(void);

	/*
	 * @brief Get a param type and a param size in the ASCII file
	 */
	virtual bool getParamInfo(std::string& paramId, LocalParamType& paramType, int& dim1Size, int& dim2Size);

	/*
	 * @brief Get the index of the nearest record of time (the higher one) in the ASCII file
	 */
	virtual int getRecordIndex(std::string& timeId, double time);

	/*
	 * @brief Get a param packet from the ASCII file
	 */
	virtual FileReaderStatus getParamPacketData(std::string& timeId, std::string& paramId,
			int recordIndex, double stopTime, LocalParamDataPacket *packet);

	private:

	/*
	 * @brief Retreive value at specified column in the line
	 */
	bool getColumnAt (int colNum, const char *line, std::string &colValue);

	/*
	 * @brief ASCII identifier
	 */
	std::ifstream _asciiStream;

};

} /* LocalFileInterface */
} /* AMDA */

#endif /* FILEREADERASCII_HH_ */