// This may look like C code, but it is really -*- C++ -*- // Gestion de block de donnees swapable // R. Ansari Mars 2005 // LAL (Orsay) / IN2P3-CNRS DAPNIA/SPP (Saclay) / CEA #ifndef PPFSWAPPER_H #define PPFSWAPPER_H #include "machdefs.h" #include "swsegdb.h" #include "ppersist.h" #include "ppftpointerio.h" namespace SOPHYA { /*! \class SOPHYA::PPFDataSwapper \ingroup BaseTools Implementation of SOPHYA::DataSwapperInterface interface on PPF streams (POutPersist , PInPersist) to be used with SOPHYA::SwSegDataBlock classes. */ template class PPFDataSwapper : public DataSwapperInterface { public: PPFDataSwapper() { ppfos = NULL; ppfis = NULL;} PPFDataSwapper(POutPersist & os) { ppfos = &os; ppfis = NULL;} PPFDataSwapper(PInPersist & is) { ppfos = NULL; ppfis = &is;} PPFDataSwapper(PInPersist & is, POutPersist & os) { ppfos = &os; ppfis = &is;} virtual int_8 WriteToSwap(const T * d, size_t sz, int_8 idx, int_8 oswp=0, bool osw=false) { if (ppfos == NULL) throw NotAvailableOperation("PPFDataSwapper::WriteToSwap() - No POutPersist stream !"); int_8 tag = ppfos->WritePositionTag(); PPF_TPointer_IO::Write(*ppfos, d, sz); return tag; } virtual void ReadFromSwap(int_8 idx, int_8 swp, T* d, size_t sz) { if (ppfis == NULL) throw NotAvailableOperation("PPFDataSwapper::ReadFromSwap() - No PInPersist stream !"); bool ok = ppfis->GotoPositionTag(swp); PPF_TPointer_IO::Read(*ppfis, d, sz); return; } protected: POutPersist* ppfos; PInPersist* ppfis; }; } // Fin du namespace #endif