Index: trunk/SophyaLib/HiStats/basedtable.cc
===================================================================
--- trunk/SophyaLib/HiStats/basedtable.cc	(revision 2696)
+++ trunk/SophyaLib/HiStats/basedtable.cc	(revision 2699)
@@ -117,7 +117,9 @@
 sa_size_t BaseDataTable::IndexNom(char const* nom) const 
 {
-  for(sa_size_t k=0; k<NVar(); k++)
-    if ( mNames[k].nom == nom )  return k;
-  throw NotFoundExc("BaseDataTable::IndexNom() : column name not found ");
+  for(sa_size_t k=0; k<NVar(); k++) 
+    if ( mNames[k].nom == nom )      return k;
+  return -1;
+  // Reza:Avril 2005 : PINtuple se base sur le renvoi de -1 et pas d'une exception
+  //  throw NotFoundExc("BaseDataTable::IndexNom() : column name not found ");
 }
 
@@ -202,13 +204,13 @@
   sa_size_t off = n%mSegSz;
   for(sa_size_t k=0; k<mIColsP.size(); k++) 
-    mVarMTV[mIColIdx[k]] = mIColsP[k]->GetSegment(bid)[off];
+    mVarMTV[mIColIdx[k]] = mIColsP[k]->GetCstSegment(bid)[off];
   for(sa_size_t k=0; k<mLColsP.size(); k++) 
-    mVarMTV[mLColIdx[k]] = mLColsP[k]->GetSegment(bid)[off];
+    mVarMTV[mLColIdx[k]] = mLColsP[k]->GetCstSegment(bid)[off];
   for(sa_size_t k=0; k<mFColsP.size(); k++) 
-    mVarMTV[mFColIdx[k]] = mFColsP[k]->GetSegment(bid)[off];
+    mVarMTV[mFColIdx[k]] = mFColsP[k]->GetCstSegment(bid)[off];
   for(sa_size_t k=0; k<mDColsP.size(); k++) 
-    mVarMTV[mDColIdx[k]] = mDColsP[k]->GetSegment(bid)[off];
+    mVarMTV[mDColIdx[k]] = mDColsP[k]->GetCstSegment(bid)[off];
   for(sa_size_t k=0; k<mSColsP.size(); k++) 
-    mVarMTV[mSColIdx[k]] = atof(mSColsP[k]->GetSegment(bid)[off].c_str());
+    mVarMTV[mSColIdx[k]] = atof(mSColsP[k]->GetCstSegment(bid)[off].c_str());
 
   return mVarMTV;
@@ -307,13 +309,13 @@
   sa_size_t off = n%mSegSz;
   for(sa_size_t k=0; k<mIColsP.size(); k++) 
-    mVarD[mIColIdx[k]] = mIColsP[k]->GetSegment(bid)[off];
+    mVarD[mIColIdx[k]] = mIColsP[k]->GetCstSegment(bid)[off];
   for(sa_size_t k=0; k<mLColsP.size(); k++) 
-    mVarD[mLColIdx[k]] = mLColsP[k]->GetSegment(bid)[off];
+    mVarD[mLColIdx[k]] = mLColsP[k]->GetCstSegment(bid)[off];
   for(sa_size_t k=0; k<mFColsP.size(); k++) 
-    mVarD[mFColIdx[k]] = mFColsP[k]->GetSegment(bid)[off];
+    mVarD[mFColIdx[k]] = mFColsP[k]->GetCstSegment(bid)[off];
   for(sa_size_t k=0; k<mDColsP.size(); k++) 
-    mVarD[mDColIdx[k]] = mDColsP[k]->GetSegment(bid)[off];
+    mVarD[mDColIdx[k]] = mDColsP[k]->GetCstSegment(bid)[off];
   for(sa_size_t k=0; k<mSColsP.size(); k++) 
-    mVarD[mSColIdx[k]] = atof(mSColsP[k]->GetSegment(bid)[off].c_str());
+    mVarD[mSColIdx[k]] = atof(mSColsP[k]->GetCstSegment(bid)[off].c_str());
 
   return mVarD;
@@ -326,5 +328,5 @@
   if ((n < 0) || (n >= NEntry())) 
     throw RangeCheckError("BaseDataTable::GetCell() out of range line index n");
-  if ((k < 0) || (n >= NVar())) 
+  if ((k < 0) || (k >= NVar())) 
     throw RangeCheckError("BaseDataTable::GetCell() out of range column index k");
   double rv = BADVAL;
@@ -332,19 +334,20 @@
   sa_size_t bid = n/mSegSz;
   sa_size_t off = n%mSegSz;
+
   switch (mNames[k].type) {
   case IntegerField :
-    rv = mIColsP[sk]->GetSegment(bid)[off];
+    rv = mIColsP[sk]->GetCstSegment(bid)[off];
     break;
   case LongField :
-    rv = mLColsP[sk]->GetSegment(bid)[off];
+    rv = mLColsP[sk]->GetCstSegment(bid)[off];
     break;
   case FloatField :
-    rv = mFColsP[sk]->GetSegment(bid)[off];
+    rv = mFColsP[sk]->GetCstSegment(bid)[off];
     break;
   case DoubleField :
-    rv = mDColsP[sk]->GetSegment(bid)[off];
+    rv = mDColsP[sk]->GetCstSegment(bid)[off];
     break;
   case StringField :
-    rv = atof(mSColsP[sk]->GetSegment(bid)[off].c_str());
+    rv = atof(mSColsP[sk]->GetCstSegment(bid)[off].c_str());
     break;
   default:
@@ -365,5 +368,5 @@
   if ((n < 0) || (n >= NEntry())) 
     throw RangeCheckError("BaseDataTable::GetCell() out of range line index n");
-  if ((k < 0) || (n >= NVar())) 
+  if ((k < 0) || (k >= NVar())) 
     throw RangeCheckError("BaseDataTable::GetCell() out of range column index k");
   MuTyV rv;;
@@ -373,17 +376,17 @@
   switch (mNames[k].type) {
   case IntegerField :
-    rv = mIColsP[sk]->GetSegment(bid)[off];
+    rv = mIColsP[sk]->GetCstSegment(bid)[off];
     break;
   case LongField :
-    rv = mLColsP[sk]->GetSegment(bid)[off];
+    rv = mLColsP[sk]->GetCstSegment(bid)[off];
     break;
   case FloatField :
-    rv = mFColsP[sk]->GetSegment(bid)[off];
+    rv = mFColsP[sk]->GetCstSegment(bid)[off];
     break;
   case DoubleField :
-    rv = mDColsP[sk]->GetSegment(bid)[off];
+    rv = mDColsP[sk]->GetCstSegment(bid)[off];
     break;
   case StringField :
-    rv = atof(mSColsP[sk]->GetSegment(bid)[off].c_str());
+    rv = mSColsP[sk]->GetCstSegment(bid)[off];
     break;
   default:
@@ -420,5 +423,5 @@
   case IntegerField :
     for(size_t is=0; is<mIColsP[sk]->NbSegments(); is++) {
-      int_4* sp = mIColsP[sk]->GetSegment(is);
+      const int_4* sp = mIColsP[sk]->GetCstSegment(is);
       for(size_t n=0; n<mIColsP[sk]->SegmentSize(); n++) {
 	if (cnt >= NEntry())  break;
@@ -432,5 +435,5 @@
   case LongField :
     for(size_t is=0; is<mLColsP[sk]->NbSegments(); is++) {
-      int_8* sp = mLColsP[sk]->GetSegment(is);
+      const int_8* sp = mLColsP[sk]->GetCstSegment(is);
       for(size_t n=0; n<mLColsP[sk]->SegmentSize(); n++) {
 	if (cnt >= NEntry())  break;
@@ -443,5 +446,5 @@
   case FloatField :
     for(size_t is=0; is<mFColsP[sk]->NbSegments(); is++) {
-      r_4* sp = mFColsP[sk]->GetSegment(is);
+      const r_4* sp = mFColsP[sk]->GetCstSegment(is);
       for(size_t n=0; n<mFColsP[sk]->SegmentSize(); n++) {
 	if (cnt >= NEntry())  break;
@@ -454,5 +457,5 @@
   case DoubleField :
     for(size_t is=0; is<mDColsP[sk]->NbSegments(); is++) {
-      r_8* sp = mDColsP[sk]->GetSegment(is);
+      const r_8* sp = mDColsP[sk]->GetCstSegment(is);
       for(size_t n=0; n<mDColsP[sk]->SegmentSize(); n++) {
 	if (cnt >= NEntry())  break;
@@ -524,11 +527,13 @@
 string BaseDataTable::LineHeaderToString() const 
 {
-  char buff[32];
-  string rets=" Num    ";
+  string rets,s;
+  
   for(int i=0; i<NVar(); i++) {
-    sprintf(buff, "%8s ", NomIndex(i).c_str() );
-    rets += buff;
-  }
-  rets += '\n';
+    s = mNames[i].nom;
+    s += ' ';
+    size_t l = s.length();
+    for(size_t ii=l; ii<10; ii++) s += ' ';
+    rets += s;
+  }
   return(rets);  
 }
@@ -547,17 +552,17 @@
     switch (mNames[k].type) {
     case IntegerField :
-      rv = mIColsP[sk]->GetSegment(bid)[off];
+      rv = mIColsP[sk]->GetCstSegment(bid)[off];
       break;
     case LongField :
-      rv = mLColsP[sk]->GetSegment(bid)[off];
+      rv = mLColsP[sk]->GetCstSegment(bid)[off];
       break;
     case FloatField :
-      rv = mFColsP[sk]->GetSegment(bid)[off];
+      rv = mFColsP[sk]->GetCstSegment(bid)[off];
       break;
     case DoubleField :
-      rv = mDColsP[sk]->GetSegment(bid)[off];
+      rv = mDColsP[sk]->GetCstSegment(bid)[off];
       break;
     case StringField :
-      rv = atof(mSColsP[sk]->GetSegment(bid)[off].c_str());
+      rv = mSColsP[sk]->GetCstSegment(bid)[off];
     break;
     default:
@@ -565,6 +570,9 @@
       break;
     }
-    rs += " ";
-    rs += (string)rv;
+    string s = (string)rv;
+    s += ' ';
+    size_t l = s.length();
+    for(size_t ii=l; ii<10; ii++) s += ' ';
+    rs += s;
   }
   return rs;
Index: trunk/SophyaLib/HiStats/basedtable.h
===================================================================
--- trunk/SophyaLib/HiStats/basedtable.h	(revision 2696)
+++ trunk/SophyaLib/HiStats/basedtable.h	(revision 2699)
@@ -87,8 +87,9 @@
   //! Copy or merges  the data from \b a into the data table (cp=true -> copy)
   virtual void      CopyMerge(BaseDataTable const& a, bool cp=false) ; 
-  //! Equal (copy) operator
-  inline BaseDataTable&  operator = (BaseDataTable const& a) 
-  { CopyMerge(a, true) ; return *this ; } 
-   
+
+  //! Clear/reset the table content and structure.
+  virtual void Clear() = 0;
+
+  // ---- ASCII I/O
   void              Print(int num, int nmax=1) const ;
   
@@ -101,5 +102,7 @@
   int		    FillFromASCIIFile(string const& fn);
   
-  // Declaration de l interface NTuple
+  //-------------------------------------------------------------
+  //-----------  Declaration de l interface NTuple --------------
+
   virtual sa_size_t NbLines() const ;
   virtual sa_size_t NbColumns() const ;
@@ -115,4 +118,7 @@
   virtual string    LineHeaderToString() const;
   virtual string    LineToString(sa_size_t n) const;  
+
+  //  Pour la gestion de persistance PPF
+  friend class ObjFileIO<BaseDataTable> ;
   
 protected:
Index: trunk/SophyaLib/HiStats/datatable.cc
===================================================================
--- trunk/SophyaLib/HiStats/datatable.cc	(revision 2696)
+++ trunk/SophyaLib/HiStats/datatable.cc	(revision 2699)
@@ -217,155 +217,2 @@
 }
 
-/*!
-   \class SOPHYA::ObjFileIO<DataTable>
-   \ingroup HiStats
-   Persistence (serialisation) handler for class DataTable
-*/
-/* --Methode-- */ 
-DECL_TEMP_SPEC  /* equivalent a template <> , pour SGI-CC en particulier */
-void   ObjFileIO<DataTable>::WriteSelf(POutPersist& s)  const
-//	Serialisation en ecriture du DataTable sur stream PPF
-{
-  if (dobj == NULL)   
-    throw NullPtrError("ObjFileIO<DataTable>::WriteSelf() NULL dobj pointer ");
-  //-------  On ecrit 3 uint_4 .... 
-  //  [0]: Numero de version ;
-  //  [1] : bit1 non nul -> has info  
-  //  [2] : reserve
-  uint_4 itab[3];
-  itab[0] = 1;  // Numero de version a 1
-  itab[1] = itab[2] = 0;
-  if (dobj->mInfo)  itab[1] = 1;
-  s.Put(itab, 3);
-
-  //-------- Ecriture de segment size, nb de colonnes, nb de lignes ...  
-  // [0] : SegmentSize()        [1] : NVar()
-  // [2] : NEntry()             [3] : NbSegments()
-  uint_8 ltab[5];
-  ltab[0] = dobj->SegmentSize();
-  ltab[1] = dobj->NVar();
-  ltab[2] = dobj->NEntry();
-  ltab[3] = dobj->NbSegments();
-  ltab[4] = 0;
-  s.Put(ltab, 5);
-
-  //------ Ecriture du nom et type des colonnes
-  for(sa_size_t k=0; k<dobj->NVar(); k++) { 
-    uint_2 typ = dobj->mNames[k].type;
-    s.Put(typ);
-    s.Put(dobj->mNames[k].nom);
-  }
-  // ------- Ecriture des tableaux min,max et n_minmax
-  for(uint_8 k=0; k<ltab[1]; k++) { 
-    s.Put(dobj->mMin[k]);
-    s.Put(dobj->mMax[k]);
-    s.Put(dobj->mMinMaxNEnt[k]);
-  }  
-  //------- Ecriture du DVList Info() associe, si existant
-  if (dobj->mInfo)  s << (*(dobj->mInfo));
-
-  //------- Ecriture des SegDataBlock<T> 
-  for (size_t kk=0; kk<dobj->mNames.size(); kk++) {
-    sa_size_t sk = dobj->mNames[kk].ser;
-    switch (dobj->mNames[kk].type) {
-    case BaseDataTable::IntegerField :
-      s << dobj->mICols[sk]; 
-    break;
-    case BaseDataTable::LongField :
-      s << dobj->mLCols[sk]; 
-      break;
-    case BaseDataTable::FloatField :
-      s << dobj->mFCols[sk]; 
-      break;
-    case BaseDataTable::DoubleField :
-      s << dobj->mDCols[sk]; 
-      break;
-    case BaseDataTable::StringField :
-      s << dobj->mSCols[sk]; 
-      break;
-    default:
-      throw ForbiddenError("ObjFileIO<DataTable>::WriteSelf() : unknown column type ");
-    break;
-    }
-  }    
-  return;
-}
-
-/* --Methode-- */
-DECL_TEMP_SPEC  /* equivalent a template <> , pour SGI-CC en particulier */
-void  ObjFileIO<DataTable>::ReadSelf(PInPersist& s)
-//	Serialisation en lecture du DataTable sur stream PPF
-{
-  // ------- On lit les 3 premiers uint_4
-  //  [0]: Numero de version ;
-  //  [1] : bit1 non nul -> has info  
-  //  [2] : reserve
-  uint_4 itab[3] = {0,0,0};
-  s.Get(itab, 3);
-  bool hadinfo = false;
-  if ((itab[1]&1) == 1)  hadinfo = true;
-
-  // -------- Lecture de segment size, nb de colonnes, nb de lignes ...  
-  // [0] : SegmentSize()        [1] : NVar()
-  // [2] : NEntry()             [3] : NbSegments()
-  uint_8 ltab[5] = {0,0,0,0,0};
-  s.Get(ltab, 5);
-  if (dobj == NULL) dobj = new DataTable(ltab[0]);
-  else { dobj->Clear();  dobj->mSegSz = ltab[0]; }
-  // -------- Lecture nom/type colonnes et allocation des colonnes
-  uint_2 typ; 
-  string cnom;
-  for(uint_8 k=0; k<ltab[1]; k++) { 
-    s.Get(typ);
-    s.Get(cnom);
-    BaseDataTable::FieldType ft = (BaseDataTable::FieldType)typ;
-    dobj->AddColumn(ft, cnom);
-  }
-  // ------- Lecture des tableaux min,max et n_minmax
-  for(uint_8 k=0; k<ltab[1]; k++) { 
-    s.Get(dobj->mMin[k]);
-    s.Get(dobj->mMax[k]);
-    s.Get(dobj->mMinMaxNEnt[k]);
-  }  
-  // ------- Lecture du DVList Info() associe, si necessaire
-  if (hadinfo) {    // Lecture eventuelle du DVList Info
-    if (dobj->mInfo == NULL)  dobj->mInfo = new DVList;
-    s >> (*(dobj->mInfo));
-  }
-  // ------- Mise a jour des champs Nb d'entrees, nb segments ...
-  dobj->mNEnt = ltab[2];
-  dobj->mNSeg = ltab[3];
-  // ------- Lecture des SegDataBlock<T> 
-  for (size_t kk=0; kk<dobj->mNames.size(); kk++) {
-    sa_size_t sk = dobj->mNames[kk].ser;
-    switch (dobj->mNames[kk].type) {
-    case BaseDataTable::IntegerField :
-      s >> dobj->mICols[sk]; 
-    break;
-    case BaseDataTable::LongField :
-      s >> dobj->mLCols[sk]; 
-      break;
-    case BaseDataTable::FloatField :
-      s >> dobj->mFCols[sk]; 
-      break;
-    case BaseDataTable::DoubleField :
-      s >> dobj->mDCols[sk]; 
-      break;
-    case BaseDataTable::StringField :
-      s >> dobj->mSCols[sk]; 
-      break;
-    default:
-      throw ForbiddenError("ObjFileIO<DataTable>::ReadSelf() : unknown column type ");
-    break;
-    }
-  }    
-return;
-}
-
-#ifdef __CXX_PRAGMA_TEMPLATES__
-#pragma define_template ObjFileIO<DataTable>
-#endif
-
-#if defined(ANSI_TEMPLATES) || defined(GNU_TEMPLATES)
-template class ObjFileIO<DataTable>;
-#endif
Index: trunk/SophyaLib/HiStats/datatable.h
===================================================================
--- trunk/SophyaLib/HiStats/datatable.h	(revision 2696)
+++ trunk/SophyaLib/HiStats/datatable.h	(revision 2699)
@@ -31,10 +31,10 @@
 
   //  Pour la gestion de persistance PPF
-  friend class ObjFileIO<DataTable> ;
+  friend class ObjFileIO<BaseDataTable> ;
   // pour fichiers FITS
   friend class FITS_DataTable;
   
   //! Reset the table content and structure
-  void Clear();
+  virtual void Clear();
 protected:
   void Share(DataTable const & a);
@@ -51,10 +51,11 @@
 /*! Writes the object in the POutPersist stream \b os */
 inline POutPersist& operator << (POutPersist& os, DataTable & obj)
-{ ObjFileIO<DataTable> fio(&obj);  fio.Write(os);  return(os); }
+{ ObjFileIO<BaseDataTable> fio(&obj);  fio.Write(os);  return(os); }
 /*! Reads the object from the PInPersist stream \b is */
 inline PInPersist& operator >> (PInPersist& is, DataTable & obj)
-{ ObjFileIO<DataTable> fio(&obj); is.SkipToNextObject(); fio.Read(is); return(is); }
+{ ObjFileIO<BaseDataTable> fio(&obj); is.SkipToNextObject(); 
+  fio.Read(is); return(is); }
 // Classe pour la gestion de persistance
-// ObjFileIO<DataTable>
+// ObjFileIO<BaseDataTable>
 } // namespace SOPHYA
 
Index: trunk/SophyaLib/HiStats/histats.h
===================================================================
--- trunk/SophyaLib/HiStats/histats.h	(revision 2696)
+++ trunk/SophyaLib/HiStats/histats.h	(revision 2699)
@@ -10,4 +10,5 @@
 #include "xntuple.h"
 #include "datatable.h"
+#include "swppfdtable.h"
 
 #endif // HISTATS_SEEN
Index: trunk/SophyaLib/HiStats/histinit.cc
===================================================================
--- trunk/SophyaLib/HiStats/histinit.cc	(revision 2696)
+++ trunk/SophyaLib/HiStats/histinit.cc	(revision 2699)
@@ -13,4 +13,5 @@
 #include "xntuple.h"
 #include "datatable.h"
+#include "swppfdtable.h"
 
 /*!
@@ -48,6 +49,7 @@
   DObjRegister(ObjFileIO<XNTuple>, XNTuple);
 
-  PPRegister(ObjFileIO<DataTable>);
-  DObjRegister(ObjFileIO<DataTable>, DataTable);
+  PPRegister(ObjFileIO<BaseDataTable>);
+  DObjRegister(ObjFileIO<BaseDataTable>, DataTable);
+  DObjRegister(ObjFileIO<BaseDataTable>, SwPPFDataTable);
 
 }
Index: trunk/SophyaLib/HiStats/objlist.list
===================================================================
--- trunk/SophyaLib/HiStats/objlist.list	(revision 2696)
+++ trunk/SophyaLib/HiStats/objlist.list	(revision 2699)
@@ -1,4 +1,5 @@
 basedtable.o
 datatable.o
+fio_dtable.o
 hisprof.o
 histerr.o
@@ -9,3 +10,4 @@
 ntuple.o
 proxtuple.o
+swppfdtable.o
 xntuple.o
Index: trunk/SophyaLib/HiStats/swppfdtable.cc
===================================================================
--- trunk/SophyaLib/HiStats/swppfdtable.cc	(revision 2696)
+++ trunk/SophyaLib/HiStats/swppfdtable.cc	(revision 2699)
@@ -46,6 +46,6 @@
 SwPPFDataTable::SwPPFDataTable(POutPersist & os, sa_size_t segsz)
   : BaseDataTable(segsz) ,
-    mISwapper(os), mLSwapper(os), mFSwapper(os), mDSwapper(os), mSSwapper(os),
-    mSwOut(&os), mSwIn(NULL)
+    mSwOut(&os), mSwIn(NULL),
+    mISwapper(os), mLSwapper(os), mFSwapper(os), mDSwapper(os), mSSwapper(os)
 {
 }
@@ -53,7 +53,14 @@
 SwPPFDataTable::SwPPFDataTable(PInPersist & is, sa_size_t segsz)
   : BaseDataTable(segsz) ,
-    mISwapper(is), mLSwapper(is), mFSwapper(is), mDSwapper(is), mSSwapper(is),
-    mSwOut(NULL), mSwIn(&is)
-{
+    mSwOut(NULL), mSwIn(NULL)
+{
+  PInPersist* pis = new PInPersist(is.FileName(), false);
+  mSwIn = new St_InSwap;
+  mSwIn->pis = pis;  mSwIn->refcnt = 1;
+  mISwapper.SetInStream(*pis);
+  mLSwapper.SetInStream(*pis);
+  mFSwapper.SetInStream(*pis);
+  mDSwapper.SetInStream(*pis);
+  mDSwapper.SetInStream(*pis);
 }
 
@@ -64,4 +71,16 @@
 {
   Share(a);
+}
+//! Destructor - Deletes / closes the input PPF swap stream  
+SwPPFDataTable::~SwPPFDataTable()
+{
+  if (mSwIn) { 
+    mSwIn->refcnt--;
+    if (mSwIn->refcnt == 0) {
+      delete mSwIn->pis;
+      delete mSwIn;
+      mSwIn = NULL;
+    }
+  }
 }
 
@@ -77,4 +96,5 @@
   mSwOut = a.mSwOut;
   mSwIn = a.mSwIn;
+  if (mSwIn)  mSwIn->refcnt++;  // comptage de reference pour le stream input 
 
   // On recopie la taille de segment
@@ -277,172 +297,2 @@
 }
 
-/*!
-   \class SOPHYA::ObjFileIO<SwPPFDataTable>
-   \ingroup HiStats
-   Persistence (serialisation) handler for class SwPPFDataTable
-*/
-/* --Methode-- */ 
-DECL_TEMP_SPEC  /* equivalent a template <> , pour SGI-CC en particulier */
-void   ObjFileIO<SwPPFDataTable>::WriteSelf(POutPersist& s)  const
-//	Serialisation en ecriture du SwPPFDataTable sur stream PPF
-{
-  if (dobj == NULL)   
-    throw NullPtrError("ObjFileIO<SwPPFDataTable>::WriteSelf() NULL dobj pointer ");
-  if (dobj->mSwOut != &s) 
-    throw NotAvailableOperation("ObjFileIO<SwPPFDataTable>::WriteSelf() OutputStream <> SwapStream");
-  //-------  On ecrit 3 uint_4 .... 
-  //  [0]: Numero de version ;
-  //  [1] : bit1 non nul -> has info  
-  //  [2] : reserve
-  uint_4 itab[3];
-  itab[0] = 1;  // Numero de version a 1
-  itab[1] = itab[2] = 0;
-  if (dobj->mInfo)  itab[1] = 1;
-  s.Put(itab, 3);
-
-  //-------- Ecriture de segment size, nb de colonnes, nb de lignes ...  
-  // [0] : SegmentSize()        [1] : NVar()
-  // [2] : NEntry()             [3] : NbSegments()
-  uint_8 ltab[5];
-  ltab[0] = dobj->SegmentSize();
-  ltab[1] = dobj->NVar();
-  ltab[2] = dobj->NEntry();
-  ltab[3] = dobj->NbSegments();
-  ltab[4] = 0;
-  s.Put(ltab, 5);
-
-  //------ Ecriture du nom et type des colonnes
-  for(sa_size_t k=0; k<dobj->NVar(); k++) { 
-    uint_2 typ = dobj->mNames[k].type;
-    s.Put(typ);
-    s.Put(dobj->mNames[k].nom);
-  }
-  // ------- Ecriture des tableaux min,max et n_minmax
-  for(uint_8 k=0; k<ltab[1]; k++) { 
-    s.Put(dobj->mMin[k]);
-    s.Put(dobj->mMax[k]);
-    s.Put(dobj->mMinMaxNEnt[k]);
-  }  
-  //------- Ecriture du DVList Info() associe, si existant
-  if (dobj->mInfo)  s << (*(dobj->mInfo));
-
-  //------- Ecriture des tables de positionnement de SwSegDataBlock<T> 
-  for (size_t kk=0; kk<dobj->mNames.size(); kk++) {
-    sa_size_t sk = dobj->mNames[kk].ser;
-    switch (dobj->mNames[kk].type) {
-    case BaseDataTable::IntegerField :
-      s.PutPosTagTable(dobj->mICols[sk].GetSwapPosTagTable()); 
-      break;
-    case BaseDataTable::LongField :
-      s.PutPosTagTable(dobj->mLCols[sk].GetSwapPosTagTable()); 
-      break;
-    case BaseDataTable::FloatField :
-      s.PutPosTagTable(dobj->mFCols[sk].GetSwapPosTagTable()); 
-      break;
-    case BaseDataTable::DoubleField :
-      s.PutPosTagTable(dobj->mDCols[sk].GetSwapPosTagTable()); 
-      break;
-    case BaseDataTable::StringField :
-      s.PutPosTagTable(dobj->mSCols[sk].GetSwapPosTagTable()); 
-      break;
-    default:
-      throw ForbiddenError("ObjFileIO<SwPPFDataTable>::WriteSelf() : unknown column type ");
-    break;
-    }
-  }    
-  return;
-}
-
-/* --Methode-- */
-DECL_TEMP_SPEC  /* equivalent a template <> , pour SGI-CC en particulier */
-void  ObjFileIO<SwPPFDataTable>::ReadSelf(PInPersist& s)
-//	Serialisation en lecture du SwPPFDataTable sur stream PPF
-{
-  // ------- On lit les 3 premiers uint_4
-  //  [0]: Numero de version ;
-  //  [1] : bit1 non nul -> has info  
-  //  [2] : reserve
-  uint_4 itab[3] = {0,0,0};
-  s.Get(itab, 3);
-  bool hadinfo = false;
-  if ((itab[1]&1) == 1)  hadinfo = true;
-
-  // -------- Lecture de segment size, nb de colonnes, nb de lignes ...  
-  // [0] : SegmentSize()        [1] : NVar()
-  // [2] : NEntry()             [3] : NbSegments()
-  uint_8 ltab[5] = {0,0,0,0,0};
-  s.Get(ltab, 5);
-  if (dobj == NULL) dobj = new SwPPFDataTable(s, ltab[0]);
-  else { 
-    // Copie brutale en utilisant l'operateur = 
-     *dobj = SwPPFDataTable(s, ltab[0]);
-  }
-  // -------- Lecture nom/type colonnes et allocation des colonnes
-  uint_2 typ; 
-  string cnom;
-  for(uint_8 k=0; k<ltab[1]; k++) { 
-    s.Get(typ);
-    s.Get(cnom);
-    BaseDataTable::FieldType ft = (BaseDataTable::FieldType)typ;
-    dobj->AddColumn(ft, cnom);
-  }
-  // ------- Lecture des tableaux min,max et n_minmax
-  for(uint_8 k=0; k<ltab[1]; k++) { 
-    s.Get(dobj->mMin[k]);
-    s.Get(dobj->mMax[k]);
-    s.Get(dobj->mMinMaxNEnt[k]);
-  }  
-  // ------- Lecture du DVList Info() associe, si necessaire
-  if (hadinfo) {    // Lecture eventuelle du DVList Info
-    if (dobj->mInfo == NULL)  dobj->mInfo = new DVList;
-    s >> (*(dobj->mInfo));
-  }
-  // ------- Mise a jour des champs Nb d'entrees, nb segments ...
-  dobj->mNEnt = ltab[2];
-  dobj->mNSeg = ltab[3];
-  cout << " DEBUG___ SegmentSize()= " << dobj->SegmentSize() << endl;
-  // ------- Lecture des tag de positionnement des SwSegDataBlock<T> 
-  vector<int_8> swpos;
-  for (size_t kk=0; kk<dobj->mNames.size(); kk++) {
-    sa_size_t sk = dobj->mNames[kk].ser;
-    switch (dobj->mNames[kk].type) {
-    case BaseDataTable::IntegerField :
-      swpos.clear();
-      s.GetPosTagTable(swpos);
-      dobj->mICols[sk] = SwSegDataBlock<int_4>(dobj->mISwapper, swpos, dobj->SegmentSize());
-    break;
-    case BaseDataTable::LongField :
-      swpos.clear();
-      s.GetPosTagTable(swpos);
-      dobj->mLCols[sk] = SwSegDataBlock<int_8>(dobj->mLSwapper, swpos, dobj->SegmentSize());
-      break;
-    case BaseDataTable::FloatField :
-      swpos.clear();
-      s.GetPosTagTable(swpos);
-      dobj->mFCols[sk] = SwSegDataBlock<r_4>(dobj->mFSwapper, swpos, dobj->SegmentSize());
-      break;
-    case BaseDataTable::DoubleField :
-      swpos.clear();
-      s.GetPosTagTable(swpos);
-      dobj->mDCols[sk] = SwSegDataBlock<r_8>(dobj->mDSwapper, swpos, dobj->SegmentSize());
-      break;
-    case BaseDataTable::StringField :
-      swpos.clear();
-      s.GetPosTagTable(swpos);
-      dobj->mSCols[sk] = SwSegDataBlock<string>(dobj->mSSwapper, swpos, dobj->SegmentSize());
-      break;
-    default:
-      throw ForbiddenError("ObjFileIO<SwPPFDataTable>::ReadSelf() : unknown column type ");
-    break;
-    }
-  }    
-return;
-}
-
-#ifdef __CXX_PRAGMA_TEMPLATES__
-#pragma define_template ObjFileIO<SwPPFDataTable>
-#endif
-
-#if defined(ANSI_TEMPLATES) || defined(GNU_TEMPLATES)
-template class ObjFileIO<SwPPFDataTable>;
-#endif
Index: trunk/SophyaLib/HiStats/swppfdtable.h
===================================================================
--- trunk/SophyaLib/HiStats/swppfdtable.h	(revision 2696)
+++ trunk/SophyaLib/HiStats/swppfdtable.h	(revision 2699)
@@ -20,5 +20,7 @@
   SwPPFDataTable(POutPersist & os, sa_size_t segsz=512); 
   SwPPFDataTable(SwPPFDataTable const& a); 
-  
+
+  virtual ~SwPPFDataTable();
+
   virtual sa_size_t AddColumn(FieldType ft, string const & cnom);
 
@@ -32,8 +34,8 @@
 
   //  Pour la gestion de persistance PPF
-  friend class ObjFileIO<SwPPFDataTable> ;
+  friend class ObjFileIO<BaseDataTable> ;
   
   //! Reset the table content and structure
-  void Clear();
+  virtual void Clear();
   /*! This method should be called in order to empty the swapout buffer, 
      before saving object to PPF stream 
@@ -56,16 +58,21 @@
   PPFDataSwapper<string> mSSwapper;
  
-  POutPersist* mSwOut;
-  PInPersist* mSwIn;
+  // Output swap stream doit etre cree avant l'appel au constructeur
+  // et rester valide (non detruit) tant que l'objet SwPPFDataTable existe
+  POutPersist* mSwOut;   
+  // Input swap stream - On cree un input swap stream et on fait 
+  // un comptage de reference pour le detruire lorsque tous les tables
+  // l'utilisant sont supprimes
+  typedef struct { PInPersist* pis; uint_4 refcnt; } St_InSwap; 
+  St_InSwap * mSwIn;
 }; 
   
 /*! Writes the object in the POutPersist stream \b os */
 inline POutPersist& operator << (POutPersist& os, SwPPFDataTable & obj)
-{ obj.SwapOutAll();  ObjFileIO<SwPPFDataTable> fio(&obj);  fio.Write(os);  return(os); }
+{ obj.SwapOutAll();  ObjFileIO<BaseDataTable> fio(&obj);  fio.Write(os);  return(os); }
 /*! Reads the object from the PInPersist stream \b is */
 inline PInPersist& operator >> (PInPersist& is, SwPPFDataTable & obj)
-{  ObjFileIO<SwPPFDataTable> fio(&obj); is.SkipToNextObject(); fio.Read(is); return(is); }
-// Classe pour la gestion de persistance
-// ObjFileIO<SwPPFDataTable>
+{  ObjFileIO<BaseDataTable> fio(&obj); is.SkipToNextObject(); fio.Read(is); return(is); }
+
 } // namespace SOPHYA
 
