source: Sophya/trunk/SophyaLib/BaseTools/ppfswapper.h@ 2695

Last change on this file since 2695 was 2695, checked in by ansari, 20 years ago

1/ Declaration des classes PPF_TPointer_IO< X > avec X=int_1/2/4/8 r_4 ...
remis ds ppftpointerio.h - corps de fonction laisse ds .cc
2/ Ajout de la methode SwapOutBuffer() ds SwSegDataBlock<T>
3/ Ajout du constructeur par defaut ds PPFDataSwapper

Reza 26/4/2005

File size: 1.6 KB
RevLine 
[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
14namespace 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
22template <class T>
23class PPFDataSwapper : public DataSwapperInterface<T> {
24public:
[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 }
43protected:
44 POutPersist* ppfos;
45 PInPersist* ppfis;
46};
47
48} // Fin du namespace
49
50#endif
Note: See TracBrowser for help on using the repository browser.