// This may look like C code, but it is really -*- C++ -*-
// Adaptateur d objets (pour NamedObjMgr) 
// pour les classes TMatrix<T>, TVector<T> de Sophya
//                                      Reza 11/99
//  LAL-IN2P3/CNRS               CEA-DAPNIA     
 
#ifndef NOMTMATVECADAPTER_H_SEEN
#define NOMTMATVECADAPTER_H_SEEN

#include "nomgadapter.h"
#include "tmatrix.h"
#include "generaldata.h"

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

template <class T> 
class NOMAdapter_TMatrix : public NObjMgrAdapter {
public:
				NOMAdapter_TMatrix(TMatrix<T>* m = NULL);
  virtual			~NOMAdapter_TMatrix();

  virtual NObjMgrAdapter*	Clone(AnyDataObj* o);

  virtual string		GetDataObjType();

  virtual AnyDataObj*		CloneDataObj(bool share=false);

// Returns a string with synthetic information about the object 
// opts : additional optional argument 
  virtual string                GetInfoString(vector<string>& opts);
// Perform an operation on the object definded 
// opts : operation definition 
  virtual int                   PerformOperation(vector<string>& opts);

  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);

protected:
  TMatrix<T>* mMtx;
};

// Class Interface NTuple pour TMatrix<T>

template <class T> 
class NTupInt_TMatrix : public NTupleInterface {
public:
			NTupInt_TMatrix(TMatrix<T>* m);
  virtual		~NTupInt_TMatrix();
  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:
  TMatrix<T>* mMtx;
  mutable r_8 mRet[8];
};


#endif
