/*    
   --- SOPHYA software - FitsIOServer module ---
   Guy Le Meur 08/2000    R. Ansari , 2006 
   (C) UPS+LAL IN2P3/CNRS     (C) DAPNIA-SPP/CEA 
*/
#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_); }

virtual int         CheckHandling(AnyDataObj & o) ;
virtual int         CheckReadability(FitsInOutFile& is);
virtual FitsHandlerInterface* Clone();

protected :

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

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

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

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

} // Fin du namespace

#endif
