Index: trunk/SophyaLib/BaseTools/ppersist.h
===================================================================
--- trunk/SophyaLib/BaseTools/ppersist.h	(revision 1202)
+++ trunk/SophyaLib/BaseTools/ppersist.h	(revision 2441)
@@ -17,4 +17,5 @@
 #include <time.h>
 
+#include <complex>
 #include <string>
 #include <map>
@@ -93,4 +94,5 @@
     static void Initialize();   // Pour initialiser classList
 
+    int    Version() {return version;}  // PIn/OutPersist version number
     string FileName() { return filename; }   // Retourne le nom de fichier
 
@@ -109,8 +111,10 @@
 	  PPS_OBJECT = 2,           // classId, data...
 	  PPS_REFERENCE = 3,        // objectId
-          PPS_TAG = 4,              // tag entries
+          PPS_NAMETAG_TABLE = 4,    // Name tag table (Written at the end of file/stream) 
 	  PPS_EOF = 5,              // Just before tag infomation, offset to PPS_TAG
 	  PPS_ENDOBJECT = 6,        // marks the end of a given object information
-          PPS_TAG_MARK = 7,         // To have a name tag, position marker in a file
+          PPS_NAMETAG_MARK = 7,     // To have a name tag, position marker in a file
+          PPS_POSTAG_MARK = 8,      // Position tag mark + 8 bytes (=stream position)
+          PPS_POSTAG_TABLE = 40,    // Position tag table + 8 bytes (=stream position)
           PPS_SIMPLE = 16,          // 16 + number of bytes, up to 8 bytes
           PPS_SIMPLE_ARRAY4 = 32,   // 32 + number of bytes, up to 8 bytes, then 4 bytes of length
@@ -120,4 +124,5 @@
    enum  {PPS_DATATYPE_CHAR = 0,        // 0  : DataType=character
           PPS_DATATYPE_FLOAT = 64,      // 64 : DataType=float 
+          PPS_DATATYPE_COMPLEX = 65,    // 65 : DataType=complex 
           PPS_DATATYPE_INTEGER = 128,   // 128 :DataType=integer 
           PPS_DATATYPE_UNSIGNED = 192   // 192 :DataType=Unsigned integer 
@@ -126,8 +131,9 @@
     map<string, int_8> tags;
     string filename;
+    int version;     // PPersist(In/Out) version 
   };
 
 
-  // TBD : use hash tables instead of maps. Check hashtbl status in STL.
+// TBD : use hash tables instead of maps. Check hashtbl status in STL.
 
 //! Input stream for PPersit objects.
@@ -137,5 +143,8 @@
     ~PInPersist();
 
-    bool   GotoTag(string const& name);
+    // Gestion des tags
+    bool   GotoPositionTag(int_8 pos);
+    bool   GotoNameTag(string const& name);
+    inline bool   GotoTag(string const& name) { return GotoNameTag(name); }
     int    NbTags();
     bool   GotoTagNum(int itag);  // 0..NbTags-1
@@ -144,4 +153,6 @@
     vector<string> const &  GetTagNames();  
 
+    // Lecture donnees de base et tableaux de donnees de base
+    // Basic data type (and corresponding arrays) reading
     void   GetByte (char& c);
     void   GetBytes(void* ptr, size_t bytes);
@@ -150,4 +161,8 @@
     void   GetR8   (r_8&);
     void   GetR8s  (r_8*, size_t);
+    void   GetI1   (int_1&);
+    void   GetI1s  (int_1*, size_t);
+    void   GetU1   (uint_1&);
+    void   GetU1s  (uint_1*, size_t);
     void   GetI2   (int_2&);
     void   GetI2s  (int_2*, size_t);
@@ -164,24 +179,41 @@
     void   GetLine (char* ptr, size_t len);
     void   GetStr  (string&);
-
-    void   Get(char&   c) {GetByte(c);}
-    void   Get(r_4&    x) {GetR4(x);}
-    void   Get(r_8&    x) {GetR8(x);}
-    void   Get(uint_2& x) {GetU2(x);}
-    void   Get(int_2&  x) {GetI2(x);}
-    void   Get(uint_4& x) {GetU4(x);}
-    void   Get(int_4&  x) {GetI4(x);}
-    void   Get(uint_8& x) {GetU8(x);}
-    void   Get(int_8&  x) {GetI8(x);}
-    void   Get(r_4*    x, size_t n) {GetR4s(x,n);}
-    void   Get(r_8*    x, size_t n) {GetR8s(x,n);}
-    void   Get(uint_2* x, size_t n) {GetU2s(x,n);}
-    void   Get(int_2*  x, size_t n) {GetI2s(x,n);}
-    void   Get(uint_4* x, size_t n) {GetU4s(x,n);}
-    void   Get(int_4*  x, size_t n) {GetI4s(x,n);}
-    void   Get(uint_8* x, size_t n) {GetU8s(x,n);}
-    void   Get(int_8*  x, size_t n) {GetI8s(x,n);}
-    void   Get(string& x) {GetStr(x);}
-  
+    void   GetZ4   (complex<r_4> &);
+    void   GetZ4s  (complex<r_4> *, size_t);
+    void   GetZ8   (complex<r_8> &);
+    void   GetZ8s  (complex<r_8> *, size_t);
+
+    inline void   Get(char&   c) {GetByte(c);}
+    inline void   Get(r_4&    x) {GetR4(x);}
+    inline void   Get(r_8&    x) {GetR8(x);}
+    inline void   Get(uint_1& x) {GetU1(x);}
+    inline void   Get(int_1&  x) {GetI1(x);}
+    inline void   Get(uint_2& x) {GetU2(x);}
+    inline void   Get(int_2&  x) {GetI2(x);}
+    inline void   Get(uint_4& x) {GetU4(x);}
+    inline void   Get(int_4&  x) {GetI4(x);}
+    inline void   Get(uint_8& x) {GetU8(x);}
+    inline void   Get(int_8&  x) {GetI8(x);}
+    inline void   Get(complex<r_4> & x) {GetZ4(x);}
+    inline void   Get(complex<r_8> & x) {GetZ8(x);}
+
+    inline void   Get(r_4*    x, size_t n) {GetR4s(x,n);}
+    inline void   Get(r_8*    x, size_t n) {GetR8s(x,n);}
+    inline void   Get(uint_1* x, size_t n) {GetU1s(x,n);}
+    inline void   Get(int_1*  x, size_t n) {GetI1s(x,n);}
+    inline void   Get(uint_2* x, size_t n) {GetU2s(x,n);}
+    inline void   Get(int_2*  x, size_t n) {GetI2s(x,n);}
+    inline void   Get(uint_4* x, size_t n) {GetU4s(x,n);}
+    inline void   Get(int_4*  x, size_t n) {GetI4s(x,n);}
+    inline void   Get(uint_8* x, size_t n) {GetU8s(x,n);}
+    inline void   Get(int_8*  x, size_t n) {GetI8s(x,n);}
+    inline void   Get(string& x) {GetStr(x);}
+    inline void   Get(complex<r_4> * x, size_t n) { GetZ4s(x, n); }
+    inline void   Get(complex<r_8> * x, size_t n) { GetZ8s(x, n); }
+
+    // Reading a list (table) of position tags
+    void    GetPosTagTable(int_8*, size_t);
+    void    GetPosTagTable(vector<int_8>&);
+
     //   Object Reading 
     PPersist*  ReadObject();
@@ -190,5 +222,4 @@
     PPersist*  GetPPObject(AnyDataObj * po=NULL);
 
-    int    Version() {return version;}
     time_t CreationDate() { return creationdate; }
     string CreationDateStr(); 
@@ -219,5 +250,4 @@
 
     bool bigEndian;
-    int version;
 
     time_t creationdate;
@@ -237,5 +267,8 @@
     ~POutPersist();
 
-    void WriteTag(string const& name);
+    // Ecriture de tags
+    int_8 WritePositionTag();
+    void  WriteNameTag(string const& name);
+    inline void WriteTag(string const& name) { WriteNameTag(name); }
   
     void PutByte (char c);
@@ -245,4 +278,8 @@
     void PutR8   (r_8);
     void PutR8s  (r_8 const*, size_t);
+    void PutI1   (int_1);
+    void PutI1s  (int_1 const*, size_t);
+    void PutU1   (uint_1);
+    void PutU1s  (uint_1 const*, size_t);
     void PutI2   (int_2);
     void PutI2s  (int_2 const*, size_t);
@@ -259,12 +296,17 @@
     void PutLine (char const* ptr, size_t len=0); // deprecated ?
     void PutStr  (string const&);
-    void PutPPObject (PPersist const*); // Like doing Write(stream) on PPersist object
-
-    void PutObject(AnyDataObj & o);   // Creates the corresponding PPersist Object and call Write()
-    void PutObject(AnyDataObj & o, string tagname);
+    void PutZ4   (complex<r_4>);
+    void PutZ4s  (complex<r_4> const*, size_t);
+    void PutZ8   (complex<r_8>);
+    void PutZ8s  (complex<r_8> const*, size_t);
+
 
     void   Put(char   c) {PutByte(c);}
     void   Put(r_4    x) {PutR4(x);}
     void   Put(r_8    x) {PutR8(x);}
+    void   Put(complex<r_4>   x) {PutZ4(x);}
+    void   Put(complex<r_8>   x) {PutZ8(x);}
+    void   Put(uint_1 x) {PutU1(x);}
+    void   Put(int_1  x) {PutI1(x);}
     void   Put(uint_2 x) {PutU2(x);}
     void   Put(int_2  x) {PutI2(x);}
@@ -275,4 +317,8 @@
     void   Put(r_4 const*    x, size_t n) {PutR4s(x,n);}
     void   Put(r_8 const*    x, size_t n) {PutR8s(x,n);}
+    void   Put(complex<r_4> const*    x, size_t n) {PutZ4s(x,n);}
+    void   Put(complex<r_8> const*    x, size_t n) {PutZ8s(x,n);}
+    void   Put(uint_1 const* x, size_t n) {PutU1s(x,n);}
+    void   Put(int_1 const*  x, size_t n) {PutI1s(x,n);}
     void   Put(uint_2 const* x, size_t n) {PutU2s(x,n);}
     void   Put(int_2 const*  x, size_t n) {PutI2s(x,n);}
@@ -283,4 +329,14 @@
     void   Put(string const& s) {PutStr(s);}
     void   Put(PPersist const* x) {PutPPObject(x);}
+
+    // Writing a list of position tag table
+    void   PutPosTagTable(int_8 const *, size_t);
+    void   PutPosTagTable(vector<int_8> const&);
+
+    // Objet Write - Ecriture des objets
+    void PutPPObject (PPersist const*); // Like doing Write(stream) on PPersist object
+
+    void PutObject(AnyDataObj & o);   // Creates the corresponding PPersist Object and call Write()
+    void PutObject(AnyDataObj & o, string tagname);
 
 
@@ -310,5 +366,7 @@
   };
   
-  
+
+// Le macro suivant permettent de simplifier la declaration 
+// des operateurs >> << sur les POutPersist et  PInPersist
 #define RAWPERSISTIO(_Type_,_xtyp_)                                             \
   inline POutPersist& operator << (POutPersist& c, _Type_ const& data)            \
@@ -324,4 +382,6 @@
   }                                                                               
 
+// On utilise le macro RAWPERSISTIO pour declarer POutPersist << et PInPersist >> 
+// pour les types de base r_4 r_8 int_4 int_8 ...
   RAWPERSISTIO(int_4,I4);
   RAWPERSISTIO(uint_4,U4);
@@ -331,4 +391,7 @@
   RAWPERSISTIO(r_4,R4);
   RAWPERSISTIO(r_8,R8);
+  RAWPERSISTIO(complex<r_4>,Z4);
+  RAWPERSISTIO(complex<r_8>,Z8);
+  RAWPERSISTIO(string,Str);
   
 #if 0
