/*
    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.
*/

#include "config.h"


Config * Config::instance = NULL;

Config* Config::getInstance()
{

	return instance;
}

void Config::loadOptions(int ac,char** av)
{


	using namespace boost::program_options;

	selfSimilarity = 0;
	options_description options("Similarity parallel options", 400);

	options.add_options()
			("help", "Prints this text")

			("matrix-filename", value<std::string>(&matrixName), "Name of the matrix")
			("matrix-type", value<std::string>(&typeOfMatrix), "Type of storage matrix, one of: supermatrix, textfile, densematrix")
			("label-file", value<std::string>(&labelFile), "File with row labels")
			("results-file", value<std::string>(&outputFile), "File storing results")
			("minimum-similarity", value<double>(&minimalSimilarity)->default_value(0.0001), "Minimum similarity of rows")
			("k-best-results", value<int>(&kBestResults)->default_value(20), "Number of best results to display")
			("selfsim","If similarity to self should be written")
			;
	variables_map vm;
	store(parse_command_line(ac, av, options), vm);
	notify(vm);

	if(vm.count("selfsim"))
	{
		selfSimilarity = 1;
	}

	if( vm.count("help") )
	{
		std::cout << "Parallel similarity\n\n";
		std::cout << options << std::endl;
		exit(0);
	}
	if( !vm.count("matrix-type"))
		typeOfMatrix="";

	if(!vm.count("matrix-filename") || !vm.count("label-file") || !vm.count("results-file"))
	{
		std::cout << "One or more required arguments missing \n";
		exit(0);
	}

}

void Config::initialize(int ac, char**av)
{
	if(instance==NULL)
	{
		instance = new Config();
		instance->loadOptions(ac,av);

	}


}


