| 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 DATATABLE_H_SEEN | 
|---|
| 7 | #define DATATABLE_H_SEEN | 
|---|
| 8 |  | 
|---|
| 9 | #include "basedtable.h" | 
|---|
| 10 | #include "objfio.h" | 
|---|
| 11 |  | 
|---|
| 12 |  | 
|---|
| 13 | namespace SOPHYA { | 
|---|
| 14 |  | 
|---|
| 15 | //  Forward class declaration for Fits handler | 
|---|
| 16 | template <class T>  class FitsHandler; | 
|---|
| 17 |  | 
|---|
| 18 | //! An implementation of BaseDataTable with data (columns) stored in memory. | 
|---|
| 19 | class DataTable : public BaseDataTable { | 
|---|
| 20 | public: | 
|---|
| 21 | DataTable(sa_size_t segsz=512); | 
|---|
| 22 | DataTable(DataTable const& a, bool share=true); | 
|---|
| 23 |  | 
|---|
| 24 | virtual sa_size_t AddColumn(FieldType ft, string const & cnom); | 
|---|
| 25 |  | 
|---|
| 26 | //! Equal (copy) operator - Copies the data and the structure if necessary from \b a | 
|---|
| 27 | inline DataTable&  operator = (BaseDataTable const& a) | 
|---|
| 28 | { CopyMerge(a, true) ; return *this ; } | 
|---|
| 29 | //! Equal (copy) operator - Copies the data and the structure if necessary from \b a | 
|---|
| 30 | inline DataTable& operator = (DataTable const& a) | 
|---|
| 31 | { CopyMerge(a, true) ; return *this ; } | 
|---|
| 32 |  | 
|---|
| 33 | //  Pour la gestion de persistance PPF | 
|---|
| 34 | friend class ObjFileIO<BaseDataTable> ; | 
|---|
| 35 | // pour fichiers FITS | 
|---|
| 36 | friend class FitsHandler<BaseDataTable>; | 
|---|
| 37 |  | 
|---|
| 38 | //! Reset the table content and structure | 
|---|
| 39 | virtual void Clear(); | 
|---|
| 40 | protected: | 
|---|
| 41 | void Share(DataTable const & a); | 
|---|
| 42 | void Clone(DataTable const & a); | 
|---|
| 43 |  | 
|---|
| 44 | // Donnees en memoire | 
|---|
| 45 | std::vector< SegDataBlock<int_4> > mICols; | 
|---|
| 46 | std::vector< SegDataBlock<int_8> > mLCols; | 
|---|
| 47 | std::vector< SegDataBlock<r_4> > mFCols; | 
|---|
| 48 | std::vector< SegDataBlock<r_8> > mDCols; | 
|---|
| 49 | std::vector< SegDataBlock< complex<r_4> > > mYCols; | 
|---|
| 50 | std::vector< SegDataBlock< complex<r_8> > > mZCols; | 
|---|
| 51 | std::vector< SegDataBlock<string> > mSCols; | 
|---|
| 52 | }; | 
|---|
| 53 |  | 
|---|
| 54 | /*! Writes the object in the POutPersist stream \b os */ | 
|---|
| 55 | inline POutPersist& operator << (POutPersist& os, DataTable & obj) | 
|---|
| 56 | { ObjFileIO<BaseDataTable> fio(&obj);  fio.Write(os);  return(os); } | 
|---|
| 57 | /*! Reads the object from the PInPersist stream \b is */ | 
|---|
| 58 | inline PInPersist& operator >> (PInPersist& is, DataTable & obj) | 
|---|
| 59 | { ObjFileIO<BaseDataTable> fio(&obj); is.SkipToNextObject(); | 
|---|
| 60 | fio.Read(is); return(is); } | 
|---|
| 61 | // Classe pour la gestion de persistance | 
|---|
| 62 | // ObjFileIO<BaseDataTable> | 
|---|
| 63 | } // namespace SOPHYA | 
|---|
| 64 |  | 
|---|
| 65 | #endif | 
|---|
| 66 |  | 
|---|