Ignore:
Timestamp:
Dec 7, 2005, 7:12:03 PM (20 years ago)
Author:
ansari
Message:

Modif classe FitsSwapper pour utilisation de FitsInOutFile - Reza 7/12/2005

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaExt/FitsIOServer/fitsswapper.h

    r2785 r2857  
    99#include "machdefs.h"
    1010#include "swsegdb.h"
    11 #include "FitsIO/fitsio.h"
     11#include "fitsinoutfile.h"
     12#include "fitsblkrw.h"
    1213
    1314namespace SOPHYA {
     
    1516  \class SOPHYA::FITSDataSwapper
    1617  \ingroup FitsIOServer
    17   Implementation of SOPHYA::DataSwapperInterface interface on FITS streams
    18   (fitsfile *) to be used with SOPHYA::SwSegDataBlock classes.
     18  Implementation of SOPHYA::DataSwapperInterface interface on FITS files
     19  (FitsInOutFile) to be used with SOPHYA::SwSegDataBlock classes.
    1920*/
    2021
     
    2223class FITSDataSwapper : public DataSwapperInterface<T> {
    2324public:
    24   FITSDataSwapper();
    25   FITSDataSwapper(fitsfile * is, int coli, fitsfile * os=NULL, int colo=0);
     25  FITSDataSwapper()
     26  {
     27    SetInOutStream(NULL, 0);
     28  }
     29  FITSDataSwapper(FitsInOutFile * ios, int col)
     30  {
     31    SetInOutStream(ios, col);
     32  }
    2633
    27   inline fitsfile * InStream() { return fitsis; }
    28   inline fitsfile * OutStream() { return fitsos; }
    29   void SetInStream(fitsfile * is, int col);
    30   void SetOutStream(fitsfile * os, int col);
     34  inline FitsInOutFile * InOutStream() { return fios; }
     35  void SetInOutStream(FitsInOutFile * ios, int col)
     36  {
     37    fios = ios;
     38    fcol = col;
     39    rowos = 1;
     40    if ( fios != NULL) {
     41      fhdu = fios->CurrentHDU();
     42      if (fios->CurrentHDUType() != BINARY_TBL)
     43        throw FitsIOException("FITSDataSwapper<T>::SetInOutStream() CurrHDU not a BINARY_TBL");
     44    }
     45  }
    3146
    3247  // Operateur = , on recopie les pointeurs des streams
    33   FITSDataSwapper<T>& operator = (FITSDataSwapper<T> const & a);
     48  FITSDataSwapper<T>& operator = (FITSDataSwapper<T> const & a)
     49  {
     50    fios = a.fios;
     51    fcol = a.fcol;
     52    rowos = a.rowos;
     53    fhdu = a.fhdu;
     54  }
    3455
    35   virtual int_8 WriteToSwap(const T * d, size_t sz, int_8 idx, int_8 oswp=0, bool osw=false);
    36   virtual void  ReadFromSwap(int_8 idx, int_8 swp, T* d, size_t sz);
     56  virtual int_8 WriteToSwap(const T * d, size_t sz, int_8 idx, int_8 oswp=0, bool osw=false)
     57  {
     58    if (fios == NULL)
     59      FitsIOException("FITSDataSwapper<T>::ReadFromSwap() null InOutFile pointer");
     60    fios->MoveAbsToHDU(fhdu);
     61    long row = rowos;
     62    if (osw)  row = oswp;
     63    FitsBlockRW<T>::WriteColumnData(*fios, fcol, row, 1, d, sz);
     64    if (!osw) rowos += sz;
     65    return row;
     66  }
     67
     68  virtual void  ReadFromSwap(int_8 idx, int_8 swp, T* d, size_t sz)
     69  {
     70    if (fios == NULL)
     71      FitsIOException("FITSDataSwapper<T>::ReadFromSwap() null InOutFile pointer");
     72    FitsBlockRW<T>::ReadColumnData(*fios, fcol, swp, 1, d, sz);
     73  }
    3774
    3875protected:
    39   fitsfile * fitsos;
    40   int colos, hduos;
     76  FitsInOutFile * fios;
     77  int fcol, fhdu;
    4178  long rowos;
    42   fitsfile * fitsis;
    43   int colis, hduis;
    4479};
    4580
Note: See TracChangeset for help on using the changeset viewer.