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

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

1/ Simplification de la classe gestionnairee PPersist ObjFile<T> (objfio.h)
2/ Ajout DECL_TEMP_SPEC ds ppftpointerio.h
3/ Nom specifique pour methode SegDBInterface::GetSegment() const devenu
SegDBInterface::GetCstSegment() const pour eviter l'appel a la methode non const
et adapatation classes derivees (segdatablock.h et swsegdb.h)
4/ Ajout SkipToNextObjet() ds PInPersist::ReadObject() (ppersist.cc) et protection contre pointeur NULL -> new DVList pour la lecture PPersist de DVList

Reza - 27 Avril 2005

File size: 2.0 KB
Line 
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:
25 PPFDataSwapper() { ppfos = NULL; ppfis = NULL;}
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
30 inline PInPersist & InStream() { return *ppfis; }
31 inline PInPersist & OutStream() { return *ppfos; }
32 inline void SetInStream(PInPersist & is) { ppfis = &is; }
33 inline void SetOutStream(POutPersist & os) { ppfos = &os; }
34
35 // Operateur = , on recopie les pointeurs des streams
36 inline PPFDataSwapper& operator = (PPFDataSwapper const & a)
37 { ppfis = a.ppfis; ppfos = a.ppfos; return *this; }
38
39 virtual int_8 WriteToSwap(const T * d, size_t sz, int_8 idx, int_8 oswp=0, bool osw=false)
40 {
41 if (ppfos == NULL) throw NotAvailableOperation("PPFDataSwapper<T>::WriteToSwap() - No POutPersist stream !");
42 int_8 tag = ppfos->WritePositionTag();
43 PPF_TPointer_IO<T>::Write(*ppfos, d, sz);
44 return tag;
45 }
46 virtual void ReadFromSwap(int_8 idx, int_8 swp, T* d, size_t sz)
47 {
48 if (ppfis == NULL) throw NotAvailableOperation("PPFDataSwapper<T>::ReadFromSwap() - No PInPersist stream !");
49 bool ok = ppfis->GotoPositionTag(swp);
50 PPF_TPointer_IO<T>::Read(*ppfis, d, sz);
51 return;
52 }
53protected:
54 POutPersist* ppfos;
55 PInPersist* ppfis;
56};
57
58} // Fin du namespace
59
60#endif
Note: See TracBrowser for help on using the repository browser.