/** 
 * @file SparseVectorFeature.h
 * @brief feature class to use in Examples stored sparse features
 * @author Björn Fröhlich
 * @date 05/25/2009

 */
#ifndef SparseVectorFeatureINCLUDE
#define SparseVectorFeatureINCLUDE

#include "core/vector/VectorT.h"
#include "core/vector/MatrixT.h"
#include "core/image/ImageT.h"
#include "core/imagedisplay/ImageDisplay.h"
 
#include "core/basics/Config.h"
#include "vislearning/cbaselib/Feature.h"
#include "core/vector/SparseVectorT.h"


namespace OBJREC {

class SparseVectorFeature : public Feature
{

	protected:
		//! feature dimension
		int dimension;
		
		//! index of the feature
		int feature_index;

	public:
  
		/**
	 	 * internally used by SparseVectorFeature::explode
		 * @param _dimension new dimension
		 * @param _feature_index new featureindex
		 */
		SparseVectorFeature ( int _dimension, int _feature_index = 0 ) { dimension = _dimension; feature_index = _feature_index; };
      
		/**
		 * simple destructor
		 */
		virtual ~SparseVectorFeature();
     
		/**
		 * returns the value of the sparse feature stored in example
		 * @param example input example
		 * @return feature value
		 */
		double val( const Example *example ) const;
		
		
		/**
		 * creates for each feature a own SparseVectorFeature in featurepool
		 * @param featurePool the feature pool
		 * @param variableWindow 
		 */
		void explode ( FeaturePool & featurePool, bool variableWindow = true ) const;
		
		
		Feature *clone() const;
		Feature *generateFirstParameter () const;

		/**
		 * store the data
		 * @param is input stream
		 * @param format 
		 */
		void restore (std::istream & is, int format = 0);
		
		
		/**
		 * read the data
		 * @param os 
		 * @param format 
		 */
		void store (std::ostream & os, int format = 0) const;
		
		
		/**
		 * does nothing
		 */
		void clear ();

		
		/**
		 * returns the feature index and the dimension
		 * @param feature_index 
		 * @param dimension 
		 */
		void getStump ( int & feature_index, int & dimension ) const;

};


} // namespace

#endif