Index: trunk/SophyaLib/BaseTools/defs.h
===================================================================
--- trunk/SophyaLib/BaseTools/defs.h	(revision 268)
+++ 	(revision )
@@ -1,1 +1,0 @@
-#include "machdefs.h"
Index: trunk/SophyaLib/BaseTools/machdefs.h
===================================================================
--- trunk/SophyaLib/BaseTools/machdefs.h	(revision 268)
+++ trunk/SophyaLib/BaseTools/machdefs.h	(revision 269)
@@ -230,5 +230,6 @@
 
 #ifdef __GNUG__
-#define GNU_TEMPLATES
+#define ANSI_TEMPLATES
+// #define GNU_TEMPLATES
 #define HAS_STR_NPOS
 #define HAS_EXPLICIT
Index: trunk/SophyaLib/BaseTools/ndatablock.cc
===================================================================
--- trunk/SophyaLib/BaseTools/ndatablock.cc	(revision 268)
+++ trunk/SophyaLib/BaseTools/ndatablock.cc	(revision 269)
@@ -9,4 +9,5 @@
 #include "pexceptions.h"
 #include "ndatablock.h"
+#include "objfio.h"
 
 using namespace PlanckDPC;
@@ -245,4 +246,6 @@
 // Re-dimension, dans ce cas re-allocation de la place
 {
+// Pas de realloc, si pas de changement de taille ?
+if (n == mSz)  return;  // $CHECK$ A verifier , Reza 26/04/99
 Alloc(n);
 }
@@ -275,5 +278,5 @@
 if(i1>=mSz || n<=0 || !p) return;
 size_t i2 = i1+n; if(i2>mSz) i2=mSz;
-size_t im = 1; bool enl;
+size_t im = 1; bool enl=false;
 while(i1<i2) {
   enl = false;
@@ -561,4 +564,82 @@
 }
 return result;
+}
+
+
+// -------------------------------------------------------------------------
+//   Les objets delegues pour la gestion de persistance 
+// -------------------------------------------------------------------------
+
+/*
+template <class T>
+void ObjFileIO< NDataBlock<T> >::ReadSelf(PInPersist& is)
+template <class T>
+void ObjFileIO< NDataBlock<T> >::WriteSelf(POutPersist& os)
+*/
+
+template <class T>
+FIO_NDataBlock<T>::FIO_NDataBlock()
+{
+dobj=new NDataBlock<T>;
+}
+
+template <class T>
+FIO_NDataBlock<T>::FIO_NDataBlock(string const & filename) 
+{
+dobj=new NDataBlock<T>; 
+Read(filename);
+}
+
+template <class T>
+FIO_NDataBlock<T>::FIO_NDataBlock(const NDataBlock<T> & obj) 
+{ 
+dobj = new NDataBlock<T>(obj); 
+}
+
+template <class T>
+FIO_NDataBlock<T>::FIO_NDataBlock(const NDataBlock<T> * obj) 
+{ 
+dobj = new NDataBlock<T>(*obj); 
+}
+
+template <class T>
+FIO_NDataBlock<T>::~FIO_NDataBlock()
+{
+if (dobj) delete dobj;
+}
+
+template <class T>
+AnyDataObj* FIO_NDataBlock<T>::DataObj()
+{
+return(dobj);
+}
+
+
+template <class T>
+void FIO_NDataBlock<T>::ReadSelf(PInPersist& is)
+{
+// On lit les 3 premiers uint_8
+uint_8 itab[3];
+is.Get(itab, 3);
+if (dobj == NULL) dobj = new NDataBlock<T>(itab[1]);
+else dobj->ReSize(itab[1]);
+// On lit le tableau de nombres
+PIOSReadArray(is, dobj->Data(), dobj->Size()); 
+}
+
+
+template <class T>
+void FIO_NDataBlock<T>::WriteSelf(POutPersist& os) const
+{
+if (dobj == NULL)   return;  // Attention - $CHECK$ Reza 26/04/99
+//  On ecrit 3 uint_4 
+//  0 : Numero de version,  1 : Taille,  2  reserve a l
+uint_8 itab[3];
+itab[0] = 1;
+itab[1] = dobj->Size();
+itab[2] = 0;
+os.Put(itab, 3);
+//  On ecrit le tableau de nombres 
+PIOSWriteArray(os, dobj->Data(), dobj->Size()); 
 }
 
@@ -577,7 +658,23 @@
 #pragma define_template NDataBlock< complex<float> >
 #pragma define_template NDataBlock< complex<double> >
-#endif
-
-#ifdef __GNU_TEMPLATES__
+
+// Instances des delegues FileIO (PPersist)
+#pragma define_template FIO_NDataBlock<uint_1>;
+#pragma define_template FIO_NDataBlock<uint_2>;
+#pragma define_template FIO_NDataBlock<int_2>;
+#pragma define_template FIO_NDataBlock<int_4>;
+#pragma define_template FIO_NDataBlock<int_8>;
+#pragma define_template FIO_NDataBlock<uint_2>;
+#pragma define_template FIO_NDataBlock<uint_4>;
+#pragma define_template FIO_NDataBlock<uint_8>;
+#pragma define_template FIO_NDataBlock<r_8>;
+#pragma define_template FIO_NDataBlock<r_4>;
+#pragma define_template FIO_NDataBlock< complex<float> >;
+#pragma define_template FIO_NDataBlock< complex<double> >;
+
+#endif
+
+
+#if defined(ANSI_TEMPLATES) || defined(GNU_TEMPLATES)
 template class NDataBlock<uint_1>;
 template class NDataBlock<uint_2>;
@@ -592,18 +689,17 @@
 template class NDataBlock< complex<float> >;
 template class NDataBlock< complex<double> >;
-#endif
-
-#if defined(__ANSI_TEMPLATES__) 
-template class NDataBlock<uint_1>;
-template class NDataBlock<uint_2>;
-template class NDataBlock<int_2>;
-template class NDataBlock<int_4>;
-template class NDataBlock<int_8>;
-template class NDataBlock<uint_2>;
-template class NDataBlock<uint_4>;
-template class NDataBlock<uint_8>;
-template class NDataBlock<r_4>;
-template class NDataBlock<r_8>;
-template class NDataBlock< complex<float> >;
-template class NDataBlock< complex<double> >;
-#endif
+
+// Instances des delegues FileIO (PPersist)
+template class FIO_NDataBlock<uint_1>;
+template class FIO_NDataBlock<uint_2>;
+template class FIO_NDataBlock<int_2>;
+template class FIO_NDataBlock<int_4>;
+template class FIO_NDataBlock<int_8>;
+template class FIO_NDataBlock<uint_2>;
+template class FIO_NDataBlock<uint_4>;
+template class FIO_NDataBlock<uint_8>;
+template class FIO_NDataBlock<r_8>;
+template class FIO_NDataBlock<r_4>;
+template class FIO_NDataBlock< complex<float> >;
+template class FIO_NDataBlock< complex<double> >;
+#endif
Index: trunk/SophyaLib/BaseTools/ndatablock.h
===================================================================
--- trunk/SophyaLib/BaseTools/ndatablock.h	(revision 268)
+++ trunk/SophyaLib/BaseTools/ndatablock.h	(revision 269)
@@ -8,4 +8,5 @@
 #include "machdefs.h"
 #include "anydataobj.h"
+#include "ppersist.h"
 #include <iostream.h>
 
@@ -110,5 +111,5 @@
 template<class T>
 inline ostream& operator << (ostream& os, const NDataBlock<T>& a)
-                      {Print(os); return(os);}
+                      {a.Print(os); return(os);}
 template<class T>
 inline NDataBlock<T> operator + (const NDataBlock<T>& a,T b)
@@ -149,4 +150,26 @@
                       {return a.Div(b);}
 
+
+// Classe pour la gestion de persistance
+template <class T>
+class FIO_NDataBlock : public  PPersist  {
+
+public:
+	    FIO_NDataBlock();
+	    FIO_NDataBlock(string const & filename); 
+	    FIO_NDataBlock(const NDataBlock<T> & obj);
+	    FIO_NDataBlock(const NDataBlock<T> * obj);
+  virtual   ~FIO_NDataBlock();
+
+  virtual   AnyDataObj* DataObj();
+  inline operator NDataBlock<T>() { return(*dobj); }
+
+protected :
+  virtual void       ReadSelf(PInPersist&);           
+  virtual void       WriteSelf(POutPersist&) const;  
+  NDataBlock<T> * dobj;
+
+};
+
 } // Fin du namespace
 
Index: trunk/SophyaLib/BaseTools/objfio.h
===================================================================
--- trunk/SophyaLib/BaseTools/objfio.h	(revision 269)
+++ trunk/SophyaLib/BaseTools/objfio.h	(revision 269)
@@ -0,0 +1,184 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Classe de gestion des I/O fichiers des objets 
+//                          R.Ansari          04/99
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#ifndef OBJFILEIO_H_SEEN
+#define OBJFILEIO_H_SEEN
+
+#include "machdefs.h"
+#include "anydataobj.h"
+#include "ppersist.h"
+
+namespace PlanckDPC {
+
+  /*
+// Pour gerer les Persist I/O de tableaux numerique templates
+template <class T>
+void PIOSReadArray(PInPersist & is, T* arr, size_t n);
+template <class T>
+void PIOSWriteArray(POutPersist & os, T const * arr, size_t n);
+  */
+
+
+template <class T>
+class ObjFileIO : public PPersist {
+
+public :
+	    ObjFileIO() { dobj=new T; }
+	    ObjFileIO(string const & filename) { dobj=new T; Read(filename); }
+	    ObjFileIO(const T & obj) { dobj = new T(obj); }
+	    ObjFileIO(const T * obj) { dobj = new T(*obj); }
+  virtual   ~ObjFileIO() { if (dobj) delete dobj; }
+
+  virtual   AnyDataObj* DataObj() { return(dobj); }
+  inline operator T() { return(*dobj); }
+
+protected :
+  virtual void       ReadSelf(PInPersist&);           
+  virtual void       WriteSelf(POutPersist&) const;  
+
+  T * dobj;
+};
+
+// Fonctions d'ecriture de tableaux numeriques
+inline
+void PIOSReadArray(PInPersist & is, uint_1 * arr, size_t n)
+{
+is.GetBytes(arr, n);
+}
+
+inline
+void PIOSReadArray(PInPersist & is, uint_2 * arr, size_t n)
+{
+is.Get(arr, n);
+}
+
+inline
+void PIOSReadArray(PInPersist & is, int_2 * arr, size_t n)
+{
+is.Get(arr, n);
+}
+
+inline
+void PIOSReadArray(PInPersist & is, uint_4 * arr, size_t n)
+{
+is.Get(arr, n);
+}
+
+inline
+void PIOSReadArray(PInPersist & is, int_4 * arr, size_t n)
+{
+is.Get(arr, n);
+}
+
+inline
+void PIOSReadArray(PInPersist & is, uint_8 * arr, size_t n)
+{
+is.Get(arr, n);
+}
+
+inline
+void PIOSReadArray(PInPersist & is, int_8 * arr, size_t n)
+{
+is.Get(arr, n);
+}
+
+inline
+void PIOSReadArray(PInPersist & is, r_4 * arr, size_t n)
+{
+is.Get(arr, n);
+}
+
+inline
+void PIOSReadArray(PInPersist & is, r_8 * arr, size_t n)
+{
+is.Get(arr, n);
+}
+
+inline
+void PIOSReadArray(PInPersist & is, complex<float> * arr, size_t n)
+{
+r_4 * pr = (r_4 *)arr;
+is.Get(pr, n*2);
+}
+
+inline
+void PIOSReadArray(PInPersist & is, complex<double> * arr, size_t n)
+{
+r_8 * pr = (r_8 *)arr;
+is.Get(pr, n*2);
+}
+
+// Fonctions d ecriture de tableaux de nombre
+inline
+void PIOSWriteArray(POutPersist & os, uint_1 const * arr, size_t n)
+{
+os.PutBytes(arr, n);
+}
+
+inline
+void PIOSWriteArray(POutPersist & os, uint_2 const * arr, size_t n)
+{
+os.Put(arr, n);
+}
+
+inline
+void PIOSWriteArray(POutPersist & os, int_2 const * arr, size_t n)
+{
+os.Put(arr, n);
+}
+
+inline
+void PIOSWriteArray(POutPersist & os, uint_4 const * arr, size_t n)
+{
+os.Put(arr, n);
+}
+
+inline
+void PIOSWriteArray(POutPersist & os, int_4 const * arr, size_t n)
+{
+os.Put(arr, n);
+}
+
+inline
+void PIOSWriteArray(POutPersist & os, uint_8 const * arr, size_t n)
+{
+os.Put(arr, n);
+}
+
+inline
+void PIOSWriteArray(POutPersist & os, int_8 const * arr, size_t n)
+{
+os.Put(arr, n);
+}
+
+inline
+void PIOSWriteArray(POutPersist & os, r_4 const * arr, size_t n)
+{
+os.Put(arr, n);
+}
+
+inline
+void PIOSWriteArray(POutPersist & os, r_8 const * arr, size_t n)
+{
+os.Put(arr, n);
+}
+
+inline
+void PIOSWriteArray(POutPersist & os, complex<float> const * arr, size_t n)
+{
+r_4 const * pr = (r_4 const *)arr;
+os.Put(pr, n*2);
+}
+
+inline
+void PIOSWriteArray(POutPersist & os, complex<double> const * arr, size_t n)
+{
+r_8 const * pr = (r_8 const *)arr;
+os.Put(pr, n*2);
+}
+
+} // Fin namespace
+
+#endif
Index: trunk/SophyaLib/BaseTools/peidainit.cc
===================================================================
--- trunk/SophyaLib/BaseTools/peidainit.cc	(revision 268)
+++ trunk/SophyaLib/BaseTools/peidainit.cc	(revision 269)
@@ -3,4 +3,5 @@
 #include <stdio.h>
 #include "pexceptions.h"
+#include "ppersist.h"
 #include "peidainit.h"
 // ---  Classe d'initialisation de PEIDA++, (PPersistMgr en particulier)
@@ -22,4 +23,5 @@
   #endif
 
+  PIOPersist::Initialize();
 //DEL  PPersistMgr::classList = new PPersistMgr::ClassList;
 //DEL  PShPersist::objList    = new PShPersist::ObjList;
Index: trunk/SophyaLib/BaseTools/pexceptions.cc
===================================================================
--- trunk/SophyaLib/BaseTools/pexceptions.cc	(revision 268)
+++ trunk/SophyaLib/BaseTools/pexceptions.cc	(revision 269)
@@ -5,4 +5,10 @@
 
 void PFailHandler(void); 
+
+// egcs ne semble pas connaitre set_new_handler (Reza 26/04/99)
+#ifdef __GNUG__
+void PFailHandler(void) {}
+void InitFailNewHandler() {}
+#else
 
 void PFailHandler(void)
@@ -18,2 +24,3 @@
 }
 
+#endif
Index: trunk/SophyaLib/BaseTools/ppersist.cc
===================================================================
--- trunk/SophyaLib/BaseTools/ppersist.cc	(revision 268)
+++ trunk/SophyaLib/BaseTools/ppersist.cc	(revision 269)
@@ -37,6 +37,14 @@
 
 MD5_CTX PIOPersist::ctx;
-PIOPersist::ClassList PIOPersist::classList;
-
+PIOPersist::ClassList * PIOPersist::classList = NULL;   // $CHECK$ Reza 26/04/99
+
+//++
+void
+PIOPersist::Initialize()
+//  Initialisation globale (objets statiques) $CHECK$ Reza 26/04/99
+//--
+{
+classList = new PIOPersist::ClassList;
+}
 
 //++
@@ -51,5 +59,5 @@
 //--
 {
-  if (classList.size() && (classList.find(classId) != classList.end())) {
+  if (classList->size() && (classList->find(classId) != classList->end())) {
       cerr << "RegisterClass : Error, " << hex << classId << dec 
            << " already registered." << endl;
@@ -57,5 +65,5 @@
     }
   
-  classList[classId] = f;
+  (*classList)[classId] = f;
 }
 
@@ -64,6 +72,6 @@
 PIOPersist::FindCreatorFunc(uint_8 classId)
 {
-  ClassList::iterator i = classList.find(classId);
-  if (i == classList.end()) throw(NotFoundExc("PIOPersist::FindCreatorFunc"));
+  ClassList::iterator i = classList->find(classId);
+  if (i == classList->end()) throw(NotFoundExc("PIOPersist::FindCreatorFunc"));
   return (*i).second;
 }
Index: trunk/SophyaLib/BaseTools/ppersist.h
===================================================================
--- trunk/SophyaLib/BaseTools/ppersist.h	(revision 268)
+++ trunk/SophyaLib/BaseTools/ppersist.h	(revision 269)
@@ -25,6 +25,10 @@
 #endif
 
+// Classe de base pour les objets qui peuvent devenir PPersist
+
 namespace PlanckDPC {
   
+  class AnyDataObj;
+
   class PIOPersist;
   class PInPersist;
@@ -48,4 +52,7 @@
     void               Write(POutPersist&, string const& tag) const; 
     void               ReadAtTag(PInPersist& s, string const& tag);
+
+    virtual AnyDataObj* DataObj()       // Retourne l'objet reel $CHECK$ - Reza 
+                  { return(NULL); }     // Devrait etre virtuelle pure
   protected:  
     virtual void       ReadSelf(PInPersist&)=0;           
@@ -76,8 +83,10 @@
     static MD5_CTX ctx;
   
+    static void Initialize();   // Pour initialiser classList
   private:
 
     typedef map<uint_8, ClassCreatorFunc, less<uint_8> > ClassList;  
-    static ClassList             classList;
+    // Pas de createur appele pour objets statiques sur Linux - $CHECK$ Reza 26/04/99
+    static ClassList *           classList;  
 
   protected:
