[2696] | 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 SWPPFDTABLE_H_SEEN
|
---|
| 7 | #define SWPPFDTABLE_H_SEEN
|
---|
| 8 |
|
---|
| 9 | #include "basedtable.h"
|
---|
| 10 | #include "swsegdb.h"
|
---|
| 11 | #include "ppfswapper.h"
|
---|
| 12 | #include "objfio.h"
|
---|
| 13 |
|
---|
| 14 |
|
---|
| 15 | namespace SOPHYA {
|
---|
| 16 |
|
---|
[2808] | 17 | //! An implementation of BaseDataTable with using a PPF stream as swap space.
|
---|
[2696] | 18 | class SwPPFDataTable : public BaseDataTable {
|
---|
| 19 | public:
|
---|
| 20 | SwPPFDataTable(sa_size_t segsz=512);
|
---|
| 21 | SwPPFDataTable(POutPersist & os, sa_size_t segsz=512);
|
---|
| 22 | SwPPFDataTable(SwPPFDataTable const& a);
|
---|
[2699] | 23 |
|
---|
| 24 | virtual ~SwPPFDataTable();
|
---|
| 25 |
|
---|
[2696] | 26 | virtual sa_size_t AddColumn(FieldType ft, string const & cnom);
|
---|
| 27 |
|
---|
| 28 | // Filling data structures (adding lines)
|
---|
| 29 | virtual sa_size_t AddLine(const r_8* data);
|
---|
| 30 | virtual sa_size_t AddLine(const MuTyV * data);
|
---|
| 31 |
|
---|
| 32 | //! Equal (copy) operator - Copies the structure and shares the data \b a
|
---|
| 33 | inline SwPPFDataTable& operator = (SwPPFDataTable const& a)
|
---|
| 34 | { Clear(); Share(a); return *this ; }
|
---|
| 35 |
|
---|
| 36 | // Pour la gestion de persistance PPF
|
---|
[2699] | 37 | friend class ObjFileIO<BaseDataTable> ;
|
---|
[2696] | 38 |
|
---|
[2808] | 39 | //! Reset(Clear) the table content and structure
|
---|
[2699] | 40 | virtual void Clear();
|
---|
[2696] | 41 | /*! This method should be called in order to empty the swapout buffer,
|
---|
| 42 | before saving object to PPF stream
|
---|
| 43 | */
|
---|
| 44 | void SwapOutAll() const;
|
---|
| 45 | protected:
|
---|
| 46 | SwPPFDataTable(PInPersist & is, sa_size_t segsz);
|
---|
| 47 | void Share(SwPPFDataTable const & a);
|
---|
| 48 |
|
---|
| 49 | // Donnees en memoire
|
---|
| 50 | std::vector< SwSegDataBlock<int_4> > mICols;
|
---|
| 51 | PPFDataSwapper<int_4> mISwapper;
|
---|
| 52 | std::vector< SwSegDataBlock<int_8> > mLCols;
|
---|
| 53 | PPFDataSwapper<int_8> mLSwapper;
|
---|
| 54 | std::vector< SwSegDataBlock<r_4> > mFCols;
|
---|
| 55 | PPFDataSwapper<r_4> mFSwapper;
|
---|
| 56 | std::vector< SwSegDataBlock<r_8> > mDCols;
|
---|
| 57 | PPFDataSwapper<r_8> mDSwapper;
|
---|
[2827] | 58 | std::vector< SwSegDataBlock< complex<r_4> > > mYCols;
|
---|
| 59 | PPFDataSwapper< complex<r_4> > mYSwapper;
|
---|
| 60 | std::vector< SwSegDataBlock< complex<r_8> > > mZCols;
|
---|
| 61 | PPFDataSwapper< complex<r_8> > mZSwapper;
|
---|
[2696] | 62 | std::vector< SwSegDataBlock<string> > mSCols;
|
---|
| 63 | PPFDataSwapper<string> mSSwapper;
|
---|
| 64 |
|
---|
[2699] | 65 | // Output swap stream doit etre cree avant l'appel au constructeur
|
---|
| 66 | // et rester valide (non detruit) tant que l'objet SwPPFDataTable existe
|
---|
| 67 | POutPersist* mSwOut;
|
---|
| 68 | // Input swap stream - On cree un input swap stream et on fait
|
---|
| 69 | // un comptage de reference pour le detruire lorsque tous les tables
|
---|
| 70 | // l'utilisant sont supprimes
|
---|
[2808] | 71 | //! \cond Pour NE PAS inclure dans la doc
|
---|
[2699] | 72 | typedef struct { PInPersist* pis; uint_4 refcnt; } St_InSwap;
|
---|
[2808] | 73 | //! \endcond
|
---|
[2699] | 74 | St_InSwap * mSwIn;
|
---|
[2696] | 75 | };
|
---|
| 76 |
|
---|
| 77 | /*! Writes the object in the POutPersist stream \b os */
|
---|
| 78 | inline POutPersist& operator << (POutPersist& os, SwPPFDataTable & obj)
|
---|
[2699] | 79 | { obj.SwapOutAll(); ObjFileIO<BaseDataTable> fio(&obj); fio.Write(os); return(os); }
|
---|
[2696] | 80 | /*! Reads the object from the PInPersist stream \b is */
|
---|
| 81 | inline PInPersist& operator >> (PInPersist& is, SwPPFDataTable & obj)
|
---|
[2699] | 82 | { ObjFileIO<BaseDataTable> fio(&obj); is.SkipToNextObject(); fio.Read(is); return(is); }
|
---|
| 83 |
|
---|
[2696] | 84 | } // namespace SOPHYA
|
---|
| 85 |
|
---|
| 86 | #endif
|
---|
| 87 |
|
---|