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

Last change on this file since 2889 was 2864, checked in by ansari, 20 years ago

1/ Ajout methode CheckReadability() , retour int pour CheckHandling() ds l'interface FitsHandler et propagation vers handler TArray et DataTable
2/ Correction dans FitsManager et ajout initialiseur de module FitsIOServer (fiosinit.h .cc)
3/ FitsSwapper complete - corrige - full template (suppression de fitsswapper.cc)
4/ MAJ Makefile et objlist.list suite ajout fiosinit.cc et swfitsdtable

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