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

namespace hal_architect
{
	enum ContextType{ Sentence, Window, HAL };

	class Config
	{
		public:
			std::string workdir;
			std::vector<LexicalUnits::LexicalUnitPtr> m_vLexicalUnits;
			std::vector<size_t> rowLU;// indices in lexicalUnits
			std::vector<size_t> columnLU;// indices in lexicalUnits
			std::map<size_t, std::string> columnToFlex;
			// placeholder for further use
			std::map<size_t, std::string> rowToFlex;

			std::string m_sMatrixName;
			std::string m_sCorpusInfo;
			std::vector<std::string> m_sCorpusFiles;

			/**
			  * Function initializing config based on application input parameters
			  */
			static Config* Initalize(int ac, char*av[]);
			/**
			  * Function returning static instance of Config
			  */
			static Config* GetInstance();
			/**
			  * Function sweeping memory after static instance of Config
			  */
			static void Delete();

			ContextType m_ContextType;

			size_t m_stWindowLeft;
			size_t m_stWindowRight;
			size_t m_stHALWindow;
			std::string m_sDistanceFunction;

			bool m_bFilterDisamb;
		private:
			static Config* m_pInstance;
			/**
			  * Constructor
			  */
			Config(int ac, char*av[]);

			/**
			  * Function parsing input parameters
			  */
			void InitalizeProgramOptions(int ac, char* av[]);

			/**
			  * Function loading lines (usually words) from file into vector
			  * \param vec Output vector for lines
			  */
			void LoadStringVectror(const std::string &filename, std::vector<std::string> &vec);
			/**
			  * Function loading row multiword lexical units from files specified in config file
			  */
			void LoadRowME();
			/**
			  * Function loading column multiword lexical units from files specified in config file
			  */
			void LoadColumnME();
			/**
			  * Function loading all row lexical units
			  */
			void LoadRowUnits();
			/**
			  * Function loading all column lexical units
			  */
			void LoadColumnUnits();

			/**
			  * Function loading single words from file
			  */
			void LoadSimpleWords(const std::string &filename, std::string& flex, std::vector<LexicalUnits::LexicalUnitPtr>&out);

			/**
			  * Function parsing input string and returning flex class contained in it
			  */
			Corpus::TFlexClass GetFlexClass(const std::string&);


			/**
			Format for normal units: words file#flex
			*/
			std::vector<std::string> m_vRowUnits;
			std::vector<std::string>  m_vRowTermFiles;
			std::vector<std::string> m_vColumnUnits;
			std::vector<std::string> m_vColumnTermFiles;
			bool m_bChceckDocuments;

			boost::shared_ptr<JOSKIPI::Parsers::CAntlrParser> m_OperatorParser;

	};
}//namespace hal_architect
#endif //ARCH2_CONFIG_H

