Index: /trunk/SophyaLib/BaseTools/ppersist.cc
===================================================================
--- /trunk/SophyaLib/BaseTools/ppersist.cc	(revision 587)
+++ /trunk/SophyaLib/BaseTools/ppersist.cc	(revision 588)
@@ -36,4 +36,5 @@
 MD5_CTX PIOPersist::ctx;
 PIOPersist::ClassList * PIOPersist::classList = NULL;   // $CHECK$ Reza 26/04/99
+map<string, uint_8> * PIOPersist::typeids = NULL;
 
 //++
@@ -44,9 +45,10 @@
 {
 classList = new PIOPersist::ClassList;
-}
-
-//++
-void
-PIOPersist::RegisterClass(uint_8 classId, ClassCreatorFunc f)
+typeids = new map<string, uint_8>;
+}
+
+//++
+void
+PIOPersist::RegisterClass(uint_8 classId, string typname, ClassCreatorFunc f)
 //
 //	Register a new persistant class.
@@ -64,4 +66,5 @@
   
   (*classList)[classId] = f;
+  (*typeids)[typname]  = classId;
 }
 
@@ -154,5 +157,5 @@
   // Check tag value
   char ppstype;
-  s.GetRawByte(ppstype);
+  s.GetTypeTag(ppstype);
   if (ppstype != PInPersist::PPS_OBJECT) {
     throw FileFormatExc("PPersist::Read : not an object in flow");
@@ -162,5 +165,6 @@
   uint_8 classId;
   s.GetRawU8(classId);
-  if (classId != PIOPersist::Hash(typeid(*this).name())) {
+  uint_8 myClassId = PIOPersist::getTypeId(typeid(*this).name());
+  if (classId != myClassId) {
     throw FileFormatExc("PPersist::Read : not the same object type");
   }
@@ -274,5 +278,5 @@
   // Find tag entries at end of file
   s->seekg(-(sizeof(int_8)+1), ios::end);
-  GetRawByte(ppstype);
+  GetTypeTag(ppstype);
   if (ppstype != PPS_EOF)
     throw FileFormatExc("PInPersist::Scan   corrupted file, no eof entry at end of file");
@@ -288,5 +292,5 @@
   s->seekg(pos);
   while (true) {
-    GetRawByte(ppstype);
+    GetTypeTag(ppstype);
     if (ppstype == PPS_EOF) break;
     
@@ -322,4 +326,5 @@
       //    throw NotFoundExc("PInPersist::GotoTag   tag not found");
   s->seekg((*i).second);
+  objList.clear(); // $CHECK$ EA 171199
   return(true); 
 }
@@ -332,4 +337,5 @@
   for (int j=0; j<itag; j++) i++;
   s->seekg((*i).second);
+  objList.clear(); // $CHECK$ EA 171199
   return(true);
 }
@@ -410,4 +416,14 @@
 }
 
+void
+PInPersist::GetTypeTag(char& c) 
+{
+  GetRawByte(c);
+  while (c == PPS_TAG_MARK) {
+    objList.clear();
+    GetRawByte(c);
+  }
+}
+
 
 void
@@ -459,5 +475,5 @@
 {
   char ppstype;
-  GetRawByte(ppstype);
+  GetTypeTag(ppstype);
   if (ppstype != PPS_SIMPLE + datasz)
     throw FileFormatExc("PInPersist::CheckTag   bad type in ppersist file");
@@ -468,5 +484,5 @@
 {
   char ppstype;
-  GetRawByte(ppstype);
+  GetTypeTag(ppstype);
   size_t filesz;
   if (sz <= 0x7fff) {
@@ -686,5 +702,5 @@
 {
   char ppstype;
-  GetRawByte(ppstype);
+  GetTypeTag(ppstype);
   if (ppstype != PPS_LINE) 
     throw FileFormatExc("PInPersist::GetLine   bad type in ppersist file");
@@ -696,5 +712,5 @@
 {
   char ppstype;
-  GetRawByte(ppstype);
+  GetTypeTag(ppstype);
   if (ppstype != PPS_STRING) 
     throw FileFormatExc("PInPersist::GetLine   bad type in ppersist file");
@@ -713,5 +729,5 @@
   // Get tag
   char ppstype;
-  GetRawByte(ppstype);
+  GetTypeTag(ppstype);
   if (ppstype != PPS_OBJECT && ppstype != PPS_REFERENCE && ppstype != PPS_NULL) {
     throw FileFormatExc("PInPersist::ReadObject : not an object in flow");
@@ -741,5 +757,7 @@
     GetRawI4(id);
     if (id <0 || id>=objList.size()) {
-      throw FileFormatExc("PInPersist::ReadObject    invalid object id for reference");
+      char msg[200];
+      sprintf(msg, "PInPersist::ReadObject    invalid object id for reference: %d/%d",id,objList.size());
+      throw FileFormatExc(msg);
     }
     return objList[id];
@@ -843,4 +861,6 @@
 
   tags[name] = tagPos;
+  PutRawByte(PPS_TAG_MARK);                       // This is a tag
+  objList.clear(); // $CHECK$ EA 171199
 }
 
@@ -1193,5 +1213,6 @@
 
   PutRawByte(PPS_OBJECT);
-  PutRawU8(PIOPersist::Hash(typeid(*obj).name()));
+  PutRawU8(getTypeId(typeid(*obj).name()));
+  //PutRawU8(PIOPersist::Hash(typeid(*obj).name()));
   assignObjectId(obj);
   obj->WriteSelf(*this);
Index: /trunk/SophyaLib/BaseTools/ppersist.h
===================================================================
--- /trunk/SophyaLib/BaseTools/ppersist.h	(revision 587)
+++ /trunk/SophyaLib/BaseTools/ppersist.h	(revision 588)
@@ -69,5 +69,5 @@
     typedef PPersist*            (*ClassCreatorFunc)();
   
-    static void                  RegisterClass(uint_8 classId, ClassCreatorFunc f);
+    static void                  RegisterClass(uint_8 classId, string typname, ClassCreatorFunc f);
     static ClassCreatorFunc      FindCreatorFunc(uint_8 classId);
     static uint_8 Hash(string const& typname) {
@@ -80,4 +80,5 @@
   
     static void Initialize();   // Pour initialiser classList
+    static uint_8 getTypeId(string s) {return (*typeids)[s];}
   private:
 
@@ -85,6 +86,8 @@
     // Pas de createur appele pour objets statiques sur Linux - $CHECK$ Reza 26/04/99
     static ClassList *           classList;  
+    static map<string, uint_8> * typeids;
 
   protected:
+
     enum {PPS_NULL = 0,             // this is a null object
 	  PPS_STRING = 1,           // string, length (2b) + data
@@ -94,4 +97,5 @@
 	  PPS_EOF = 5,              // Just before tag infomation, offset to PPS_TAG
 	  PPS_LINE = 6,             // '\n'-terminated, deprecated ?
+          PPS_TAG_MARK = 7,         // to reset object count when skipped
           PPS_SIMPLE = 16,          // 16 + number of bytes, up to 8 bytes
           PPS_SIMPLE_ARRAY = 32,    // 32 + number of bytes, up to 8 bytes, then 2 bytes of length
@@ -166,4 +170,5 @@
     void   CheckTag   (short datasz);
     void   CheckArrayTag(short datasz, size_t sz);
+    void   GetTypeTag (char& c);
     void   GetRawByte (char& c);
     void   GetRawBytes(void* ptr, size_t bytes);
@@ -319,5 +324,5 @@
     public:
       static PPersist* Create() {return new T();}
-      static void Register(string id) {PIOPersist::RegisterClass(Hash(id),Create);}
+      static void Register(string id) {PIOPersist::RegisterClass(Hash(id),typeid(T).name(),Create);}
       static uint_8 Hash(string id) {
 	return PIOPersist::Hash(id);
