#ifndef RADIALSCHEME_H
#define RADIALSCHEME_H

#include <misc_tools.h>
#include <xml_parameters.h>

//Hello, this is class RadialScheme... It is constructed around one particular function: its 1D-DENSITY function that defines the local cell density in each region of the image, as a function of radius r to center of image.
//Two other functions are the integral of the density function and the inverse of the integral.

//The three functions are defined as virtual functions, and must be defined in chidren objects (only child for the moment is LogPolarFoveaHandler).

// The last two functions are only required if you start using a layer of discrete spiking units. The last two functions possess a default definition, consisting of integrating the density function step by step (the basic spatial unity being supposed to be one pixel). But it is more precise and faster, to also define explicitly the two integral functions, when they have an analytical formula.

//Honestly, I dont see why you should bother to use soething else than a log-polar scheme, but well... Who KNOWS??


//Some static variables and functions are here to tell whether a RadialScheme was created or not, and to point to the last created (and only one, if the code is well written) RadialScheme, which is the 'effective' one in all programs that use a RadialScheme.
//If no RadialScheme was created, then RadialScheme::instance()=NULL
//If a RadialScheme fov was created (or a child object fov), then RadialScheme::instance()=&fov

//class UniqueRadialSchemePointer is a hidden class necessary for this job, that I could not suppress: if I include rsPointer directly in class RadialScheme, I get a bug when initializing rsPointer, probably at the level of the inheritance of RadialScheme by class LogPolarRadialScheme...? unresolved bug!



class RadialScheme: virtual public xmlClass
{
public:

static RadialScheme * instance();
static void dontUse();

  RadialScheme();
  virtual ~RadialScheme();

  virtual double density(double r);
  virtual double integratedDensity(double r);
  virtual double findRadius(double integrated_density);

  
//just for information: I still dont understand why the below code would not work
/*
protected:
  static RadialScheme * rsPointer;
public:
  //static RadialScheme * instance () {return rsPointer;}
*/
};

//a hidden class... that I could not suppress (see upper text)
class UniqueRadialSchemePointer
{
friend class RadialScheme;
static RadialScheme * rsPointer;
};

#endif
