// Guy Le Meur 08/2000


#ifndef FITSLOCALMAP_SEEN
#define FITSLOCALMAP_SEEN


#include "pexceptions.h" 
#include "localmap.h"
#include "fitsfile.h"

namespace SOPHYA {


/////////////////////////////////////////////////////////////////////////
// Classe pour la gestion de persistance sur fichiers fits
/////////////////////////////////////////////////////////////////////////



template <class T>
class FITS_LocalMap : public FitsIOHandler {

  public :
FITS_LocalMap();
FITS_LocalMap(char inputfile[],int hdunum=0);
FITS_LocalMap(const LocalMap<T> & obj);
FITS_LocalMap(LocalMap<T> *obj);
virtual ~FITS_LocalMap();
virtual AnyDataObj* DataObj();
virtual   void      SetDataObj(AnyDataObj & o); 
inline operator LocalMap<T>() { return(*dobj_); }

protected :

void ReadFromFits(FitsInFile& is);
void WriteToFits(FitsOutFile& os) ;

  LocalMap<T> * dobj_;
  bool ownobj_;
};
//////////////////////////////////////////////////////////////////

template <class T>
inline FitsOutFile& operator << (FitsOutFile& fios, LocalMap<T> & lm)
  { FITS_LocalMap<T> fih(&lm); fih.Write(fios); return (fios); }

template <class T>
inline FitsInFile& operator >> (FitsInFile& fiis, LocalMap<T> & lm)
  { FITS_LocalMap<T> fih(&lm); fih.Read(fiis); return (fiis); }

} // Fin du namespace

#endif
