/*
    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 ARCH2_CONFIG_H
#define ARCH2_CONFIG_H
#include "arch_headers.h"
#include "LexicalUnit.h"

namespace me_architect
{
	typedef boost::shared_ptr<JOSKIPI::Operators::CCondition> CondPtr;
	enum CorpusType{XML, POLIQARP};
	class Options;

	class Config
	{
		public:
			CorpusType m_CorpusType;
			std::string m_sWorkdir;
			std::string m_sCorpusFile;
			std::vector<std::string> documents;
			std::vector<LexicalUnits::LexicalUnitPtr> m_vLexicalUnits;
			std::vector<size_t> rowLU;// indices in lexicalUnits
			std::vector<size_t> columnLU;// indices in lexicalUnits
			std::vector<CondPtr> m_vConditions; //operators for columns
			std::map<size_t, std::string> columnToFlex;
			std::map<size_t, std::string> rowToFlex;
			bool m_bFilterDisamb;

			std::string m_sMatrixName;
			std::string m_sCorpusInfo;

			static Config* Initalize(int ac, char*av[]);
			static Config* GetInstance();
			static void Delete();

		private:
			static Config* m_pInstance;
			Config();

			void LoadStringVectror(const std::string &filename, std::vector<std::string> &vec);
			void LoadDocuments();
			void LoadRowME();
			void LoadRowUnits();

			void LoadOperators();
			std::string LoadSingleOperatorString(const std::string& filename);
			void LoadSimpleWords(const std::string &filename, std::string& flex,
				std::vector<LexicalUnits::LexicalUnitPtr>&out);
			void LoadMEForColumns(const std::string &filename, std::vector<LexicalUnits::LexicalUnitPtr> &out);
			Corpus::TFlexClass GetFlexClass(const std::string&);


			/**
			Format for normal units: op.file#words file#flex
			Format for ME: op.file#units file
			*/
			std::vector<std::string> m_vOperatorDefines;
			/**
			Format for normal units: words file#flex
			*/
			std::vector<std::string> m_vRowUnits;
			std::vector<std::string> m_vRowTermFiles;
			bool m_bChceckDocuments;
			boost::shared_ptr<JOSKIPI::Parsers::CAntlrParser> m_OperatorParser;


			friend class Options;

	};
}//namespace architect
#endif //ARCH2_CONFIG_H

