/*
    Copyright (C) 2012 Bartosz Broda, Jacek Bochenek, Łukasz Biłeńkij, 
    Damian Jaworski, Wojciech Mazur, Dominik Piasecki, Maciej Piasecki, 
    Radosław Ramocki
    
    This program is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your option)
any later version.

    This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. 

    See the LICENSE and COPYING files for more details.
*/

#ifndef MATRICESLIB_IO_SUPERMATRIXREADER_H
#define MATRICESLIB_IO_SUPERMATRIXREADER_H

#include "../matrices_headers.h"

#include "filesystem_error.h"
#include "../Feature.h"
#include "../SuperMatrix.h"

namespace Matrices
{
	class SuperMatrix;

	namespace IO
	{
		/**
		Nie obsluguje znakow konca linii w polach elementow plikow CSV (pliki cech). Uzywamy uproszczonego formatu CSV.
		*/
		class MATRICES_API SuperMatrixReader
		{
		public:
			SuperMatrixPtr Read(const std::string &dir, const std::string &matrix_name,
					bool ccs = true, bool crs = true);
		private:
			static void CheckDir(const std::string &dir,const std::string &matrix_name);
			static SuperMatrixPtr LoadMatrix(const std::string &dir, const std::string &matrix_name, bool ccs,
					bool crs, FeatureVectorPtr row_features, FeatureVectorPtr column_features);
			static FeatureVectorPtr  LoadFeatures(std::string filename);
		};

		void MATRICES_API CheckSuperMatrixFiles(const std::string &dir, const std::string &matrix_name, bool ccs = true, bool crs = true);

		SuperMatrixPtr MATRICES_API LoadSuperMatrix(const std::string &dir, const std::string &name, bool ccs = true, bool crs = true);
		std::map<size_t, std::string> TryLoadingBoundaries(const std::string &mdir, const std::string &mname);
		std::string NormalizeDir(const std::string &s);
	}
}

#endif // MATRICESLIB_IO_SUPERMATRIXREADER_H
