/*
    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 WBST_SINGLETEST
#define WBST_SINGLETEST
#include "wbst_headers.h"
#include "question.h"

struct SingleTestResult
{
	SingleTestResult();
	size_t good;
	size_t bad;
	size_t skipped;
};

std::ostream & operator << (std::ostream&, const SingleTestResult &);

class SingleTest
{
				public:
	/**
	  * Public constructor for single test
	  * \param pMatrix Pointer to matrix to be loaded
	  * \param questions Vector with questions to be checked
	  * \param pCmp Pointer to compare function
	  * \param flex_class Flex class to find words, if it's not provided in WBST file
	  * \param logfile Output file, where results will be stored
	  */
	SingleTest( Matrices::SuperMatrixPtr pMatrix, std::vector<WBSTQuestion> questions,
				smartcomparator::compare::CompareFunctionPtr pCmp,
				const std::string &flex_class,std::string logfile);

	/**
	  * Function running tests for all questions loaded
	  */
	void runTest();

	/**
	  * Function returning results in short form
	  * \returns Aggregated results
	  */
	SingleTestResult GetAggregatedResults();
	/**
	  * Function saving test results to logfile
	  */
	void WriteResults();

				private:
	/**
	  * Function performing test on single question
	  */
	void SingleQuestion(size_t question_no);

	Matrices::SuperMatrixPtr m_pMatrix;
	std::vector<WBSTQuestion> m_vQuestions;
	std::string m_sLogFile;
	smartcomparator::compare::CompareFunctionPtr m_pCmp;
	std::string m_sFlexClass;

	std::set<size_t> m_vGoodIndices;
	std::map<size_t, std::string> m_mBadToChoosen;
	std::set<size_t> m_vSkippedIndices;

};

typedef boost::shared_ptr<SingleTest> SingleTestPtr;

#endif //WBST_SINGLETEST

