| 1 | // This may look like C code, but it is really -*- C++ -*- | 
|---|
| 2 | // Class DataTable  (Row-Column data table in memory) | 
|---|
| 3 | //   R. Ansari -  Avril 2005 | 
|---|
| 4 | //   (C)  LAL-IN2P3/CNRS    CEA-DAPNIA | 
|---|
| 5 |  | 
|---|
| 6 | #ifndef SWFITSDTABLE_H_SEEN | 
|---|
| 7 | #define SWFITSDTABLE_H_SEEN | 
|---|
| 8 |  | 
|---|
| 9 | #include "basedtable.h" | 
|---|
| 10 | #include "swsegdb.h" | 
|---|
| 11 | #include "fitsswapper.h" | 
|---|
| 12 |  | 
|---|
| 13 |  | 
|---|
| 14 | namespace SOPHYA { | 
|---|
| 15 |  | 
|---|
| 16 | //! An implementation of BaseDataTable with using FITS files as swap space. | 
|---|
| 17 | class SwFitsDataTable : public BaseDataTable { | 
|---|
| 18 | public: | 
|---|
| 19 | SwFitsDataTable(sa_size_t segsz=512); | 
|---|
| 20 | SwFitsDataTable(FitsInOutFile & os, sa_size_t segsz=512, bool fgcreate=true); | 
|---|
| 21 | SwFitsDataTable(SwFitsDataTable const& a); | 
|---|
| 22 |  | 
|---|
| 23 | virtual ~SwFitsDataTable(); | 
|---|
| 24 |  | 
|---|
| 25 | virtual sa_size_t AddColumn(FieldType ft, string const & cnom); | 
|---|
| 26 |  | 
|---|
| 27 | // Filling data structures (adding lines) | 
|---|
| 28 | virtual sa_size_t AddRow(const r_8* data); | 
|---|
| 29 | virtual sa_size_t AddRow(const MuTyV * data); | 
|---|
| 30 |  | 
|---|
| 31 | //! Equal (copy) operator - Copies the data and the structure from \b a | 
|---|
| 32 | inline  SwFitsDataTable& operator = (BaseDataTable const& a) | 
|---|
| 33 | { CopyMerge(a, true) ; return *this ; } | 
|---|
| 34 | //! Equal (copy) operator - Copies the structure and shares the data \b a | 
|---|
| 35 | inline SwFitsDataTable& operator = (SwFitsDataTable const& a) | 
|---|
| 36 | { Clear(); Share(a); return *this ; } | 
|---|
| 37 |  | 
|---|
| 38 | //! Acces the FitsInOutFile swap stream | 
|---|
| 39 | inline FitsInOutFile& FitsSwapFile() { return mSwF; } | 
|---|
| 40 |  | 
|---|
| 41 | //! Reset(Clear) the table content and structure | 
|---|
| 42 | virtual void Clear(); | 
|---|
| 43 | /*! This method should be called in order to empty the swapout buffer, | 
|---|
| 44 | before saving object to PPF stream | 
|---|
| 45 | */ | 
|---|
| 46 | void SwapOutAll() const; | 
|---|
| 47 |  | 
|---|
| 48 | //  Pour la gestion I/O FITS | 
|---|
| 49 | friend class FitsHandler<BaseDataTable> ; | 
|---|
| 50 |  | 
|---|
| 51 | protected: | 
|---|
| 52 | void Share(SwFitsDataTable const & a); | 
|---|
| 53 | // Methode pour utilisation par FitsHandler<BaseDataTable> | 
|---|
| 54 | sa_size_t AddColRd(FieldType ft, string const & cnom, int colidx=-1, | 
|---|
| 55 | vector<int_8> const * swpos=NULL); | 
|---|
| 56 |  | 
|---|
| 57 |  | 
|---|
| 58 | // Donnees (SegDataBlock) et leurs swapper | 
|---|
| 59 | std::vector< SwSegDataBlock<int_4> > mICols; | 
|---|
| 60 | std::vector< SwSegDataBlock<int_8> > mLCols; | 
|---|
| 61 | std::vector< SwSegDataBlock<r_4> > mFCols; | 
|---|
| 62 | std::vector< SwSegDataBlock<r_8> > mDCols; | 
|---|
| 63 | std::vector< SwSegDataBlock< complex<r_4> > > mYCols; | 
|---|
| 64 | std::vector< SwSegDataBlock< complex<r_8> > > mZCols; | 
|---|
| 65 | std::vector< SwSegDataBlock<string> > mSCols; | 
|---|
| 66 |  | 
|---|
| 67 | // In/Out swap file doit etre cree avant l'appel au constructeur | 
|---|
| 68 | // et rester valide (non detruit) tant que l'objet SwFitsDataTable existe | 
|---|
| 69 | FitsInOutFile mSwF; | 
|---|
| 70 | bool mFgCreate; // true -> creation de table, false -> lecture | 
|---|
| 71 | }; | 
|---|
| 72 |  | 
|---|
| 73 | } // namespace SOPHYA | 
|---|
| 74 |  | 
|---|
| 75 | #endif | 
|---|
| 76 |  | 
|---|