AbstractReader.hh 1.08 KB
/*
 * AbstractReader.h
 *
 *  Created on: 5 août 2013
 *      Author: CS
 */

#ifndef ABSTRACTREADER_H_
#define ABSTRACTREADER_H_

#include <string>
#include "TimeTable.hh"
#include "log4cxx/logger.h"
#include <memory>

namespace TimeTableCatalog {

/**
 * TimeTable reader Interface.
 */
class AbstractReader {
public:
	AbstractReader(const std::string& pPath);
	virtual ~AbstractReader();

	/**
	 * Reads a TT from a file.
	 */
	virtual void read(TimeTable& pTT) = 0;

	/**
	 * Checks the TT format to know if the reader is the good one.
	 */
	virtual bool canRead(const std::string& pPath) = 0;

	/**
	 * Creates an instance of this.
	 */
	virtual std::unique_ptr<AbstractReader> createInstance(
			const std::string& pPath) = 0;

protected:

	/**
	 * Logger
	 */
	static log4cxx::LoggerPtr _logger;

	std::string getLocalPath();

	const std::string& getPath() const {return _path;}

private:

	/**
	 * TT local file if _path is url as http://
	 */
	std::string _downloadedPath;
	/**
	 * TT file system path.
	 */
	std::string _path;

};

} /* namespace TimeTableCatalog */
#endif /* ABSTRACTREADER_H_ */