[2660] | 1 | // This may look like C code, but it is really -*- C++ -*-
|
---|
| 2 | // Gestion de block de donnees swapable
|
---|
| 3 | // R. Ansari Mars 2005
|
---|
| 4 | // LAL (Orsay) / IN2P3-CNRS DAPNIA/SPP (Saclay) / CEA
|
---|
| 5 | #ifndef PPFSWAPPER_H
|
---|
| 6 | #define PPFSWAPPER_H
|
---|
| 7 |
|
---|
| 8 |
|
---|
| 9 | #include "machdefs.h"
|
---|
| 10 | #include "swsegdb.h"
|
---|
| 11 | #include "ppersist.h"
|
---|
| 12 | #include "ppftpointerio.h"
|
---|
| 13 |
|
---|
| 14 | namespace SOPHYA {
|
---|
| 15 | /*!
|
---|
| 16 | \class SOPHYA::PPFDataSwapper
|
---|
| 17 | \ingroup BaseTools
|
---|
| 18 | Implementation of SOPHYA::DataSwapperInterface interface on PPF streams
|
---|
| 19 | (POutPersist , PInPersist) to be used with SOPHYA::SwSegDataBlock classes.
|
---|
| 20 | */
|
---|
| 21 |
|
---|
| 22 | template <class T>
|
---|
| 23 | class PPFDataSwapper : public DataSwapperInterface<T> {
|
---|
| 24 | public:
|
---|
[2695] | 25 | PPFDataSwapper() { ppfos = NULL; ppfis = NULL;}
|
---|
[2660] | 26 | PPFDataSwapper(POutPersist & os) { ppfos = &os; ppfis = NULL;}
|
---|
| 27 | PPFDataSwapper(PInPersist & is) { ppfos = NULL; ppfis = &is;}
|
---|
| 28 | PPFDataSwapper(PInPersist & is, POutPersist & os) { ppfos = &os; ppfis = &is;}
|
---|
| 29 | virtual int_8 WriteToSwap(const T * d, size_t sz, int_8 idx, int_8 oswp=0, bool osw=false)
|
---|
| 30 | {
|
---|
| 31 | if (ppfos == NULL) throw NotAvailableOperation("PPFDataSwapper<T>::WriteToSwap() - No POutPersist stream !");
|
---|
| 32 | int_8 tag = ppfos->WritePositionTag();
|
---|
| 33 | PPF_TPointer_IO<T>::Write(*ppfos, d, sz);
|
---|
| 34 | return tag;
|
---|
| 35 | }
|
---|
| 36 | virtual void ReadFromSwap(int_8 idx, int_8 swp, T* d, size_t sz)
|
---|
| 37 | {
|
---|
| 38 | if (ppfis == NULL) throw NotAvailableOperation("PPFDataSwapper<T>::ReadFromSwap() - No PInPersist stream !");
|
---|
| 39 | bool ok = ppfis->GotoPositionTag(swp);
|
---|
| 40 | PPF_TPointer_IO<T>::Read(*ppfis, d, sz);
|
---|
| 41 | return;
|
---|
| 42 | }
|
---|
| 43 | protected:
|
---|
| 44 | POutPersist* ppfos;
|
---|
| 45 | PInPersist* ppfis;
|
---|
| 46 | };
|
---|
| 47 |
|
---|
| 48 | } // Fin du namespace
|
---|
| 49 |
|
---|
| 50 | #endif
|
---|