Changeset 2857 in Sophya for trunk/SophyaExt/FitsIOServer/fitsswapper.h
- Timestamp:
- Dec 7, 2005, 7:12:03 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaExt/FitsIOServer/fitsswapper.h
r2785 r2857 9 9 #include "machdefs.h" 10 10 #include "swsegdb.h" 11 #include "FitsIO/fitsio.h" 11 #include "fitsinoutfile.h" 12 #include "fitsblkrw.h" 12 13 13 14 namespace SOPHYA { … … 15 16 \class SOPHYA::FITSDataSwapper 16 17 \ingroup FitsIOServer 17 Implementation of SOPHYA::DataSwapperInterface interface on FITS streams18 ( 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. 19 20 */ 20 21 … … 22 23 class FITSDataSwapper : public DataSwapperInterface<T> { 23 24 public: 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 } 26 33 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 } 31 46 32 47 // 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 } 34 55 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 } 37 74 38 75 protected: 39 fitsfile * fitsos;40 int colos, hduos;76 FitsInOutFile * fios; 77 int fcol, fhdu; 41 78 long rowos; 42 fitsfile * fitsis;43 int colis, hduis;44 79 }; 45 80
Note:
See TracChangeset
for help on using the changeset viewer.