#ifndef _NICE_OBJREC_GENERICKERNELSELECTION_INCLUDE
#define _NICE_OBJREC_GENERICKERNELSELECTION_INCLUDE

#include <vector>
#include "KernelRBF.h"
#include "KernelExp.h"
#include "KernelHIK.h"
#include "KernelEXPHIK.h"

namespace OBJREC
{

class GenericKernelSelection
{
  public:

    static Kernel *selectKernel ( const NICE::Config *conf, std::string kernel_type )
    {
      Kernel *kernel = NULL;

      if ( kernel_type == "rbf" )
      {
        double log_rbf_gamma = conf->gD ( "Kernel","log_rbf_gamma",-2.5 );
        kernel = new KernelRBF ( log_rbf_gamma );
      }
      else if ( kernel_type == "exp" )
      {
        double log_rbf_gamma = conf->gD ( "Kernel","log_rbf_gamma",-2.5 );
        double log_rbf_sv = conf->gD ( "Kernel","log_rbf_sv",0.0 );
        kernel = new KernelExp ( log_rbf_gamma, log_rbf_sv );
      }
      else if ( kernel_type == "hik" )
      {
        double alpha = conf->gD ( "Kernel","alpha",1.0 );
        double beta = conf->gD ( "Kernel","beta",1.0 );
        kernel = new KernelHIK ( alpha, beta );
      }
      else if ( kernel_type == "exphik" )
      {
        double alpha = conf->gD ( "Kernel","alpha",1.0 );
        double beta = conf->gD ( "Kernel","beta",1.0 );
        double gamma = conf->gD ( "Kernel","gamma",1.0 );
        kernel = new KernelEXPHIK ( gamma, alpha, beta );
      }      
      else
      {
        fthrow ( NICE::Exception, "Kernel type " << kernel_type << " is unknown" );
      }

      return kernel;
    }

};

}

#endif
