/** 
* @file FeaturePool.h
* @brief collection of features
* @author Erik Rodner
* @date 04/21/2008

*/
#ifndef FEATUREPOOLINCLUDE
#define FEATUREPOOLINCLUDE

#include "Feature.h"
#include "core/basics/Persistent.h"
#include "core/basics/Config.h"
#include "vislearning/cbaselib/CachedExample.h"


namespace OBJREC {

/** collection of features */
class FeaturePool : public std::vector< std::pair<double, Feature *> >, public NICE::Persistent
{
    protected:
	std::vector<double> cumsum;
	const NICE::Config *conf;

    public:
	
	/** simple constructor */
	FeaturePool();
      
	/** constructor uses config */
	FeaturePool( const NICE::Config *conf );

	/** simple destructor */
	virtual ~FeaturePool();

	Feature *getRandomFeature () const;

	void initRandomFeatureSelection ();

	void addFeature ( Feature *f, double probability = 1.0 );

	void calcFeatureVector ( const Example & pe, NICE::Vector & x ) const;

	void destroy ();
     
	virtual void restore (std::istream & is, int format = 0);
	virtual void store (std::ostream & os, int format = 0) const;
	virtual void clear ();
};


} // namespace

#endif
