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