Index: trunk/SophyaExt/FitsIOServer/fabtwriter.h
===================================================================
--- trunk/SophyaExt/FitsIOServer/fabtwriter.h	(revision 2450)
+++ trunk/SophyaExt/FitsIOServer/fabtwriter.h	(revision 2453)
@@ -16,13 +16,16 @@
 namespace SOPHYA {
 
-//! Class for writing a FITS ASCII or BINARY table
-class FitsABTWriter : public AnyDataObj {
+///////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////
+//! Class for writing into a FITS file (DO NOT USE)
+class FitsWriter : public AnyDataObj {
+protected:
+  FitsWriter(string fname,int lp=0);
+  FitsWriter(const char* cfname,int lp=0);
+  FitsWriter(string fname,bool update,int lp=0);
+  FitsWriter(const char* cfname,bool update,int lp=0);
+  virtual ~FitsWriter();
+
 public:
-  FitsABTWriter(string fname,int hdutype=BINARY_TBL,int lp=0);
-  FitsABTWriter(const char* cfname,int hdutype=BINARY_TBL,int lp=0);
-  FitsABTWriter(string fname,bool update,int hdutype=BINARY_TBL,int lp=0);
-  FitsABTWriter(const char* cfname,bool update,int hdutype=BINARY_TBL,int lp=0);
-  virtual ~FitsABTWriter();
-
   void Flush(void);
 
@@ -36,4 +39,48 @@
   inline void WriteKey(const char *keyname,char* val,char* comment=NULL)
                       {string dum=val; WriteKey(keyname,dum,comment);}
+  //! Set debug level
+  inline void SetDebug(int lp=0) {DbgLevel = (unsigned short) lp;}
+
+  //! Return the number of overflows managed by cfitsio
+  inline unsigned long GetNOverFlow(void) {return NOverFlow;}
+
+protected:
+  struct KeyDouble {string keyname; double val; string comment;};
+  struct KeyLong   {string keyname; long   val; string comment;};
+  struct KeyString {string keyname; string val; string comment;};
+
+  void cr_or_upd_fits(const char *cfname,bool update,int lp);
+
+  void writekeys(void);
+  void printerrorwrite(const char* type,int col,long row,int sta);
+  void printerror(int sta) const;
+
+  string FitsFN,ExtName;
+  bool Update;
+  int HduType;
+  unsigned short DbgLevel;
+  fitsfile *FitsPtr;
+  unsigned long NOverFlow;
+
+  vector<struct KeyDouble> DoubleKey;
+  vector<struct KeyLong>   LongKey;
+  vector<struct KeyString> StringKey;
+};
+
+///////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////
+//! Class for writing a FITS ASCII or BINARY table
+class FitsABTWriter : public FitsWriter {
+public:
+  FitsABTWriter(string fname,int hdutype=BINARY_TBL,int lp=0);
+  FitsABTWriter(const char* cfname,int hdutype=BINARY_TBL,int lp=0);
+  FitsABTWriter(string fname,bool update,int hdutype=BINARY_TBL,int lp=0);
+  FitsABTWriter(const char* cfname,bool update,int hdutype=BINARY_TBL,int lp=0);
+  virtual ~FitsABTWriter();
+
+  //! Set the FITS table extension name
+  inline void SetExtName(string extname=string("")) {ExtName = extname;}
+  //! Set the FITS table extension name
+  inline void SetExtName(char* extname="") {ExtName = extname;}
 
   //! Add a new column to the FITS table and return its number (see addcol).
@@ -45,11 +92,4 @@
                    ,const char* tunit="",int datatype=TDOUBLE)
      {return addcol(label,tform,tunit,datatype);}
-
-  //! Set the FITS table extension name
-  inline void SetExtName(string extname=string("")) {ExtName = extname;}
-  //! Set the FITS table extension name
-  inline void SetExtName(char* extname="") {ExtName = extname;}
-  //! Set debug level
-  inline void SetDebug(int lp=0) {DbgLevel = (unsigned short) lp;}
 
   void Write(int col,long row,uint_1 val);
@@ -66,6 +106,4 @@
   long Write(int col,long row,TVector<float>& val);
   long Write(int col,long row,TVector<double>& val);
-  //! Return the number of overflows managed by cfitsio
-  inline unsigned long GetNOverFlow(void) {return NOverFlow;}
 
   //! Return the number of created columns
@@ -78,30 +116,40 @@
 
 protected:
-  struct KeyDouble {string keyname; double val; string comment;};
-  struct KeyLong   {string keyname; long   val; string comment;};
-  struct KeyString {string keyname; string val; string comment;};
+  int addcol(const char* label,const char* tform,const char* tunit,int datatype);
+  void createtbl(void);
 
-  void cr_or_upd_fits(const char *cfname,bool update,int hdutype,int lp);
-  int addcol(const char* label,const char* tform
-            ,const char* tunit,int datatype);
-  void createtbl(void);
-  void writekeys(void);
-  void printerrorwrite(const char* type,int col,long row,int sta);
-  void printerror(int sta) const;
-
-  string FitsFN,ExtName;
-  bool Update;
-  int HduType;
-  unsigned short DbgLevel;
-  fitsfile *FitsPtr;
   bool FirstTime;
   vector<string> Label;
   vector<string> TForm;
   vector<string> TUnit;
-  unsigned long NOverFlow;
+};
 
-  vector<struct KeyDouble> DoubleKey;
-  vector<struct KeyLong>   LongKey;
-  vector<struct KeyString> StringKey;
+///////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////
+//! Class for writing a FITS Image
+class FitsImg2DWriter : public FitsWriter {
+public:
+  FitsImg2DWriter(string fname,int bitpix=FLOAT_IMG,int lp=0);
+  FitsImg2DWriter(const char* cfname,int bitpix=FLOAT_IMG,int lp=0);
+  FitsImg2DWriter(string fname,bool update,int bitpix=FLOAT_IMG,int lp=0);
+  FitsImg2DWriter(const char* cfname,bool update,int bitpix=FLOAT_IMG,int lp=0);
+  virtual ~FitsImg2DWriter();
+
+  void Write(TMatrix<uint_2>& data);
+  void Write(TMatrix<int_4>& data);
+  void Write(TMatrix<float>& data);
+  void Write(TMatrix<double>& data);
+
+  //! Print to os
+  virtual void   Print(ostream& os) const;
+  //! Print to stdout
+  inline  void   Print(void) const {Print(cout);}
+
+protected:
+  void createimg(void);
+
+  int BitPix;
+  long Naxis[2];
+  bool FirstTime;
 };
 
