// This may look like C code, but it is really -*- C++ -*-
// Adaptateur d objets (pour NamedObjMgr) pour Histos/NTuple
//                                    Reza 05/99
//  LAL-IN2P3/CNRS               CEA-DAPNIA     
 
#ifndef NOMHISTADAPTER_H_SEEN
#define NOMHISTADAPTER_H_SEEN

#include "nomgadapter.h"
#include "histos.h"
#include "histos2.h"
#include "hisprof.h"
#include "ntuple.h"
#include "basedtable.h"

//-----------------------------------------------------------------------------
// Class Adaptateur d'objet (Pour NamedObjMgr) d'objet Histo / HProf
//-----------------------------------------------------------------------------

class NOMAdapter_Histo : public NObjMgrAdapter {
public:
				NOMAdapter_Histo(Histo* h = NULL);
  virtual			~NOMAdapter_Histo();

  virtual NObjMgrAdapter*	Clone(AnyDataObj* o);

  virtual string		GetDataObjType();

  virtual AnyDataObj*		CloneDataObj(bool share=false);

  virtual void			SavePPF(POutPersist& s, string const & nom);

// Returns a string with synthetic information about the object
  virtual string                GetInfoString(int lev=0);

  virtual string                GetInfoString(vector<string>& opts);

  virtual void			Print(ostream& os, int lev=0);
  virtual PIDrawer*		GetDrawer(string& dopt);
  virtual NTupleInterface*	GetNTupleInterface(bool& adel);

  virtual GeneralFitData* GetGeneralFitData(bool& adel
          ,GeneralFitData::FitErrType errtype=GeneralFitData::DefaultError
          ,double errscale=1.,double errmin=0.
          ,int i1=0,int i2=-1,int j1=0,int j2=-1);
  virtual AnyDataObj* FitResidusObj(GeneralFit& mfit);
  virtual AnyDataObj* FitFunctionObj(GeneralFit& mfit);

protected:
  Histo* mHis;
};

// Class Interface NTuple pour Histo / HProf
class NTupInt_Histo : public NTupleInterface {
public:
			NTupInt_Histo(Histo* h);
  virtual		~NTupInt_Histo();
  virtual sa_size_t     NbLines() const ;
  virtual sa_size_t     NbColumns() const ;
  virtual r_8 *         GetLineD(sa_size_t n) const ;
  virtual string        VarList_C(const char* nomx=NULL) const ;
protected:
  Histo* mHis;
  HProf* mHpr;
  mutable r_8 mRet[5];
};

//-------------------------------------------------------------------------
// Class Adaptateur d'objet (Pour NamedObjMgr) d'objet Histo2D
//-------------------------------------------------------------------------

class NOMAdapter_Histo2D : public NObjMgrAdapter {
public:
				NOMAdapter_Histo2D(Histo2D* h = NULL);
  virtual			~NOMAdapter_Histo2D();

  virtual NObjMgrAdapter*	Clone(AnyDataObj* o);

  virtual string		GetDataObjType();

  virtual AnyDataObj*		CloneDataObj(bool share=false);

  virtual void			SavePPF(POutPersist& s, string const & nom);

  virtual void			Print(ostream& os, int lev=0);
  virtual PIDrawer*		GetDrawer(string& dopt);
  virtual P2DArrayAdapter*      Get2DArray(string& dopt);
  virtual NTupleInterface*	GetNTupleInterface(bool& adel);

  virtual GeneralFitData* GetGeneralFitData(bool& adel
          ,GeneralFitData::FitErrType errtype=GeneralFitData::DefaultError
          ,double errscale=1.,double errmin=0.
          ,int i1=0,int i2=-1,int j1=0,int j2=-1);
  virtual AnyDataObj* FitResidusObj(GeneralFit& mfit);
  virtual AnyDataObj* FitFunctionObj(GeneralFit& mfit);

  virtual string                GetInfoString(vector<string>& opts);

protected:
  Histo2D* mHis;
};

// Class Interface NTuple pour Histo2D
class NTupInt_Histo2D : public NTupleInterface {
public:
			NTupInt_Histo2D(Histo2D* h);
  virtual		~NTupInt_Histo2D();
  virtual sa_size_t     NbLines() const ;
  virtual sa_size_t     NbColumns() const ;
  virtual r_8 *         GetLineD(sa_size_t n) const ;
  virtual string        VarList_C(const char* nomx=NULL) const ;
protected:
  Histo2D* mHis;
  mutable r_8 mRet[6];
};


//-------------------------------------------------------------------------
// Class Adaptateur d'objet (Pour NamedObjMgr) d'objet NTuple 
//-------------------------------------------------------------------------

class NOMAdapter_NTuple : public NObjMgrAdapter {
public:
				NOMAdapter_NTuple(NTuple* nt = NULL);
  virtual			~NOMAdapter_NTuple();

  virtual NObjMgrAdapter*	Clone(AnyDataObj* o);

  virtual string		GetDataObjType();

  virtual AnyDataObj*		CloneDataObj(bool share=false);

  virtual void			SavePPF(POutPersist& s, string const & nom);

  virtual string                GetInfoString(vector<string>& opts);
  virtual void			Print(ostream& os, int lev=0);
  virtual NTupleInterface*	GetNTupleInterface(bool& adel);

protected:
  NTuple* mNt;
};


//-------------------------------------------------------------------------
// Class Adaptateur d'objet (Pour NamedObjMgr) d'objet BaseDataTable 
//-------------------------------------------------------------------------

class NOMAdapter_DataTable : public NObjMgrAdapter {
public:
				NOMAdapter_DataTable(BaseDataTable* dt = NULL);
  virtual			~NOMAdapter_DataTable();

  virtual NObjMgrAdapter*	Clone(AnyDataObj* o);

  virtual string		GetDataObjType();

  virtual AnyDataObj*		CloneDataObj(bool share=false);

  virtual void			SavePPF(POutPersist& s, string const & nom);

  virtual string                GetInfoString(vector<string>& opts);
  virtual void			Print(ostream& os, int lev=0);
  virtual NTupleInterface*	GetNTupleInterface(bool& adel);

protected:
  BaseDataTable* mDT;
};



#endif
