/*
    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 GENERICTRANSFORMER_H
#define GENERICTRANSFORMER_H
#include "../comparator_stdheaders.h"
#include "Transformation.h"
#include "../compare/CompareFunction.h"

namespace smartcomparator
{
	namespace transformations
	{
		/**
		  * Transformation changes content of Supermatrix in according to weight, filter and selector.
		  * Changes are made on original SuperMatrix, not on a copy.
		  */
		class GenericTransformer : public Transformation
		{
		public:
			GenericTransformer(Matrices::SuperMatrixPtr matrix,
					   weights::WeightFeaturePtr weight=boost::shared_ptr<weights::WeightFeature>(),
					   filters::FilterFeaturePtr filter=boost::shared_ptr<filters::FilterFeature>(),
					   selectors::SelectorPtr selector=boost::shared_ptr<selectors::Selector>(),
					   transformations::TransformationPtr transformation= boost::shared_ptr<transformations::Transformation>(),
					   bool showTime=true
					   );

			/**
			  * Transforms the matrix
			  */
			virtual void TransformMatrix();

		private:
			void Filtering(filters::FilterFeaturePtr filter, Matrices::CompressedVectorPtr row);
			void Selection(selectors::SelectorPtr selector, Matrices::CompressedVectorPtr row,size_t rowNo);
			void Weighting(weights::WeightFeaturePtr weight, Matrices::CompressedVectorPtr row,size_t rowNo);
			void RemoveIndices(Matrices::CompressedVectorPtr row,size_t rowNo);
			void Transforming(transformations::TransformationPtr transformation);


			Matrices::SuperMatrixPtr m_pMatrix;
			filters::FilterFeaturePtr m_pFilter;
			selectors::SelectorPtr m_pSelector;
			weights::WeightFeaturePtr m_pWeight;
			transformations::TransformationPtr m_pTransformation;
			std::set<size_t> filterN1;
			bool m_showTime;
		};
	}
}
#endif // GENERICTRANSFORMER_H
