/**
* @file Feature.h
* @brief abstraction of a feature
* @author Erik Rodner
* @date 04/21/2008

*/
#ifndef FEATUREINCLUDE
#define FEATUREINCLUDE

#include <set>
#include <map>

#include "vislearning/cbaselib/CachedExample.h"
#include "vislearning/cbaselib/Example.h"
#include "core/basics/Persistent.h"
#include "core/basics/triplet.h"
#include "core/basics/quadruplet.h"

//#include "FeaturePool.h"

namespace OBJREC {

class FeaturePool;

#define ROADWORKS { fprintf(stderr, "not yet implemented !\n"); exit(-1); }

/* stores a sorted set of feature values: value classno index weight **/
class FeatureValues : public std::set< NICE::quadruplet<double, int, int, double> > {};
class FeatureStorage : public std::map< int, FeatureValues > {};

/* stores an unsorted set of feature values: value classno index weight **/
class FeatureValuesUnsorted : public std::vector< NICE::quadruplet<double, int, int, double > > {};
class FeatureStorageUnsorted : public std::map< int, FeatureValuesUnsorted > {};


/** abstraction of a feature */
class Feature : public NICE::Persistent
{

protected:

public:

    /** simple constructor */
    Feature();

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

    virtual double val( const Example *example ) const = 0;

    virtual Feature *clone() const = 0;

    virtual void explode ( FeaturePool & featurePool, bool variableWindow = true ) const = 0;

    virtual void calcFeatureValues ( const Examples & examples,
                                     std::vector<int> & examples_selection,
                                     FeatureValuesUnsorted & values ) const;

    virtual void calcFeatureValues ( const Examples & examples,
                                     std::vector<int> & examples_selection,
                                     FeatureValues & values ) const;

};


} // namespace

#undef ROADWORKS

#endif

