[2782] | 1 | // This may look like C code, but it is really -*- C++ -*-
|
---|
| 2 | // Gestion de block de donnees swapable
|
---|
| 3 | // C. Magneville R. Ansari Mai 2005
|
---|
| 4 | // LAL (Orsay) / IN2P3-CNRS DAPNIA/SPP (Saclay) / CEA
|
---|
| 5 | #ifndef FITSSWAPPER_H
|
---|
| 6 | #define FITSSWAPPER_H
|
---|
| 7 |
|
---|
| 8 |
|
---|
| 9 | #include "machdefs.h"
|
---|
| 10 | #include "swsegdb.h"
|
---|
[2857] | 11 | #include "fitsinoutfile.h"
|
---|
| 12 | #include "fitsblkrw.h"
|
---|
[2782] | 13 |
|
---|
| 14 | namespace SOPHYA {
|
---|
| 15 | /*!
|
---|
| 16 | \class SOPHYA::FITSDataSwapper
|
---|
| 17 | \ingroup FitsIOServer
|
---|
[2857] | 18 | Implementation of SOPHYA::DataSwapperInterface interface on FITS files
|
---|
| 19 | (FitsInOutFile) to be used with SOPHYA::SwSegDataBlock classes.
|
---|
[2782] | 20 | */
|
---|
| 21 |
|
---|
| 22 | template <class T>
|
---|
| 23 | class FITSDataSwapper : public DataSwapperInterface<T> {
|
---|
| 24 | public:
|
---|
[2857] | 25 | FITSDataSwapper()
|
---|
[2864] | 26 | : fcol(0) , rowos(1)
|
---|
[2857] | 27 | {
|
---|
| 28 | }
|
---|
[2864] | 29 | FITSDataSwapper(FitsInOutFile & ios, int col)
|
---|
| 30 | : fios(ios) , fcol(col), rowos(1)
|
---|
[2857] | 31 | {
|
---|
| 32 | }
|
---|
[2782] | 33 |
|
---|
[2864] | 34 | inline FitsInOutFile & InOutStream() { return fios; }
|
---|
| 35 | void SetInOutStream(FitsInOutFile & ios, int col)
|
---|
[2857] | 36 | {
|
---|
| 37 | fios = ios;
|
---|
| 38 | fcol = col;
|
---|
| 39 | rowos = 1;
|
---|
[2864] | 40 | /* On ne fait pas de check sur type HDU - Reza , 30/12/2005
|
---|
[2857] | 41 | if ( fios != NULL) {
|
---|
| 42 | fhdu = fios->CurrentHDU();
|
---|
| 43 | if (fios->CurrentHDUType() != BINARY_TBL)
|
---|
| 44 | throw FitsIOException("FITSDataSwapper<T>::SetInOutStream() CurrHDU not a BINARY_TBL");
|
---|
[2864] | 45 | } */
|
---|
[2857] | 46 | }
|
---|
[2782] | 47 |
|
---|
| 48 | // Operateur = , on recopie les pointeurs des streams
|
---|
[2857] | 49 | FITSDataSwapper<T>& operator = (FITSDataSwapper<T> const & a)
|
---|
| 50 | {
|
---|
| 51 | fios = a.fios;
|
---|
| 52 | fcol = a.fcol;
|
---|
| 53 | rowos = a.rowos;
|
---|
| 54 | }
|
---|
[2782] | 55 |
|
---|
[2857] | 56 | virtual int_8 WriteToSwap(const T * d, size_t sz, int_8 idx, int_8 oswp=0, bool osw=false)
|
---|
| 57 | {
|
---|
[2864] | 58 | /* fios->MoveAbsToHDU(fhdu); On suppose qu'on est sur le bon HDU - Reza 30/12/2005 */
|
---|
[2857] | 59 | long row = rowos;
|
---|
| 60 | if (osw) row = oswp;
|
---|
[2864] | 61 | FitsBlockRW<T>::WriteColumnData(fios, fcol, row, 1, d, sz);
|
---|
[2857] | 62 | if (!osw) rowos += sz;
|
---|
| 63 | return row;
|
---|
| 64 | }
|
---|
[2782] | 65 |
|
---|
[2857] | 66 | virtual void ReadFromSwap(int_8 idx, int_8 swp, T* d, size_t sz)
|
---|
| 67 | {
|
---|
[2864] | 68 | FitsBlockRW<T>::ReadColumnData(fios, fcol, swp, 1, d, sz);
|
---|
[2857] | 69 | }
|
---|
| 70 |
|
---|
[2864] | 71 | virtual DataSwapperInterface<T>* Clone()
|
---|
| 72 | {
|
---|
| 73 | FITSDataSwapper<T> * rsw = new FITSDataSwapper<T>(fios, fcol) ;
|
---|
| 74 | return rsw;
|
---|
| 75 | }
|
---|
| 76 |
|
---|
[2782] | 77 | protected:
|
---|
[2864] | 78 | FitsInOutFile fios;
|
---|
| 79 | int fcol;
|
---|
[2782] | 80 | long rowos;
|
---|
| 81 | };
|
---|
| 82 |
|
---|
| 83 | } // Fin du namespace
|
---|
| 84 |
|
---|
| 85 | #endif
|
---|