source: Sophya/trunk/SophyaExt/FitsIOServer/fitsswapper.h@ 3056

Last change on this file since 3056 was 2896, checked in by ansari, 20 years ago

Correction suite modifs commentaire pour doxygen - Reza 12/01/2006

File size: 2.1 KB
Line 
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"
11#include "fitsinoutfile.h"
12#include "fitsblkrw.h"
13
14/*!
15 \class SOPHYA::FITSDataSwapper
16 \ingroup FitsIOServer
17 Implementation of SOPHYA::DataSwapperInterface interface on FITS files
18 (FitsInOutFile) to be used with SOPHYA::SwSegDataBlock classes.
19*/
20
21namespace SOPHYA {
22
23template <class T>
24class FITSDataSwapper : public DataSwapperInterface<T> {
25public:
26 FITSDataSwapper()
27 : fcol(0) , rowos(1)
28 {
29 }
30 FITSDataSwapper(FitsInOutFile & ios, int col)
31 : fios(ios) , fcol(col), rowos(1)
32 {
33 }
34
35 inline FitsInOutFile & InOutStream() { return fios; }
36 void SetInOutStream(FitsInOutFile & ios, int col)
37 {
38 fios = ios;
39 fcol = col;
40 rowos = 1;
41 /* On ne fait pas de check sur type HDU - Reza , 30/12/2005
42 if ( fios != NULL) {
43 fhdu = fios->CurrentHDU();
44 if (fios->CurrentHDUType() != BINARY_TBL)
45 throw FitsIOException("FITSDataSwapper<T>::SetInOutStream() CurrHDU not a BINARY_TBL");
46 } */
47 }
48
49 // Operateur = , on recopie les pointeurs des streams
50 FITSDataSwapper<T>& operator = (FITSDataSwapper<T> const & a)
51 {
52 fios = a.fios;
53 fcol = a.fcol;
54 rowos = a.rowos;
55 }
56
57 virtual int_8 WriteToSwap(const T * d, size_t sz, int_8 idx, int_8 oswp=0, bool osw=false)
58 {
59 /* fios->MoveAbsToHDU(fhdu); On suppose qu'on est sur le bon HDU - Reza 30/12/2005 */
60 long row = rowos;
61 if (osw) row = oswp;
62 FitsBlockRW<T>::WriteColumnData(fios, fcol, row, 1, d, sz);
63 if (!osw) rowos += sz;
64 return row;
65 }
66
67 virtual void ReadFromSwap(int_8 idx, int_8 swp, T* d, size_t sz)
68 {
69 FitsBlockRW<T>::ReadColumnData(fios, fcol, swp, 1, d, sz);
70 }
71
72 virtual DataSwapperInterface<T>* Clone()
73 {
74 FITSDataSwapper<T> * rsw = new FITSDataSwapper<T>(fios, fcol) ;
75 return rsw;
76 }
77
78protected:
79 FitsInOutFile fios;
80 int fcol;
81 long rowos;
82};
83
84} // Fin du namespace
85
86#endif
Note: See TracBrowser for help on using the repository browser.