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