Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[Manta] r1725 - in branches/persistent: . Core Core/Color Core/Geometry Core/Persistent Core/Reflection Engine/Factory Interface Model/AmbientLights Model/Backgrounds Model/Groups Model/Lights Model/Materials Model/Primitives Model/TexCoordMappers Model/Textures StandAlone


Chronological Thread 
  • From: sparker@sci.utah.edu
  • To: manta@sci.utah.edu
  • Subject: [Manta] r1725 - in branches/persistent: . Core Core/Color Core/Geometry Core/Persistent Core/Reflection Engine/Factory Interface Model/AmbientLights Model/Backgrounds Model/Groups Model/Lights Model/Materials Model/Primitives Model/TexCoordMappers Model/Textures StandAlone
  • Date: Mon, 17 Sep 2007 15:30:58 -0600 (MDT)

Author: sparker
Date: Mon Sep 17 15:30:53 2007
New Revision: 1725

Added:
   branches/persistent/Core/Persistent/
      - copied from r1701, branches/persistent/Core/Reflection/
   branches/persistent/Core/Persistent/ArchiveElement.cc
   branches/persistent/Core/Persistent/ArchiveElement.h
Removed:
   branches/persistent/Core/Reflection/
Modified:
   branches/persistent/Core/CMakeLists.txt
   branches/persistent/Core/Color/ColorSpace.h
   branches/persistent/Core/Color/RGBTraits.cc
   branches/persistent/Core/Color/RGBTraits.h
   branches/persistent/Core/Geometry/Vector.cc
   branches/persistent/Core/Geometry/Vector.h
   branches/persistent/Core/Persistent/Archive.cc
   branches/persistent/Core/Persistent/Archive.h
   branches/persistent/Core/Persistent/ClassInfo.h
   branches/persistent/Core/Persistent/XMLArchive.cc
   branches/persistent/Core/Persistent/XMLArchive.h
   branches/persistent/Core/Persistent/stdClassInfo.h
   branches/persistent/Engine/Factory/Factory.cc
   branches/persistent/Interface/Camera.cc
   branches/persistent/Interface/Camera.h
   branches/persistent/Interface/InterfaceClassInfo.h
   branches/persistent/Interface/LightSet.cc
   branches/persistent/Interface/LightSet.h
   branches/persistent/Interface/RenderParameters.cc
   branches/persistent/Interface/RenderParameters.h
   branches/persistent/Interface/Scene.cc
   branches/persistent/Interface/Scene.h
   branches/persistent/Interface/TexCoordMapper.h
   branches/persistent/Model/AmbientLights/ArcAmbient.cc
   branches/persistent/Model/AmbientLights/ArcAmbient.h
   branches/persistent/Model/Backgrounds/LinearBackground.cc
   branches/persistent/Model/Backgrounds/LinearBackground.h
   branches/persistent/Model/Groups/Group.cc
   branches/persistent/Model/Groups/Group.h
   branches/persistent/Model/Lights/PointLight.cc
   branches/persistent/Model/Lights/PointLight.h
   branches/persistent/Model/Materials/Lambertian.cc
   branches/persistent/Model/Materials/Lambertian.h
   branches/persistent/Model/Materials/LitMaterial.cc
   branches/persistent/Model/Materials/LitMaterial.h
   branches/persistent/Model/Materials/MetalMaterial.cc
   branches/persistent/Model/Materials/MetalMaterial.h
   branches/persistent/Model/Materials/OpaqueShadower.h
   branches/persistent/Model/Primitives/Parallelogram.cc
   branches/persistent/Model/Primitives/Parallelogram.h
   branches/persistent/Model/Primitives/PrimitiveCommon.cc
   branches/persistent/Model/Primitives/PrimitiveCommon.h
   branches/persistent/Model/Primitives/Sphere.cc
   branches/persistent/Model/Primitives/Sphere.h
   branches/persistent/Model/TexCoordMappers/UniformMapper.cc
   branches/persistent/Model/TexCoordMappers/UniformMapper.h
   branches/persistent/Model/Textures/CheckerTexture.h
   branches/persistent/Model/Textures/Constant.h
   branches/persistent/StandAlone/savescene.cc
   branches/persistent/TODO
Log:
Major refactoring of persistent object capability to simplify interface and 
implement writing


Modified: branches/persistent/Core/CMakeLists.txt
==============================================================================
--- branches/persistent/Core/CMakeLists.txt     (original)
+++ branches/persistent/Core/CMakeLists.txt     Mon Sep 17 15:30:53 2007
@@ -58,15 +58,17 @@
      Math/SSEDefs.cc
      )
 SET (CORE_SOURCES ${CORE_SOURCES}
-     Reflection/Archive.h
-     Reflection/Archive.cc
-     Reflection/ClassInfo.h
+     Persistent/Archive.h
+     Persistent/Archive.cc
+     Persistent/ArchiveElement.h
+     Persistent/ArchiveElement.cc
+     Persistent/ClassInfo.h
      )
 
 IF (LIBXML2_INCLUDE)
      SET (CORE_SOURCES ${CORE_SOURCES}
-          Reflection/XMLArchive.h
-          Reflection/XMLArchive.cc
+          Persistent/XMLArchive.h
+          Persistent/XMLArchive.cc
          )
      INCLUDE_DIRECTORIES(${LIBXML2_INCLUDE})
 ENDIF (LIBXML2_INCLUDE)

Modified: branches/persistent/Core/Color/ColorSpace.h
==============================================================================
--- branches/persistent/Core/Color/ColorSpace.h (original)
+++ branches/persistent/Core/Color/ColorSpace.h Mon Sep 17 15:30:53 2007
@@ -7,8 +7,8 @@
 #include <Core/Color/RGBColor.h>
 #include <Core/Color/RGBTraits.h>
 #include <Core/Math/Expon.h>
-#include <Core/Reflection/Archive.h>
-#include <Core/Reflection/ClassInfo.h>
+#include <Core/Persistent/ArchiveElement.h>
+#include <Core/Persistent/ClassInfo.h>
 
 #include <sgi_stl_warnings_off.h>
 #include <string>
@@ -249,7 +249,7 @@
     ComponentType data[NumComponents];
 #endif
 
-    void readwrite(Archive*);
+    void readwrite(ArchiveElement*);
 
   protected:
     // DO NOT MAKE THIS PUBLIC!
@@ -275,13 +275,16 @@
     static std::string getPublicClassname() {
       return "Color";
     }
-    static void readwrite(Archive* archive, ColorSpace<Traits>& data) {
+    static void readwrite(ArchiveElement* archive, ColorSpace<Traits>& data) 
{
       if(archive->reading()){
         // Read a number of different color representations
         NOT_FINISHED("ColorSpace::readwrite");
       } else {
         Traits::readwrite(archive, data.data);
       }
+    }
+    static Persistent::StorageHint storageHint() {
+      return Persistent::LightweightObject;
     }
     static bool force_initialize;
   };

Modified: branches/persistent/Core/Color/RGBTraits.cc
==============================================================================
--- branches/persistent/Core/Color/RGBTraits.cc (original)
+++ branches/persistent/Core/Color/RGBTraits.cc Mon Sep 17 15:30:53 2007
@@ -1,13 +1,13 @@
 
 #include <Core/Color/RGBTraits.h>
-#include <Core/Reflection/Archive.h>
+#include <Core/Persistent/ArchiveElement.h>
 #include <sstream>
 #include <iomanip>
 
 using namespace Manta;
 using namespace std;
 
-void RGBTraits::readwrite(Archive* archive, ComponentType data[3])
+void RGBTraits::readwrite(ArchiveElement* archive, ComponentType data[3])
 {
   // Only used for writing...
 
@@ -33,6 +33,6 @@
     rep << "rgb: " << data[0] << " " << data[1] << " " << data[2];
   }
   string repstring = rep.str();
-  archive->readwrite(0, repstring);
+  archive->readwrite("rgb", repstring);
 }
 

Modified: branches/persistent/Core/Color/RGBTraits.h
==============================================================================
--- branches/persistent/Core/Color/RGBTraits.h  (original)
+++ branches/persistent/Core/Color/RGBTraits.h  Mon Sep 17 15:30:53 2007
@@ -4,9 +4,10 @@
 
 #include <Core/Color/RGBColor.h>
 #include <Core/Color/Conversion.h>
+#include <Core/Persistent/ClassInfo.h>
 
 namespace Manta {
-  class Archive;
+  class ArchiveElement;
   class RGBTraits {
   public:
     typedef float ComponentType;
@@ -41,7 +42,8 @@
       return data[0] * ComponentType(0.3) + data[1] * ComponentType(0.59) + 
data[2] * ComponentType(0.11);
     }
 
-    static void readwrite(Archive* archive, ComponentType data[3]);
+    static void readwrite(ArchiveElement* archive, ComponentType data[3]);
+
   };
 }
 

Modified: branches/persistent/Core/Geometry/Vector.cc
==============================================================================
--- branches/persistent/Core/Geometry/Vector.cc (original)
+++ branches/persistent/Core/Geometry/Vector.cc Mon Sep 17 15:30:53 2007
@@ -28,7 +28,7 @@
 */
 
 #include <Core/Geometry/Vector.h>
-#include <Core/Reflection/Archive.h>
+#include <Core/Persistent/ArchiveElement.h>
 
 #include <sgi_stl_warnings_off.h>
 #include <iostream>
@@ -54,8 +54,8 @@
 
 REGISTER_CLASS(Vector);
 
-void Vector::readwrite(Archive* archive)
+void Vector::readwrite(ArchiveElement* archive)
 {
-  archive->readwrite(0, data, 3);
+  archive->readwrite("data", data, 3);
 }
 

Modified: branches/persistent/Core/Geometry/Vector.h
==============================================================================
--- branches/persistent/Core/Geometry/Vector.h  (original)
+++ branches/persistent/Core/Geometry/Vector.h  Mon Sep 17 15:30:53 2007
@@ -42,7 +42,7 @@
 #include <Core/Math/Expon.h>
 #include <Core/Math/MinMax.h>
 #include <Core/Math/MiscMath.h>
-#include <Core/Reflection/ClassInfo.h>
+#include <Core/Persistent/ClassInfo.h>
 
 #include <sgi_stl_warnings_off.h>
 #include <iosfwd>
@@ -462,7 +462,7 @@
     friend Vector Interpolate(const Vector& v1, const Vector& v2, const 
Vector& weight);
 #endif
     
-    void readwrite(Archive*);
+    void readwrite(ArchiveElement*);
     //private:
     Real data[3];
 
@@ -559,7 +559,7 @@
   std::ostream& operator<< (std::ostream& os, const Vector& v);
   std::istream& operator>> (std::istream& is,       Vector& v);
 
-  DECLARE_CLASSINFO_BASECLASS(Vector, ConcreteClass, readwriteMethod);  
+  DECLARE_CLASSINFO_BASECLASS(Vector, ConcreteClass, 
readwriteMethod_lightweight);
 }
 
 namespace SCIRun {

Modified: branches/persistent/Core/Persistent/Archive.cc
==============================================================================
--- branches/persistent/Core/Reflection/Archive.cc      (original)
+++ branches/persistent/Core/Persistent/Archive.cc      Mon Sep 17 15:30:53 
2007
@@ -1,5 +1,5 @@
 
-#include <Core/Reflection/Archive.h>
+#include <Core/Persistent/Archive.h>
 #include <Core/Exceptions/InputError.h>
 #include <Core/Exceptions/OutputError.h>
 #include <Core/Exceptions/InternalError.h>

Modified: branches/persistent/Core/Persistent/Archive.h
==============================================================================
--- branches/persistent/Core/Reflection/Archive.h       (original)
+++ branches/persistent/Core/Persistent/Archive.h       Mon Sep 17 15:30:53 
2007
@@ -2,31 +2,12 @@
 #ifndef Manta_Archive_h
 #define Manta_Archive_h
 
-#include <Core/Reflection/ClassInfo.h>
-#include <Core/Exceptions/SerializationError.h>
-#include <Core/Util/NotFinished.h>
-#include <iostream>
-#include <map>
 #include <string>
-#include <typeinfo>
 
 namespace Manta {
+  class ArchiveElement;
   class Archive {
   public:
-    template<class T>
-      void readwrite(const char* fieldname, T& data);
-    template<class T>
-      void readwrite(const char* fieldname, T*& data);
-    template<class T>
-      void readwrite(const char* fieldname, const T*& data);
-
-    virtual void readwrite(const char* fieldname, bool& data) = 0;
-    virtual void readwrite(const char* fieldname, double& data) = 0;
-    virtual void readwrite(const char* fieldname, float& data) = 0;
-    virtual void readwrite(const char* fieldname, float* data, int 
numElements) = 0;
-    virtual void readwrite(const char* fieldname, int& data) = 0;
-    virtual void readwrite(const char* fieldname, std::string& data) = 0;
-
     bool reading() const {
       return isreading;
     }
@@ -35,122 +16,17 @@
     }
     static Archive* openForReading(const std::string& filename);
     static Archive* openForWriting(const std::string& filename);
-    virtual std::string getClassname() const = 0;
-
-    virtual Archive* findField(const std::string& fieldname) const = 0;
-    virtual Archive* createClass(const std::string& classname) = 0;
-    virtual Archive* createField(const std::string& fieldname) = 0;
-    virtual Archive* createFieldForClass(const std::string& fieldname, const 
std::string& classname) = 0;
-    //virtual Archive* addSequence(const std::string& sequencename);
-    virtual bool isNullPointer() const = 0;
-    virtual void writeNullPointer(const std::string& fieldname) = 0;
-
-    virtual bool haveReference(void* ptr, std::string& refname) = 0;
-    virtual void saveReference(void* ptr, const std::string& classname) = 0;
-    virtual void writeObjectReference(const std::string& fieldname,
-                                      const std::string& classname,
-                                      const std::string& refname) = 0;
 
+    virtual ArchiveElement* getRoot() = 0;
     virtual ~Archive();
   protected:
-    static bool registerArchiveType(const std::string& name, Archive* 
(*readopener)(const std::string&), Archive* (*writeopener)(const 
std::string&));
+    static bool registerArchiveType(const std::string& name,
+                                    Archive* (*readopener)(const 
std::string&),
+                                    Archive* (*writeopener)(const 
std::string&));
     Archive(bool isreading);
     bool isreading;
   private:
-
   };
-
-  template<class T>
-  void Archive::readwrite(const char* fieldname, T& data)
-  {
-    if(writing() && typeid(T) != typeid(data))
-      throw SerializationError("Cannot serialize reference to derived 
class");
-
-    Archive* subArchive;
-    if(reading()){
-      subArchive = findField(fieldname);
-      if(!subArchive)
-        throw SerializationError("Cannot find field: " + 
std::string(fieldname));
-    } else {
-      subArchive = createField(fieldname);
-    }
-    ClassInfo<T>::readwrite(subArchive, data);
-    delete subArchive;
-  }
-
-
-  template<class T>
-  void Archive::readwrite(const char* fieldname, T*& data) {
-    if(reading()){
-      Archive* subArchive = fieldname?findField(fieldname):this;
-      if(!subArchive)
-        throw SerializationError("Cannot find field: " + 
std::string(fieldname) + " while reading class: " + typeid(T).name());
-      if(subArchive->isNullPointer()){
-        data = 0;
-      } else {
-        std::string classname = subArchive->getClassname();
-        typename ClassDatabase<T>::Entry* dbentry = 
ClassDatabase<T>::getEntry(classname);
-        if(!dbentry)
-          throw SerializationError("Cannot create class: " + classname + " 
due to missing ClassInfo");
-        data = dbentry->createInstance();
-        dbentry->readwrite(subArchive, data);
-      }
-      if(fieldname)
-        delete subArchive;
-    } else {
-      // Writing
-      if(!data){
-        writeNullPointer(fieldname?fieldname:"");
-        return;
-      }
-      if(typeid(T) == typeid(*data)){
-        std::string classname = ClassInfo<T>::getPublicClassname();
-        // Check to see if this pointer has already been emitted.
-        std::string refname;
-        if(haveReference(static_cast<void*>(data), refname)){
-          writeObjectReference(fieldname?fieldname:"", classname, refname);
-        } else {
-          Archive* subArchive = fieldname?createFieldForClass(fieldname, 
classname):createClass(classname);
-          subArchive->saveReference(static_cast<void*>(data), classname);
-          ClassInfo<T>::readwrite(subArchive, *data);
-          delete subArchive;
-        }
-      } else {
-        typename ClassDatabase<T>::Entry* dbentry = 
ClassDatabase<T>::getEntry(typeid(*data));;
-        if(!dbentry){
-          std::string classname = typeid(*data).name();
-          throw SerializationError("Cannot locate serializer for class: " + 
classname + " due to missing ClassInfo");
-        }
-        // Check to see if this pointer has already been emitted.
-        // To avoid issues with pointer uniqueness under multiple
-        // inheritance, we always convert it to void the the most
-        // derived class using the class database
-        std::string classname = dbentry->getPublicClassname();
-        void* ptrvalue = dbentry->getPointerValue(data);
-        std::string refname;
-        if(haveReference(static_cast<void*>(ptrvalue), refname)){
-          writeObjectReference(fieldname?fieldname:"", classname, refname);
-        } else {
-          Archive* subArchive = fieldname?createFieldForClass(fieldname, 
classname):createClass(classname);
-          subArchive->saveReference(static_cast<void*>(data), classname);
-          dbentry->readwrite(subArchive, data);
-          delete subArchive;
-        }
-      }
-    }
-  }
-
-  template<class T>
-  void Archive::readwrite(const char* fieldname, const T*& data) {
-    if(reading()){
-      T* tmpdata;
-      readwrite(fieldname, tmpdata);
-      data = tmpdata;
-    } else {
-      T* tmpdata = const_cast<T*>(data);
-      readwrite(fieldname, tmpdata);
-    }
-  }
 
 }//namespace
 

Added: branches/persistent/Core/Persistent/ArchiveElement.cc
==============================================================================
--- (empty file)
+++ branches/persistent/Core/Persistent/ArchiveElement.cc       Mon Sep 17 
15:30:53 2007
@@ -0,0 +1,20 @@
+
+#include <Core/Persistent/ArchiveElement.h>
+#include <Core/Exceptions/InputError.h>
+#include <Core/Exceptions/OutputError.h>
+#include <Core/Exceptions/InternalError.h>
+#include <string>
+
+using namespace Manta;
+using namespace std;
+using namespace SCIRun;
+
+ArchiveElement::ArchiveElement(bool isreading)
+  : isreading(isreading)
+{
+}
+
+ArchiveElement::~ArchiveElement()
+{
+}
+

Added: branches/persistent/Core/Persistent/ArchiveElement.h
==============================================================================
--- (empty file)
+++ branches/persistent/Core/Persistent/ArchiveElement.h        Mon Sep 17 
15:30:53 2007
@@ -0,0 +1,168 @@
+
+#ifndef Manta_ArchiveElement_h
+#define Manta_ArchiveElement_h
+
+#include <Core/Persistent/ClassInfo.h>
+#include <Core/Exceptions/SerializationError.h>
+#include <string>
+#include <typeinfo>
+
+namespace Manta {
+  class ArchiveElement {
+  public:
+    bool reading() const {
+      return isreading;
+    }
+    bool writing() const {
+      return !isreading;
+    }
+
+    template<class T>
+      void readwrite(const std::string& fieldname, T& data, 
Persistent::StorageHint hint = Persistent::Default);
+    template<class T>
+      void readwrite(const std::string& fieldname, T*& data, 
Persistent::StorageHint hint = Persistent::Default);
+    template<class T>
+      void readwrite(const std::string& fieldname, const T*& data, 
Persistent::StorageHint hint = Persistent::Default);
+
+    virtual void readwrite(const std::string& fieldname, bool& data,
+                           Persistent::StorageHint hint = 
Persistent::Default) = 0;
+    virtual void readwrite(const std::string& fieldname, double& data,
+                           Persistent::StorageHint hint = 
Persistent::Default) = 0;
+    virtual void readwrite(const std::string& fieldname, float& data,
+                           Persistent::StorageHint hint = 
Persistent::Default) = 0;
+    virtual void readwrite(const std::string& fieldname, float* data, int 
numElements,
+                           Persistent::StorageHint hint = 
Persistent::Default) = 0;
+    virtual void readwrite(const std::string& fieldname, int& data,
+                           Persistent::StorageHint hint = 
Persistent::Default) = 0;
+    virtual void readwrite(const std::string& fieldname, std::string& data,
+                           Persistent::StorageHint hint = 
Persistent::Default) = 0;
+
+  protected:
+    virtual ArchiveElement* findObject(const std::string& fieldname,
+                                       ClassDatabaseInterface* db,
+                                       std::string& classname,
+                                       Persistent::StorageHint classhint,
+                                       Persistent::StorageHint instancehint) 
= 0;
+    virtual ArchiveElement* createObject(const std::string& fieldname,
+                                         const std::string& classname,
+                                         Persistent::StorageHint classhint,
+                                         Persistent::StorageHint 
instancehint,
+                                         void* datakey) = 0;
+
+    virtual bool isNullPointer(const std::string& fieldname) const = 0;
+    virtual void writeNullPointer(const std::string& fieldname) = 0;
+
+    virtual bool haveReference(void* ptr, std::string& refname) = 0;
+    virtual void writeObjectReference(const std::string& fieldname,
+                                      const std::string& classname,
+                                      const std::string& refname) = 0;
+
+    virtual ~ArchiveElement();
+    ArchiveElement(bool isreading);
+    bool isreading;
+  private:
+
+  };
+
+  template<class T>
+  void ArchiveElement::readwrite(const std::string& fieldname, T& data, 
Persistent::StorageHint instancehint)
+  {
+    if(writing() && typeid(T) != typeid(data))
+      throw SerializationError("Cannot serialize reference to derived 
class");
+
+    if(reading()){
+      Persistent::StorageHint classhint = ClassInfo<T>::storageHint();
+      if(classhint == Persistent::Default)
+        classhint = Persistent::SimpleObject;
+      std::string classname;
+      ArchiveElement* subelement = findObject(fieldname,
+                                              
ClassDatabase<T>::getInterface(),
+                                              classname, classhint, 
instancehint);
+      if(!subelement)
+        throw SerializationError("Cannot find field: " + 
std::string(fieldname) + " of type " + typeid(T).name());
+
+      typename ClassDatabase<T>::Entry* dbentry = 
ClassDatabase<T>::getEntry(classname);
+      if(!dbentry)
+        throw SerializationError("Cannot create class: " + classname + " due 
to missing ClassInfo");
+      ClassInfo<T>::readwrite(subelement, data);
+      delete subelement;
+    } else {
+      // Writing
+      Persistent::StorageHint classhint = ClassInfo<T>::storageHint();
+      if(classhint == Persistent::Default)
+        classhint = Persistent::SimpleObject;
+      std::string classname = ClassInfo<T>::getPublicClassname();
+      ArchiveElement* subelement = createObject(fieldname, classname, 
classhint, instancehint, 0);
+      ClassInfo<T>::readwrite(subelement, data);
+      delete subelement;
+    }
+  }
+
+
+  template<class T>
+  void ArchiveElement::readwrite(const std::string& fieldname, T*& data, 
Persistent::StorageHint instancehint) {
+    if(reading()){
+      if(isNullPointer(fieldname)){
+        data = 0;
+      } else {
+        Persistent::StorageHint classhint = ClassInfo<T>::storageHint();
+        std::string classname;
+        ArchiveElement* subelement = findObject(fieldname,
+                                                
ClassDatabase<T>::getInterface(),
+                                                classname, classhint, 
instancehint);
+        if(!subelement)
+          throw SerializationError("Cannot find field: " + 
std::string(fieldname) + " of type " + typeid(T).name());
+
+        typename ClassDatabase<T>::Entry* dbentry = 
ClassDatabase<T>::getEntry(classname);
+        if(!dbentry)
+          throw SerializationError("Cannot create class: " + classname + " 
due to missing ClassInfo");
+        data = dbentry->createInstance();
+        dbentry->readwrite(subelement, data);
+        delete subelement;
+      }
+    } else {
+      // Writing
+      if(!data){
+        writeNullPointer(fieldname);
+      } else {
+        typename ClassDatabase<T>::Entry* dbentry = 
ClassDatabase<T>::getEntry(typeid(*data));;
+        if(!dbentry){
+          std::string classname = typeid(*data).name();
+          throw SerializationError("Cannot locate serializer for class: " + 
classname + " due to missing ClassInfo");
+        }
+        // Check to see if this pointer has already been emitted.
+        // To avoid issues with pointer uniqueness under multiple
+        // inheritance, we always convert it to void the the most
+        // derived class using the class database
+        std::string classname = dbentry->getPublicClassname();
+        void* ptrvalue = dbentry->getPointerValue(data);
+        std::string refname;
+        if(haveReference(static_cast<void*>(ptrvalue), refname)){
+          writeObjectReference(fieldname, classname, refname);
+        } else {
+          Persistent::StorageHint classhint = ClassInfo<T>::storageHint();
+          ArchiveElement* subelement = createObject(fieldname, classname, 
+                                                    classhint, instancehint,
+                                                    
static_cast<void*>(ptrvalue));
+          dbentry->readwrite(subelement, data);
+          delete subelement;
+        }
+      }
+    }
+  }
+
+  template<class T>
+    void ArchiveElement::readwrite(const std::string& fieldname, const T*& 
data, Persistent::StorageHint hint) {
+    if(reading()){
+      T* tmpdata;
+      readwrite(fieldname, tmpdata, hint);
+      data = tmpdata;
+    } else {
+      T* tmpdata = const_cast<T*>(data);
+      readwrite(fieldname, tmpdata, hint);
+    }
+  }
+
+}//namespace
+
+#endif

Modified: branches/persistent/Core/Persistent/ClassInfo.h
==============================================================================
--- branches/persistent/Core/Reflection/ClassInfo.h     (original)
+++ branches/persistent/Core/Persistent/ClassInfo.h     Mon Sep 17 15:30:53 
2007
@@ -10,7 +10,16 @@
 #include <typeinfo>
 
 namespace Manta {
-  class Archive;
+  class ArchiveElement;
+
+  class Persistent {
+  public:
+    enum StorageHint {
+      Default, ContainerObject, LightweightObject, AnonymousField, 
SimpleObject
+    };
+  private:
+    Persistent();
+  };
 
   // This class should always be specialized.  If you see an error
   // here, you need to define the specialization for the class
@@ -25,15 +34,23 @@
       static void registerClassAndParents(const std::string& classname);
   };
 
+  class ClassDatabaseInterface {
+  public:
+    virtual ~ClassDatabaseInterface() {};
+
+    virtual bool isa(const std::string& classname) const = 0;
+    virtual std::string getPublicClassname() const = 0;
+  };
+
   template<class T>
-  class  ClassDatabase {
+  class ClassDatabase : public ClassDatabaseInterface {
   public:
     class Entry {
     public:
       virtual ~Entry() {}
       virtual T* createInstance() const = 0;
       virtual std::string getPublicClassname() const = 0;
-      virtual void readwrite(Archive* archive, T* ptr) const = 0;
+      virtual void readwrite(ArchiveElement* archive, T* ptr) const = 0;
       virtual const std::type_info& get_typeinfo() const = 0;
       virtual void* getPointerValue(T* ptr) const = 0;
     };
@@ -49,7 +66,7 @@
       virtual std::string getPublicClassname() const {
         return ClassInfo<Class>::getPublicClassname();
       }
-      virtual void readwrite(Archive* archive, T* ptr) const {
+      virtual void readwrite(ArchiveElement* archive, T* ptr) const {
         Class* derivedptr = dynamic_cast<Class*>(ptr);
         if(!derivedptr){
           std::string n1 = typeid(T).name();
@@ -109,21 +126,31 @@
       return singleton()->_getEntry(ti);
     }
 
-  private:
+    virtual bool isa(const std::string& classname) const {
+      return _getEntry(classname) != 0;
+    }
+
+    virtual std::string getPublicClassname() const {
+      return _getEntry(typeid(T))->getPublicClassname();
+    }
+    static ClassDatabaseInterface* getInterface() {
+      return singleton();
+    }
 
+  private:
     static ClassDatabase<T>* singleton() {
       if(!singleton_instance)
         singleton_instance = new ClassDatabase<T>();
       return singleton_instance;
     }
-    Entry* _getEntry(const std::string& name) {
-      typename std::map<std::string, Entry*>::iterator iter = 
database_publicname.find(name);
+    Entry* _getEntry(const std::string& name) const {
+      typename std::map<std::string, Entry*>::const_iterator iter = 
database_publicname.find(name);
       if(iter == database_publicname.end())
         return 0;
       return iter->second;
     }
-    Entry* _getEntry(const std::type_info& ti) {
-      typename std::map<const char*, Entry*>::iterator iter = 
database_typeinfoname.find(ti.name());
+    Entry* _getEntry(const std::type_info& ti) const {
+      typename std::map<const char*, Entry*>::const_iterator iter = 
database_typeinfoname.find(ti.name());
       if(iter == database_typeinfoname.end())
         return 0;
       return iter->second;
@@ -144,17 +171,36 @@
   template<class T>
   class ClassInfo_readwriteMethod {
   public:
-    static void readwrite(Archive* archive, T& data) {
+    static void readwrite(ArchiveElement* archive, T& data) {
       data.readwrite(archive);
     }
+    static Persistent::StorageHint storageHint() {
+      return Persistent::Default;
+    }
   private:
     ClassInfo_readwriteMethod();
   };
 
   template<class T>
+  class ClassInfo_readwriteMethod_lightweight {
+  public:
+    static void readwrite(ArchiveElement* archive, T& data) {
+      data.readwrite(archive);
+    }
+    static Persistent::StorageHint storageHint() {
+      return Persistent::LightweightObject;
+    }
+  private:
+    ClassInfo_readwriteMethod_lightweight();
+  };
+
+  template<class T>
   class ClassInfo_readwriteNone {
   public:
-    static void readwrite(Archive* archive, T& data) {
+    static void readwrite(ArchiveElement* archive, T& data) {
+    }
+    static Persistent::StorageHint storageHint() {
+      return Persistent::Default;
     }
   private:
     ClassInfo_readwriteNone();
@@ -194,21 +240,16 @@
     static void registerClassAndParents(const std::string& classname) {
       ClassDatabase<T>::template registerClass<C>(classname);
     }
+
+    static bool isSimpleContainer() {
+      return false;
+    }
   private:
     ClassInfo_BaseClass();
     static std::string* classname;
   };
   template<class T> std::string* ClassInfo_BaseClass<T>::classname;
 
-  template<class T>
-  bool ClassInfo_BaseClass<T>::registerClass(const std::string& _classname)
-  {
-    if(!classname)
-      classname = new std::string(_classname);
-    registerClassAndParents<T>(_classname);
-    return true;
-  }
-
   template<class T, class Parent>
   class ClassInfo_DerivedClass {
   public:
@@ -224,6 +265,9 @@
       ClassDatabase<T>::template registerClass<C>(classname);
       ClassInfo<Parent>::template registerClassAndParents<C>(classname);
     }
+    static bool isSimpleContainer() {
+      return false;
+    }
   private:
     ClassInfo_DerivedClass();
     // This is a string* instead of a string to avoid initialization order 
issues
@@ -256,6 +300,9 @@
       ClassInfo<Parent1>::template registerClassAndParents<C>(classname);
       ClassInfo<Parent2>::template registerClassAndParents<C>(classname);
     }
+    static bool isSimpleContainer() {
+      return false;
+    }
   private:
     ClassInfo_DerivedClass2();
     // This is a string* instead of a string to avoid initialization order 
issues
@@ -265,6 +312,15 @@
 
   template<class T, class Parent1, class Parent2>
     bool ClassInfo_DerivedClass2<T, Parent1, Parent2>::registerClass(const 
std::string& _classname)
+  {
+    if(!classname)
+      classname = new std::string(_classname);
+    registerClassAndParents<T>(_classname);
+    return true;
+  }
+
+  template<class T>
+  bool ClassInfo_BaseClass<T>::registerClass(const std::string& _classname)
   {
     if(!classname)
       classname = new std::string(_classname);

Modified: branches/persistent/Core/Persistent/XMLArchive.cc
==============================================================================
--- branches/persistent/Core/Reflection/XMLArchive.cc   (original)
+++ branches/persistent/Core/Persistent/XMLArchive.cc   Mon Sep 17 15:30:53 
2007
@@ -1,5 +1,6 @@
 
-#include <Core/Reflection/XMLArchive.h>
+#include <Core/Persistent/XMLArchive.h>
+#include <Core/Persistent/ArchiveElement.h>
 #include <Core/Exceptions/InputError.h>
 #include <Core/Exceptions/SerializationError.h>
 #include <Core/Util/NotFinished.h>
@@ -19,6 +20,109 @@
   return (xmlChar*)t;
 }
 
+static int count(const std::string& str1, const std::string& str2)
+{
+  int count = 0;
+  string::size_type index = 0;
+  while((index = str1.find(str2, index)) != string::npos){
+    index++;
+    count++;
+  }
+  return count;
+}
+
+static void make_safe_classname(std::string& safe_classname, bool& 
have_complex_classname)
+{
+  // If this is a complex classname, we will use "template" as the element 
name
+  // and put the classname in an attribute called "type"
+  have_complex_classname = false;
+  if(count(safe_classname, "<") > 1 || count(safe_classname, ",") > 0) {
+    have_complex_classname = true;
+    safe_classname = "template";
+  } else {
+    // This could be made considerably faster if it is ever a bottleneck
+    string classname = safe_classname;
+    string::size_type index = 0;
+    while((index = safe_classname.find("::")) != string::npos)
+      safe_classname.replace(index, 2, ".");
+    while((index = safe_classname.find("<")) != string::npos)
+      safe_classname.replace(index, 1, "-");
+    while((index = safe_classname.find(">")) != string::npos)
+      safe_classname.erase(index, 1);
+    while((index = safe_classname.find(" ")) != string::npos)
+      safe_classname.erase(index, 1);
+  }
+}
+
+static std::string get_classname(const xmlChar* ptr)
+{
+  string classname = to_char_ptr(ptr);
+  string::size_type index = 0;
+  while((index = classname.find(".")) != string::npos)
+    classname.replace(index, 1, "::");
+  int closecount = 0;
+  while((index = classname.find("-")) != string::npos){
+    classname.replace(index, 1, "<");
+    closecount++;
+  }
+  for(int i=0;i<closecount;i++)
+    classname.push_back('>');
+  return classname;
+}
+
+namespace Manta {
+  class XMLArchiveElement : public ArchiveElement {
+  public:
+    XMLArchiveElement(XMLArchive* archive, xmlNodePtr node);
+    XMLArchiveElement(XMLArchive* archive, xmlNodePtr node, const 
std::string& tagname);
+    virtual ~XMLArchiveElement();
+
+    virtual void readwrite(const std::string& fieldname, bool& data,
+                           Persistent::StorageHint hint = 
Persistent::Default);
+    virtual void readwrite(const std::string& fieldname, double& data,
+                           Persistent::StorageHint hint = 
Persistent::Default);
+    virtual void readwrite(const std::string& fieldname, float& data,
+                           Persistent::StorageHint hint = 
Persistent::Default);
+    virtual void readwrite(const std::string& fieldname, float* data, int 
numElements,
+                           Persistent::StorageHint hint = 
Persistent::Default);
+    virtual void readwrite(const std::string& fieldname, int& data,
+                           Persistent::StorageHint hint = 
Persistent::Default);
+    virtual void readwrite(const std::string& fieldname, std::string& data,
+                           Persistent::StorageHint hint = 
Persistent::Default);
+
+    virtual ArchiveElement* findObject(const std::string& fieldname,
+                                       ClassDatabaseInterface* db,
+                                       std::string& classname,
+                                       Persistent::StorageHint classhint,
+                                       Persistent::StorageHint instancehint);
+    virtual ArchiveElement* createObject(const std::string& fieldname,
+                                         const std::string& classname,
+                                         Persistent::StorageHint classhint,
+                                         Persistent::StorageHint 
instancehint,
+                                         void* datakey);
+    virtual bool isNullPointer(const std::string& fieldname) const;
+    virtual void writeNullPointer(const std::string& fieldname);
+
+    virtual bool haveReference(void* ptr, std::string& refname);
+    virtual void writeObjectReference(const std::string& fieldname,
+                                      const std::string& classname,
+                                      const std::string& refname);
+
+  private:
+    XMLArchive* archive;
+    xmlNodePtr node;
+    string tagname;
+    bool isTagElement;
+    bool tagUsed;
+    void writeProperty(const std::string& fieldname, const std::string& 
value,
+                       Persistent::StorageHint hint);
+
+    typedef XMLArchive::refmaptype refmaptype;
+    typedef XMLArchive::countmaptype countmaptype;
+    typedef XMLArchive::RefInfo RefInfo;
+  };
+}
+
 static Archive* readopener(const std::string& filename)
 {
   LIBXML_TEST_VERSION;
@@ -29,6 +133,10 @@
   if (doc == 0)
     throw InputError("Error reading file: "+filename);
 
+  xmlNodePtr root = xmlDocGetRootElement(doc);
+  if(strcmp(to_char_ptr(root->name), "Manta") != 0)
+    return 0;
+
   return new XMLArchive(doc);
 }
 
@@ -52,107 +160,112 @@
 bool XMLArchive::force_initialize = Archive::registerArchiveType("xml", 
readopener, writeopener);
 
 XMLArchive::XMLArchive(xmlDocPtr doc)
-  : Archive(true)
+  : Archive(true), doc(doc)
 {
-  node = 0;
-  ownsDoc = true;
-  docinfo = new DocInfo;
-  docinfo->doc = doc;
 }
 
 XMLArchive::XMLArchive(const std::string& infilename)
   : Archive(false)
 {
-  node = 0;
-  ownsDoc = true;
-  docinfo = new DocInfo;
-  docinfo->doc = xmlNewDoc(to_xml_ch_ptr("1.0"));
-  docinfo->filename = infilename;
+  doc = xmlNewDoc(to_xml_ch_ptr("1.0"));
+  filename = infilename;
 }
 
-XMLArchive::XMLArchive(XMLArchive* copy, xmlNodePtr node)
-  : Archive(copy->isreading), node(node), docinfo(copy->docinfo), 
ownsDoc(false)
+XMLArchive::~XMLArchive()
 {
+  if(writing()){
+    xmlKeepBlanksDefault(0);
+    xmlSaveFormatFileEnc(filename.c_str(), doc, "UTF-8", 1);
+  }
+  xmlFreeDoc(doc);
 }
 
-XMLArchive::~XMLArchive()
+ArchiveElement* XMLArchive::getRoot()
 {
-  if(ownsDoc){
-    if(writing()){
-      xmlKeepBlanksDefault(0);
-      xmlSaveFormatFileEnc(docinfo->filename.c_str(), docinfo->doc, "UTF-8", 
1);
-    } else {
-    }
-    xmlFreeDoc(docinfo->doc);
-    delete docinfo;
+  if(reading()){
+    xmlNodePtr root = xmlDocGetRootElement(doc);
+    return new XMLArchiveElement(this, root);
+  } else {
+    xmlNodePtr top = xmlNewNode(0, to_xml_ch_ptr("Manta"));
+    xmlDocSetRootElement(doc, top);
+    return new XMLArchiveElement(this, top);
   }
 }
 
-void XMLArchive::writeProperty(const char* fieldname, const std::string& 
value)
+XMLArchiveElement::XMLArchiveElement(XMLArchive* archive, xmlNodePtr node)
+  : ArchiveElement(archive->reading()), archive(archive), node(node), 
isTagElement(false)
 {
-  if(!fieldname){
-    // Write the value as a property of the parent node
-    if(xmlHasProp(node->parent, node->name)){
-      ostringstream msg;
-      msg << "Writing duplicate anonymous field in writing class " << 
to_char_ptr(node->name);
-      throw SerializationError(msg.str());
-    }
-    if(node->children){
+}
+
+XMLArchiveElement::XMLArchiveElement(XMLArchive* archive, xmlNodePtr node, 
const std::string& tagname)
+  : ArchiveElement(archive->reading()), archive(archive), node(node), 
tagname(tagname), isTagElement(true), tagUsed(false)
+{
+}
+
+XMLArchiveElement::~XMLArchiveElement()
+{
+}
+
+void XMLArchiveElement::writeProperty(const std::string& fieldname, const 
std::string& value,
+                                      Persistent::StorageHint hint)
+{
+  if(isTagElement){
+    if(tagUsed)
+      throw SerializationError("Lightweight class written with more than one 
data member");
+    tagUsed = true;
+    if(xmlHasProp(node, to_xml_ch_ptr(tagname.c_str()))){
       ostringstream msg;
-      msg << "Using anonymous (single) field when there are other XML 
children in writing class " << to_char_ptr(node->name);
+      msg << "Writing duplicate field (" << fieldname << ") in writing class 
" << to_char_ptr(node->name);
       throw SerializationError(msg.str());
     }
-    xmlSetProp(node->parent, node->name, to_xml_ch_ptr(value.c_str()));
-    xmlUnlinkNode(node);
-    xmlFreeNode(node);
-    node = 0;
+    xmlSetProp(node, to_xml_ch_ptr(tagname.c_str()), 
to_xml_ch_ptr(value.c_str()));
   } else {
-    if(xmlHasProp(node, to_xml_ch_ptr(fieldname))){
+    if(xmlHasProp(node, to_xml_ch_ptr(fieldname.c_str()))){
       ostringstream msg;
       msg << "Writing duplicate field (" << fieldname << ") in writing class 
" << to_char_ptr(node->name);
       throw SerializationError(msg.str());
     }
-    xmlSetProp(node, to_xml_ch_ptr(fieldname), to_xml_ch_ptr(value.c_str()));
+    xmlSetProp(node, to_xml_ch_ptr(fieldname.c_str()), 
to_xml_ch_ptr(value.c_str()));
   }
 }
 
-void XMLArchive::readwrite(const char* fieldname, bool& data)
+void XMLArchiveElement::readwrite(const std::string& fieldname, bool& data, 
Persistent::StorageHint hint)
 {
   if(reading()){
-    NOT_FINISHED("XMLArchive::readwrite");
+    NOT_FINISHED("XMLArchiveElement::readwrite");
   } else {
-    writeProperty(fieldname, data?"true":"false");
+    writeProperty(fieldname, data?"true":"false", hint);
   }
 }
     
-void XMLArchive::readwrite(const char* fieldname, double& data)
+void XMLArchiveElement::readwrite(const std::string& fieldname, double& 
data, Persistent::StorageHint hint)
 {
   if(reading()){
-    NOT_FINISHED("XMLArchive::readwrite");
+    NOT_FINISHED("XMLArchiveElement::readwrite");
   } else {
     ostringstream datastring;
     datastring.precision(17);
     datastring << data;
-    writeProperty(fieldname, datastring.str());
+    writeProperty(fieldname, datastring.str(), hint);
   }
 }
 
-void XMLArchive::readwrite(const char* fieldname, float& data)
+void XMLArchiveElement::readwrite(const std::string& fieldname, float& data, 
Persistent::StorageHint hint)
 {
   if(reading()){
-    NOT_FINISHED("XMLArchive::readwrite");
+    NOT_FINISHED("XMLArchiveElement::readwrite");
   } else {
     ostringstream datastring;
     datastring.precision(8);
     datastring << data;
-    writeProperty(fieldname, datastring.str());
+    writeProperty(fieldname, datastring.str(), hint);
   }
 }
 
-void XMLArchive::readwrite(const char* fieldname, float* data, int 
numelements)
+void XMLArchiveElement::readwrite(const std::string& fieldname, float* data, 
int numelements, Persistent::StorageHint hint)
 {
   if(reading()){
-    NOT_FINISHED("XMLArchive::readwrite");
+    NOT_FINISHED("XMLArchiveElement::readwrite");
   } else {
     ostringstream datastring;
     datastring.precision(8);
@@ -161,108 +274,176 @@
         datastring << " ";
       datastring << data[i];
     }
-    writeProperty(fieldname, datastring.str());
+    writeProperty(fieldname, datastring.str(), hint);
   }
 }
 
-void XMLArchive::readwrite(const char* fieldname, int& data)
+void XMLArchiveElement::readwrite(const std::string& fieldname, int& data, 
Persistent::StorageHint hint)
 {
   if(reading()){
-    NOT_FINISHED("XMLArchive::readwrite");
+    NOT_FINISHED("XMLArchiveElement::readwrite");
   } else {
     ostringstream datastring;
     datastring << data;
-    writeProperty(fieldname, datastring.str());
+    writeProperty(fieldname, datastring.str(), hint);
   }
 }
 
-void XMLArchive::readwrite(const char* fieldname, std::string& data)
+void XMLArchiveElement::readwrite(const std::string& fieldname, std::string& 
data, Persistent::StorageHint hint)
 {
   if(reading()){
-    NOT_FINISHED("XMLArchive::readwrite");
+    NOT_FINISHED("XMLArchiveElement::readwrite");
   } else {
-    writeProperty(fieldname, data);
+    writeProperty(fieldname, data, hint);
   }
 }
 
-std::string XMLArchive::getClassname() const
-{
-  return to_char_ptr(node->name);
-}
-
-Archive* XMLArchive::findField(const std::string& fieldname) const
-{
-  NOT_FINISHED("XMLArchive::findField");
+ArchiveElement* XMLArchiveElement::findObject(const std::string& fieldname,
+                                              ClassDatabaseInterface* db,
+                                              std::string& classname,
+                                              Persistent::StorageHint 
classhint,
+                                              Persistent::StorageHint 
instancehint)
+{
+#if 0
+  if(hint == AnonymousField){
+    for(xmlNode* child = node->children; child != 0; child = child->next){
+      if(strcmp(to_char_ptr(child->name), "template")){
+        xmlChar* prop = xmlGetProp(child, to_xml_ch_ptr("type"));
+        if(prop && db->isa(to_char_ptr(prop))){
+          classname = to_char_ptr(prop);
+          return new XMLArchiveElement(archive, child);
+        }
+      } else {
+        classname = get_classname(child->name);
+        if(db->isa(classname))
+          return new XMLArchiveElement(archive, child);
+      }
+    }
+  } else {
+    for(xmlNode* child = node->children; child != 0; child = child->next){
+      if(strcmp(to_char_ptr(child->name), fieldname.c_str()) == 0){
+        xmlNode* c2 = child->children;
+        // There should only be one child of those node
+        if(c2->next){
+          ostringstream msg;
+          msg << "Multiple objects in one field: " << fieldname;
+          msg << "(" << to_char_ptr(c2->name) << " and " << 
to_char_ptr(c2->next->name) << ")";
+        }
+        return new XMLArchiveElement(archive, c2);
+      }
+    }
+  }
+#else
+  NOT_FINISHED("New findObject");
+#endif
   return 0;
 }
 
-Archive* XMLArchive::createClass(const std::string& classname)
-{
-  xmlNodePtr child = xmlNewNode(0, to_xml_ch_ptr(classname.c_str()));
-  if(node)
+ArchiveElement* XMLArchiveElement::createObject(const std::string& fieldname,
+                                                const std::string& classname,
+                                                Persistent::StorageHint 
classhint,
+                                                Persistent::StorageHint 
instancehint,
+                                                void* datakey)
+{
+  if(isTagElement)
+    throw SerializationError("Creating complex object in lightweight archive 
element");
+  bool have_complex_classname;
+  string safe_classname = classname;
+  make_safe_classname(safe_classname, have_complex_classname);
+
+  xmlNodePtr returnNode;
+  if(classhint == Persistent::ContainerObject || classhint == 
Persistent::SimpleObject){
+    // Store only the field name
+    xmlNodePtr field = xmlNewNode(0, to_xml_ch_ptr(fieldname.c_str()));
+    xmlAddChild(node, field);
+    returnNode = field;
+  } else if(instancehint == Persistent::AnonymousField){
+    // Store only the class name
+    xmlNodePtr child = xmlNewNode(0, to_xml_ch_ptr(safe_classname.c_str()));
+    if(have_complex_classname)
+      xmlSetProp(child, to_xml_ch_ptr("type"), 
to_xml_ch_ptr(classname.c_str()));
     xmlAddChild(node, child);
-  else
-    xmlDocSetRootElement(docinfo->doc, child);
-  return new XMLArchive(this, child);
-}
+    returnNode = child;
+  } else if(classhint == Persistent::LightweightObject && datakey == 0){
+    // Store one value in the tag
+    return new XMLArchiveElement(archive, node, fieldname);
+  } else {
+    // Store both field name and class
+    xmlNodePtr child = xmlNewNode(0, to_xml_ch_ptr(safe_classname.c_str()));
+    if(have_complex_classname)
+      xmlSetProp(child, to_xml_ch_ptr("type"), 
to_xml_ch_ptr(classname.c_str()));
+    xmlNodePtr field = xmlNewNode(0, to_xml_ch_ptr(fieldname.c_str()));
+    xmlAddChild(node, field);
+    xmlAddChild(field, child);
+    returnNode = child;
+  }
 
-Archive* XMLArchive::createField(const std::string& fieldname)
-{
-  xmlNodePtr field = xmlNewNode(0, to_xml_ch_ptr(fieldname.c_str()));
-  xmlAddChild(node, field);
-  return new XMLArchive(this, field);
-}
 
-Archive* XMLArchive::createFieldForClass(const std::string& fieldname, const 
std::string& classname)
-{
-  xmlNodePtr field = xmlNewNode(0, to_xml_ch_ptr(fieldname.c_str()));
-  xmlAddChild(node, field);
-  xmlNodePtr child = xmlNewNode(0, to_xml_ch_ptr(classname.c_str()));
-  xmlAddChild(field, child);
-  return new XMLArchive(this, child);
+  if(datakey != 0){
+    refmaptype::iterator iter = archive->refmap.find(datakey);
+    if(iter != archive->refmap.end())
+      throw SerializationError("Pointer writen twice (reference id " + 
iter->second.refname + ")");
+
+    RefInfo ri;
+    ri.node = returnNode;
+    ri.refname = classname; // Will be appended with unique ID in 
haveReference
+    ri.used = false;
+
+    archive->refmap.insert(make_pair(datakey, ri));
+  }
+  return new XMLArchiveElement(archive, returnNode);
 }
 
-bool XMLArchive::isNullPointer() const
+bool XMLArchiveElement::isNullPointer(const std::string& fieldname) const
 {
-  NOT_FINISHED("XMLArchive::isNullPointer");
-  return false;
+  if(fieldname != ""){
+    xmlChar* prop = xmlGetProp(node, to_xml_ch_ptr(fieldname.c_str()));
+    if(prop)
+      return strcmp(to_char_ptr(prop), "null") == 0;
+
+    return false;
+  } else {
+    return strcmp(to_char_ptr(node->name), "null") == 0;
+  }
 }
 
-void XMLArchive::writeNullPointer(const std::string& fieldname)
+void XMLArchiveElement::writeNullPointer(const std::string& fieldname)
 {
-  xmlNodePtr field;
   if(fieldname == ""){
-    field = xmlNewNode(0, to_xml_ch_ptr("null"));
+    xmlNodePtr field = xmlNewNode(0, to_xml_ch_ptr("null"));
+    xmlAddChild(node, field);
   } else {
-    field = xmlNewNode(0, to_xml_ch_ptr(fieldname.c_str()));
+    xmlSetProp(node, to_xml_ch_ptr(fieldname.c_str()), 
to_xml_ch_ptr("null"));
   }
 }
 
-void XMLArchive::writeObjectReference(const std::string& fieldname,
-                                      const std::string& classname,
-                                      const std::string& refname)
+void XMLArchiveElement::writeObjectReference(const std::string& fieldname,
+                                             const std::string& classname,
+                                             const std::string& refname)
 {
   if(fieldname == ""){
-    NOT_FINISHED("XMLArchive::writeObjectReference");
+    NOT_FINISHED("XMLArchiveElement::writeObjectReference");
   } else {
     xmlSetProp(node, to_xml_ch_ptr(fieldname.c_str()), 
to_xml_ch_ptr(refname.c_str()));
   }
 }
 
-bool XMLArchive::haveReference(void* ptr, std::string& refname)
+bool XMLArchiveElement::haveReference(void* ptr, std::string& refname)
 {
-  refmaptype::iterator iter = docinfo->refmap.find(ptr);
-  if(iter == docinfo->refmap.end()){
+  refmaptype::iterator iter = archive->refmap.find(ptr);
+  if(iter == archive->refmap.end()){
     return false;
   } else {
-    RefInfo& ri = iter->second;
+    XMLArchive::RefInfo& ri = iter->second;
     if(!ri.used){
       // Append the count to make it unique
-      countmaptype::iterator citer = docinfo->countmap.find(ri.refname);
+      // We do it here so that we only change the number for objects
+      // that are referred to by reference
+      countmaptype::iterator citer = archive->countmap.find(ri.refname);
       int count;
-      if(citer == docinfo->countmap.end()){
+      if(citer == archive->countmap.end()){
         count = 0;
-        docinfo->countmap.insert(make_pair(ri.refname, 1));
+        archive->countmap.insert(make_pair(ri.refname, 1));
       } else {
         count = citer->second++;
       }
@@ -278,17 +459,3 @@
   }
 }
 
-void XMLArchive::saveReference(void* ptr, const std::string& classname)
-{
-  refmaptype::iterator iter = docinfo->refmap.find(ptr);
-  if(iter != docinfo->refmap.end())
-    throw SerializationError("Pointer writen twice (reference id " + 
iter->second.refname);
-
-
-  RefInfo ri;
-  ri.node = node;
-  ri.refname = classname; // Will be appended with unique ID later
-  ri.used = false;
-
-  docinfo->refmap.insert(make_pair(ptr, ri));
-}

Modified: branches/persistent/Core/Persistent/XMLArchive.h
==============================================================================
--- branches/persistent/Core/Reflection/XMLArchive.h    (original)
+++ branches/persistent/Core/Persistent/XMLArchive.h    Mon Sep 17 15:30:53 
2007
@@ -2,7 +2,7 @@
 #ifndef Manta_XMLArchive_h
 #define Manta_XMLArchive_h
 
-#include <Core/Reflection/Archive.h>
+#include <Core/Persistent/Archive.h>
 #include <libxml/tree.h>
 #include <map>
 #include <string>
@@ -12,33 +12,14 @@
   public:
     XMLArchive(xmlDocPtr doc);
     XMLArchive(const std::string& filename);
-    XMLArchive(XMLArchive* archive, xmlNodePtr node);
     virtual ~XMLArchive();
 
-    virtual void readwrite(const char* fieldname, bool& data);
-    virtual void readwrite(const char* fieldname, double& data);
-    virtual void readwrite(const char* fieldname, float& data);
-    virtual void readwrite(const char* fieldname, float* data, int 
numElements);
-    virtual void readwrite(const char* fieldname, int& data);
-    virtual void readwrite(const char* fieldname, std::string& data);
-    
-    virtual std::string getClassname() const;
-
-    virtual Archive* findField(const std::string& fieldname) const;
-    virtual Archive* createClass(const std::string& fieldname);
-    virtual Archive* createField(const std::string& fieldname);
-    virtual Archive* createFieldForClass(const std::string& fieldname, const 
std::string& classname);
-    virtual bool isNullPointer() const;
-    virtual void writeNullPointer(const std::string& fieldname);
-
-    virtual bool haveReference(void* ptr, std::string& refname);
-    virtual void saveReference(void* ptr, const std::string& classname);
-    virtual void writeObjectReference(const std::string& fieldname,
-                                      const std::string& classname,
-                                      const std::string& refname);
+    virtual ArchiveElement* getRoot();
 
   private:
-    xmlNodePtr node;
+    friend class XMLArchiveElement;
+    std::string filename;
+    xmlDocPtr doc;
 
     struct RefInfo {
       xmlNodePtr node;
@@ -47,15 +28,10 @@
     };
 
     typedef std::map<void*, RefInfo> refmaptype;
+    refmaptype refmap;
+
     typedef std::map<std::string, int> countmaptype;
-    struct DocInfo {
-      refmaptype refmap;
-      countmaptype countmap;
-      xmlDocPtr doc;
-      std::string filename;
-    };
-    DocInfo* docinfo;
-    bool ownsDoc;
+    countmaptype countmap;
 
     static bool force_initialize;
     void writeProperty(const char* fieldname, const std::string& value);

Modified: branches/persistent/Core/Persistent/stdClassInfo.h
==============================================================================
--- branches/persistent/Core/Reflection/stdClassInfo.h  (original)
+++ branches/persistent/Core/Persistent/stdClassInfo.h  Mon Sep 17 15:30:53 
2007
@@ -2,8 +2,8 @@
 #ifndef Manta_stdRefl_h
 #define Manta_stdRefl_h
 
-#include <Core/Reflection/ClassInfo.h>
-#include <Core/Reflection/Archive.h>
+#include <Core/Persistent/ClassInfo.h>
+#include <Core/Persistent/ArchiveElement.h>
 #include <Core/Util/NotFinished.h>
 #include <vector>
 
@@ -19,10 +19,13 @@
       init.forceinit();
       return new std::vector<T>();
     }
-    static void readwrite(Archive* archive, std::vector<T>& data) {
+    static void readwrite(ArchiveElement* archive, std::vector<T>& data) {
       init.forceinit();
       NOT_FINISHED("vector readwrite");
     }
+    static bool isSimpleContainer() {
+      return true;
+    }
   private:
     class Initializer {
     public:
@@ -48,14 +51,17 @@
       init.forceinit();
       return new std::vector<T*>();
     }
-    static void readwrite(Archive* archive, std::vector<T*>& data) {
+    static void readwrite(ArchiveElement* archive, std::vector<T*>& data) {
       init.forceinit();
       if(archive->reading()){
         NOT_FINISHED("vector readwrite");
       } else {
         for(typename std::vector<T*>::iterator iter = data.begin(); iter != 
data.end(); iter++)
-          archive->readwrite(0, *iter);
+          archive->readwrite("element", *iter, Persistent::AnonymousField);
       }
+    }
+    static Persistent::StorageHint storageHint() {
+      return Persistent::ContainerObject;
     }
   private:
     class Initializer {

Modified: branches/persistent/Engine/Factory/Factory.cc
==============================================================================
--- branches/persistent/Engine/Factory/Factory.cc       (original)
+++ branches/persistent/Engine/Factory/Factory.cc       Mon Sep 17 15:30:53 
2007
@@ -33,7 +33,8 @@
 #include <Core/Exceptions/IllegalValue.h>
 #include <Core/Exceptions/InputError.h>
 #include <Core/Exceptions/InternalError.h>
-#include <Core/Reflection/Archive.h>
+#include <Core/Persistent/Archive.h>
+#include <Core/Persistent/ArchiveElement.h>
 #include <Core/Util/Args.h>
 #include <Engine/Factory/RegisterKnownComponents.h>
 #include <Interface/Context.h>
@@ -458,16 +459,14 @@
   if(!archive)
     throw InputError("Could not open Archive: " + fullname);
   
-  string root = archive->getClassname();
-  if(root == "Scene"){
-    Scene* scene = 0;
-    archive->readwrite(0, scene);
-    if(!scene)
-      throw InternalError("Error reading file: " + fullname, __FILE__, 
__LINE__);
-    return scene;
-  } else {
-    throw InputError("Unknown root object (" + root + ") in file: " + 
fullname + ", file should contain a Scene");
-  }
+  ArchiveElement* root = archive->getRoot();
+  if(!root)
+    throw InputError("Cannot find scene in file: " + fullname);
+  Scene* scene = 0;
+  root->readwrite("scene", scene, Persistent::AnonymousField);
+  if(!scene)
+    throw InternalError("Error reading file: " + fullname, __FILE__, 
__LINE__);
+  return scene;
 }  
 
 Scene* Factory::readMOScene(const string& name, const vector<string>& args,

Modified: branches/persistent/Interface/Camera.cc
==============================================================================
--- branches/persistent/Interface/Camera.cc     (original)
+++ branches/persistent/Interface/Camera.cc     Mon Sep 17 15:30:53 2007
@@ -1,5 +1,6 @@
 
 #include <Interface/Camera.h>
+#include <Core/Persistent/ArchiveElement.h>
 
 using namespace Manta;
 
@@ -17,3 +18,12 @@
 {
 }
 
+REGISTER_CLASS(BasicCameraData);
+
+void BasicCameraData::readwrite(ArchiveElement* archive)
+{
+  archive->readwrite("eye", eye);
+  archive->readwrite("lookat", lookat);
+  archive->readwrite("up", up);
+  archive->readwrite("hfov", hfov);
+}

Modified: branches/persistent/Interface/Camera.h
==============================================================================
--- branches/persistent/Interface/Camera.h      (original)
+++ branches/persistent/Interface/Camera.h      Mon Sep 17 15:30:53 2007
@@ -35,7 +35,11 @@
 
     // Someday, it may be nice to add extra space with an identifier for 
camera that
     // want to store other parameters here.
+
+    void readwrite(ArchiveElement* archive);
   };
+
+  DECLARE_CLASSINFO_BASECLASS(BasicCameraData, ConcreteClass, 
readwriteMethod);
 
   class Camera : public Interpolable {
   public:

Modified: branches/persistent/Interface/InterfaceClassInfo.h
==============================================================================
--- branches/persistent/Interface/InterfaceClassInfo.h  (original)
+++ branches/persistent/Interface/InterfaceClassInfo.h  Mon Sep 17 15:30:53 
2007
@@ -2,7 +2,7 @@
 #ifndef Manta_InterfaceRefl_h
 #define Manta_InterfaceRefl_h
 
-#include <Core/Reflection/ClassInfo.h>
+#include <Core/Persistent/ClassInfo.h>
 
 namespace Manta {
   class AmbientLight;

Modified: branches/persistent/Interface/LightSet.cc
==============================================================================
--- branches/persistent/Interface/LightSet.cc   (original)
+++ branches/persistent/Interface/LightSet.cc   Mon Sep 17 15:30:53 2007
@@ -3,8 +3,8 @@
 #include <Interface/AmbientLight.h>
 #include <Interface/Light.h>
 #include <Interface/InterfaceClassInfo.h>
-#include <Core/Reflection/Archive.h>
-#include <Core/Reflection/stdClassInfo.h>
+#include <Core/Persistent/ArchiveElement.h>
+#include <Core/Persistent/stdClassInfo.h>
 #include <Core/Util/Assert.h>
 
 #include <sgi_stl_warnings_off.h>
@@ -54,7 +54,7 @@
   return out.str();
 }
 
-void LightSet::readwrite(Archive* archive)
+void LightSet::readwrite(ArchiveElement* archive)
 {
   archive->readwrite("lights", lights);
   archive->readwrite("ambientLight", ambientLight);

Modified: branches/persistent/Interface/LightSet.h
==============================================================================
--- branches/persistent/Interface/LightSet.h    (original)
+++ branches/persistent/Interface/LightSet.h    Mon Sep 17 15:30:53 2007
@@ -43,7 +43,7 @@
 
     string toString() const;
 
-    void readwrite(Archive* archive);
+    void readwrite(ArchiveElement* archive);
   private:
     LightSet(const LightSet&);
     LightSet& operator=(const LightSet&);

Modified: branches/persistent/Interface/RenderParameters.cc
==============================================================================
--- branches/persistent/Interface/RenderParameters.cc   (original)
+++ branches/persistent/Interface/RenderParameters.cc   Mon Sep 17 15:30:53 
2007
@@ -1,10 +1,10 @@
 
 #include <Interface/RenderParameters.h>
-#include <Core/Reflection/Archive.h>
+#include <Core/Persistent/ArchiveElement.h>
 
 using namespace Manta;
 
-void RenderParameters::readwrite(Archive* archive)
+void RenderParameters::readwrite(ArchiveElement* archive)
 {
   archive->readwrite("maxDepth", maxDepth);
   archive->readwrite("importanceCutoff", importanceCutoff);

Modified: branches/persistent/Interface/RenderParameters.h
==============================================================================
--- branches/persistent/Interface/RenderParameters.h    (original)
+++ branches/persistent/Interface/RenderParameters.h    Mon Sep 17 15:30:53 
2007
@@ -5,7 +5,7 @@
 #include <MantaTypes.h>
 
 namespace Manta {
-  class Archive;
+  class ArchiveElement;
   class RenderParameters {
   public:
     RenderParameters() {
@@ -30,7 +30,7 @@
         importanceCutoff = new_importanceCutoff;
     }
 
-    void readwrite(Archive* archive);
+    void readwrite(ArchiveElement* archive);
   private:
   };
 }

Modified: branches/persistent/Interface/Scene.cc
==============================================================================
--- branches/persistent/Interface/Scene.cc      (original)
+++ branches/persistent/Interface/Scene.cc      Mon Sep 17 15:30:53 2007
@@ -1,7 +1,7 @@
 
 #include <Interface/Scene.h>
-#include <Core/Reflection/stdClassInfo.h>
-#include <Core/Reflection/Archive.h>
+#include <Core/Persistent/stdClassInfo.h>
+#include <Core/Persistent/ArchiveElement.h>
 #include <Interface/Background.h>
 #include <Interface/InterfaceClassInfo.h>
 #include <Interface/LightSet.h>
@@ -45,7 +45,7 @@
   return &bookmarks[currentBookmark]->cameradata;
 }
 
-void Scene::readwrite(Archive* archive)
+void Scene::readwrite(ArchiveElement* archive)
 {
   archive->readwrite("object", object);
   archive->readwrite("bg", bg);
@@ -60,7 +60,7 @@
   REGISTER_CLASS(Scene::Bookmark);
 }
 
-void Scene::Bookmark::readwrite(Archive* archive)
+void Scene::Bookmark::readwrite(ArchiveElement* archive)
 {
   archive->readwrite("name", name);
   archive->readwrite("cameradata", cameradata);

Modified: branches/persistent/Interface/Scene.h
==============================================================================
--- branches/persistent/Interface/Scene.h       (original)
+++ branches/persistent/Interface/Scene.h       Mon Sep 17 15:30:53 2007
@@ -74,9 +74,9 @@
     void selectBookmark(int bookmark);
     const BasicCameraData* nextBookmark();
 
-    void readwrite(Archive*);
+    void readwrite(ArchiveElement*);
     struct Bookmark {
-      void readwrite(Archive* archive);
+      void readwrite(ArchiveElement* archive);
     private:
       friend class Scene;
       std::string name;

Modified: branches/persistent/Interface/TexCoordMapper.h
==============================================================================
--- branches/persistent/Interface/TexCoordMapper.h      (original)
+++ branches/persistent/Interface/TexCoordMapper.h      Mon Sep 17 15:30:53 
2007
@@ -5,7 +5,7 @@
 #include <Interface/Interpolable.h>
 
 namespace Manta {
-  class Archive;
+  class ArchiveElement;
   class RayPacket;
   class RenderContext;
 
@@ -19,7 +19,7 @@
     virtual void computeTexCoords3(const RenderContext& context,
                                   RayPacket& rays) const = 0;
 
-    void readwrite(Archive* archive);
+    void readwrite(ArchiveElement* archive);
   private:
     TexCoordMapper(const TexCoordMapper&);
     TexCoordMapper& operator=(const TexCoordMapper&);

Modified: branches/persistent/Model/AmbientLights/ArcAmbient.cc
==============================================================================
--- branches/persistent/Model/AmbientLights/ArcAmbient.cc       (original)
+++ branches/persistent/Model/AmbientLights/ArcAmbient.cc       Mon Sep 17 
15:30:53 2007
@@ -2,7 +2,7 @@
 #include <Model/AmbientLights/ArcAmbient.h>
 #include <Interface/RayPacket.h>
 #include <Interface/InterfaceClassInfo.h>
-#include <Core/Reflection/Archive.h>
+#include <Core/Persistent/ArchiveElement.h>
 
 #include <sgi_stl_warnings_off.h>
 #include <sstream>
@@ -78,7 +78,7 @@
 REGISTER_CLASS(ArcAmbient);
 }
 
-void ArcAmbient::readwrite(Archive* archive)
+void ArcAmbient::readwrite(ArchiveElement* archive)
 {
   ClassInfo<AmbientLight>::readwrite(archive, *this);
   archive->readwrite("cup", cup);

Modified: branches/persistent/Model/AmbientLights/ArcAmbient.h
==============================================================================
--- branches/persistent/Model/AmbientLights/ArcAmbient.h        (original)
+++ branches/persistent/Model/AmbientLights/ArcAmbient.h        Mon Sep 17 
15:30:53 2007
@@ -23,7 +23,7 @@
     virtual void computeAmbient(const RenderContext& context, RayPacket& 
rays, ColorArray ambient) const;
 
     virtual std::string toString() const;
-    virtual void readwrite(Archive*);
+    virtual void readwrite(ArchiveElement*);
   private:
     Color cup;
     Color cdown;

Modified: branches/persistent/Model/Backgrounds/LinearBackground.cc
==============================================================================
--- branches/persistent/Model/Backgrounds/LinearBackground.cc   (original)
+++ branches/persistent/Model/Backgrounds/LinearBackground.cc   Mon Sep 17 
15:30:53 2007
@@ -1,6 +1,6 @@
 
 #include <Model/Backgrounds/LinearBackground.h>
-#include <Core/Reflection/Archive.h>
+#include <Core/Persistent/ArchiveElement.h>
 #include <Interface/InterfaceClassInfo.h>
 #include <Interface/RayPacket.h>
 #include <MantaTypes.h>
@@ -44,7 +44,7 @@
 REGISTER_CLASS(LinearBackground);
 }
 
-void LinearBackground::readwrite(Archive* archive)
+void LinearBackground::readwrite(ArchiveElement* archive)
 {
   ClassInfo<Background>::readwrite(archive, *this);
   archive->readwrite("cup", cup);

Modified: branches/persistent/Model/Backgrounds/LinearBackground.h
==============================================================================
--- branches/persistent/Model/Backgrounds/LinearBackground.h    (original)
+++ branches/persistent/Model/Backgrounds/LinearBackground.h    Mon Sep 17 
15:30:53 2007
@@ -5,7 +5,7 @@
 #include <Interface/Background.h>
 #include <Core/Color/Color.h>
 #include <Core/Geometry/Vector.h>
-#include <Core/Reflection/ClassInfo.h>
+#include <Core/Persistent/ClassInfo.h>
 
 namespace Manta {
 
@@ -18,7 +18,7 @@
     virtual void preprocess(const PreprocessContext& context);
     virtual void shade(const RenderContext& context, RayPacket& rays) const;
 
-    void readwrite(Archive* archive);
+    void readwrite(ArchiveElement* archive);
   private:
     Color cup;
     Color cdown;

Modified: branches/persistent/Model/Groups/Group.cc
==============================================================================
--- branches/persistent/Model/Groups/Group.cc   (original)
+++ branches/persistent/Model/Groups/Group.cc   Mon Sep 17 15:30:53 2007
@@ -1,8 +1,8 @@
 
 #include <Model/Groups/Group.h>
 #include <Interface/InterfaceClassInfo.h>
-#include <Core/Reflection/stdClassInfo.h>
-#include <Core/Reflection/Archive.h>
+#include <Core/Persistent/stdClassInfo.h>
+#include <Core/Persistent/ArchiveElement.h>
 #include <SCIRun/Core/Util/Assert.h>
 #include <algorithm>
 #include <assert.h>
@@ -160,7 +160,7 @@
 REGISTER_CLASS(Group);
 }
 
-void Group::readwrite(Archive* archive)
+void Group::readwrite(ArchiveElement* archive)
 {
   ClassInfo<Object>::readwrite(archive, *this);
   archive->readwrite("objs", objs);

Modified: branches/persistent/Model/Groups/Group.h
==============================================================================
--- branches/persistent/Model/Groups/Group.h    (original)
+++ branches/persistent/Model/Groups/Group.h    Mon Sep 17 15:30:53 2007
@@ -32,7 +32,7 @@
 
 
 #include <Interface/Object.h>
-#include <Core/Reflection/ClassInfo.h>
+#include <Core/Persistent/ClassInfo.h>
 #include <sgi_stl_warnings_off.h>
 #include <vector>
 #include <string>
@@ -70,7 +70,7 @@
 
     static Group* create(const vector<string>& args);
 
-    void readwrite(Archive* archive);
+    void readwrite(ArchiveElement* archive);
   protected:
     vector<Object*> objs;
     vector<Object*>::iterator  parallelSplit; //point to the start of the 
parallel objects

Modified: branches/persistent/Model/Lights/PointLight.cc
==============================================================================
--- branches/persistent/Model/Lights/PointLight.cc      (original)
+++ branches/persistent/Model/Lights/PointLight.cc      Mon Sep 17 15:30:53 
2007
@@ -1,7 +1,7 @@
 
 #include <Model/Lights/PointLight.h>
-#include <Core/Reflection/Archive.h>
-#include <Core/Reflection/ClassInfo.h>
+#include <Core/Persistent/ArchiveElement.h>
+#include <Core/Persistent/ClassInfo.h>
 #include <Interface/InterfaceClassInfo.h>
 #include <MantaSSE.h>
 
@@ -70,7 +70,7 @@
   REGISTER_CLASS(PointLight);
 }
 
-void PointLight::readwrite(Archive* archive)
+void PointLight::readwrite(ArchiveElement* archive)
 {
   ClassInfo<Light>::readwrite(archive, *this);
   archive->readwrite("position", position);

Modified: branches/persistent/Model/Lights/PointLight.h
==============================================================================
--- branches/persistent/Model/Lights/PointLight.h       (original)
+++ branches/persistent/Model/Lights/PointLight.h       Mon Sep 17 15:30:53 
2007
@@ -27,7 +27,7 @@
     Color getColor() const { return color; }
     void setColor(Color new_c) { color = new_c; }
 
-    void readwrite(Archive* archive);
+    void readwrite(ArchiveElement* archive);
   private:
     Vector position;
     Color color;

Modified: branches/persistent/Model/Materials/Lambertian.cc
==============================================================================
--- branches/persistent/Model/Materials/Lambertian.cc   (original)
+++ branches/persistent/Model/Materials/Lambertian.cc   Mon Sep 17 15:30:53 
2007
@@ -34,8 +34,8 @@
 #include <Interface/AmbientLight.h>
 #include <Interface/Context.h>
 #include <Interface/ShadowAlgorithm.h>
-#include <Core/Reflection/ClassInfo.h>
-#include <Core/Reflection/Archive.h>
+#include <Core/Persistent/ClassInfo.h>
+#include <Core/Persistent/ArchiveElement.h>
 #include <Interface/InterfaceClassInfo.h>
 #include <Model/Textures/Constant.h>
 #include <iostream>
@@ -241,7 +241,7 @@
   REGISTER_CLASS(Lambertian);
 }
 
-void Lambertian::readwrite(Archive* archive)
+void Lambertian::readwrite(ArchiveElement* archive)
 {
   ClassInfo<LitMaterial>::readwrite(archive, *this);
   archive->readwrite("color", colortex);

Modified: branches/persistent/Model/Materials/Lambertian.h
==============================================================================
--- branches/persistent/Model/Materials/Lambertian.h    (original)
+++ branches/persistent/Model/Materials/Lambertian.h    Mon Sep 17 15:30:53 
2007
@@ -35,7 +35,7 @@
 #include <Interface/Texture.h>
 
 namespace Manta{
-  class Archive;
+  class ArchiveElement;
   class LightSet;
 
   class Lambertian : public LitMaterial {
@@ -46,7 +46,7 @@
     virtual ~Lambertian();
 
     virtual void shade(const RenderContext& context, RayPacket& rays) const;
-    void readwrite(Archive* archive);
+    void readwrite(ArchiveElement* archive);
   private:
     const Texture<Color>* colortex;
   };

Modified: branches/persistent/Model/Materials/LitMaterial.cc
==============================================================================
--- branches/persistent/Model/Materials/LitMaterial.cc  (original)
+++ branches/persistent/Model/Materials/LitMaterial.cc  Mon Sep 17 15:30:53 
2007
@@ -3,7 +3,7 @@
 #include <Interface/InterfaceClassInfo.h>
 #include <Interface/LightSet.h>
 #include <Interface/Context.h>
-#include <Core/Reflection/Archive.h>
+#include <Core/Persistent/ArchiveElement.h>
 
 using namespace Manta;
 
@@ -34,7 +34,7 @@
   REGISTER_CLASS(LitMaterial);
 }
 
-void LitMaterial::readwrite(Archive* archive)
+void LitMaterial::readwrite(ArchiveElement* archive)
 {
   ClassInfo<OpaqueShadower>::readwrite(archive, *this);
   archive->readwrite("localLights", localLights);

Modified: branches/persistent/Model/Materials/LitMaterial.h
==============================================================================
--- branches/persistent/Model/Materials/LitMaterial.h   (original)
+++ branches/persistent/Model/Materials/LitMaterial.h   Mon Sep 17 15:30:53 
2007
@@ -3,7 +3,7 @@
 #define Manta_Model_LitMaterial_h
 
 #include <Model/Materials/OpaqueShadower.h>
-#include <Core/Reflection/ClassInfo.h>
+#include <Core/Persistent/ClassInfo.h>
 
 namespace Manta {
   class LightSet;
@@ -15,7 +15,7 @@
 
     virtual void preprocess(const PreprocessContext&);
 
-    void readwrite(Archive* archive);
+    void readwrite(ArchiveElement* archive);
   protected:
     const LightSet* activeLights;
     LightSet* localLights;

Modified: branches/persistent/Model/Materials/MetalMaterial.cc
==============================================================================
--- branches/persistent/Model/Materials/MetalMaterial.cc        (original)
+++ branches/persistent/Model/Materials/MetalMaterial.cc        Mon Sep 17 
15:30:53 2007
@@ -1,8 +1,8 @@
 
 #include <Model/Materials/MetalMaterial.h>
 #include <Core/Math/ipow.h>
-#include <Core/Reflection/ClassInfo.h>
-#include <Core/Reflection/Archive.h>
+#include <Core/Persistent/ClassInfo.h>
+#include <Core/Persistent/ArchiveElement.h>
 #include <Interface/Context.h>
 #include <Interface/Light.h>
 #include <Interface/LightSet.h>
@@ -88,7 +88,7 @@
   REGISTER_CLASS(MetalMaterial);
 }
 
-void MetalMaterial::readwrite(Archive* archive)
+void MetalMaterial::readwrite(ArchiveElement* archive)
 {
   ClassInfo<LitMaterial>::readwrite(archive, *this);
   archive->readwrite("reflectance", specular_reflectance);

Modified: branches/persistent/Model/Materials/MetalMaterial.h
==============================================================================
--- branches/persistent/Model/Materials/MetalMaterial.h (original)
+++ branches/persistent/Model/Materials/MetalMaterial.h Mon Sep 17 15:30:53 
2007
@@ -19,7 +19,7 @@
     virtual ~MetalMaterial();
   
     virtual void shade(const RenderContext& context, RayPacket& rays) const;
-    void readwrite(Archive* archive);
+    void readwrite(ArchiveElement* archive);
   private:
     const Texture<Color>* specular_reflectance;
     int phong_exponent;

Modified: branches/persistent/Model/Materials/OpaqueShadower.h
==============================================================================
--- branches/persistent/Model/Materials/OpaqueShadower.h        (original)
+++ branches/persistent/Model/Materials/OpaqueShadower.h        Mon Sep 17 
15:30:53 2007
@@ -30,7 +30,7 @@
 */
 
 #include <Interface/Material.h>
-#include <Core/Reflection/ClassInfo.h>
+#include <Core/Persistent/ClassInfo.h>
 
 namespace Manta {
   

Modified: branches/persistent/Model/Primitives/Parallelogram.cc
==============================================================================
--- branches/persistent/Model/Primitives/Parallelogram.cc       (original)
+++ branches/persistent/Model/Primitives/Parallelogram.cc       Mon Sep 17 
15:30:53 2007
@@ -2,8 +2,8 @@
 #include <Model/Primitives/Parallelogram.h>
 #include <Interface/InterfaceClassInfo.h>
 #include <Interface/RayPacket.h>
-#include <Core/Reflection/Archive.h>
-#include <Core/Reflection/ClassInfo.h>
+#include <Core/Persistent/ArchiveElement.h>
+#include <Core/Persistent/ClassInfo.h>
 #include <Core/Geometry/BBox.h>
 #include <Core/Math/MiscMath.h>
 #include <MantaSSE.h>
@@ -555,7 +555,7 @@
   REGISTER_CLASS(Parallelogram);
 }
 
-void Parallelogram::readwrite(Archive* archive)
+void Parallelogram::readwrite(ArchiveElement* archive)
 {
   ClassInfo<PrimitiveCommon>::readwrite(archive, *this);
   ClassInfo<TexCoordMapper>::readwrite(archive, *this);

Modified: branches/persistent/Model/Primitives/Parallelogram.h
==============================================================================
--- branches/persistent/Model/Primitives/Parallelogram.h        (original)
+++ branches/persistent/Model/Primitives/Parallelogram.h        Mon Sep 17 
15:30:53 2007
@@ -7,7 +7,7 @@
 #include <Core/Geometry/Vector.h>
 
 namespace Manta {
-  class Archive;
+  class ArchiveElement;
 
   class Parallelogram : public PrimitiveCommon, public TexCoordMapper {
   public:
@@ -25,7 +25,7 @@
     virtual void computeTexCoords3(const RenderContext& context,
                                   RayPacket& rays) const;
 
-    void readwrite(Archive* archive);
+    void readwrite(ArchiveElement* archive);
   private:
     Vector anchor;
     Vector v1, v2;

Modified: branches/persistent/Model/Primitives/PrimitiveCommon.cc
==============================================================================
--- branches/persistent/Model/Primitives/PrimitiveCommon.cc     (original)
+++ branches/persistent/Model/Primitives/PrimitiveCommon.cc     Mon Sep 17 
15:30:53 2007
@@ -1,7 +1,7 @@
 
 #include <Model/Primitives/PrimitiveCommon.h>
-#include <Core/Reflection/Archive.h>
-#include <Core/Reflection/ClassInfo.h>
+#include <Core/Persistent/ArchiveElement.h>
+#include <Core/Persistent/ClassInfo.h>
 #include <Interface/Material.h>
 #include <Interface/InterfaceClassInfo.h>
 #include <Model/TexCoordMappers/UniformMapper.h>
@@ -72,7 +72,7 @@
   return success;
 }
 
-void PrimitiveCommon::readwrite(Archive* archive)
+void PrimitiveCommon::readwrite(ArchiveElement* archive)
 {
   ClassInfo<Primitive>::readwrite(archive, *this);
   archive->readwrite("material", material);

Modified: branches/persistent/Model/Primitives/PrimitiveCommon.h
==============================================================================
--- branches/persistent/Model/Primitives/PrimitiveCommon.h      (original)
+++ branches/persistent/Model/Primitives/PrimitiveCommon.h      Mon Sep 17 
15:30:53 2007
@@ -4,10 +4,10 @@
 
 #include <Interface/Interpolable.h>
 #include <Interface/Primitive.h>
-#include <Core/Reflection/ClassInfo.h>
+#include <Core/Persistent/ClassInfo.h>
 
 namespace Manta {
-  class Archive;
+  class ArchiveElement;
   class Material;
   class PrimitiveCommon : public Primitive {
   public:
@@ -32,7 +32,7 @@
     virtual InterpErr interpolate(const std::vector<keyframe_t> &keyframes);
 #endif
 
-    void readwrite(Archive* archive);
+    void readwrite(ArchiveElement* archive);
 
   private:
     Material* material;

Modified: branches/persistent/Model/Primitives/Sphere.cc
==============================================================================
--- branches/persistent/Model/Primitives/Sphere.cc      (original)
+++ branches/persistent/Model/Primitives/Sphere.cc      Mon Sep 17 15:30:53 
2007
@@ -5,8 +5,8 @@
 #include <Core/Math/Trig.h>
 #include <Core/Math/Expon.h>
 #include <Core/Math/SSEDefs.h>
-#include <Core/Reflection/Archive.h>
-#include <Core/Reflection/ClassInfo.h>
+#include <Core/Persistent/ArchiveElement.h>
+#include <Core/Persistent/ClassInfo.h>
 #include <Interface/RayPacket.h>
 #include <Interface/InterfaceClassInfo.h>
 #include <MantaSSE.h>
@@ -421,7 +421,7 @@
   REGISTER_CLASS(Sphere);
 }
 
-void Sphere::readwrite(Archive* archive)
+void Sphere::readwrite(ArchiveElement* archive)
 {
   ClassInfo<PrimitiveCommon>::readwrite(archive, *this);
   archive->readwrite("center", center);

Modified: branches/persistent/Model/Primitives/Sphere.h
==============================================================================
--- branches/persistent/Model/Primitives/Sphere.h       (original)
+++ branches/persistent/Model/Primitives/Sphere.h       Mon Sep 17 15:30:53 
2007
@@ -7,9 +7,9 @@
 #include <Core/Geometry/Vector.h>
 
 namespace Manta {
-  class Archive;
+  class ArchiveElement;
 
-  class Sphere : public PrimitiveCommon {
+  class Sphere : public PrimitiveCommon, public TexCoordMapper {
   public:
     Sphere();
     Sphere(Material* material, const Vector& center, Real radius);
@@ -39,7 +39,7 @@
       return radius;
     }
     
-    void readwrite(Archive* archive);
+    void readwrite(ArchiveElement* archive);
   private:
     Vector center;
     Real radius;

Modified: branches/persistent/Model/TexCoordMappers/UniformMapper.cc
==============================================================================
--- branches/persistent/Model/TexCoordMappers/UniformMapper.cc  (original)
+++ branches/persistent/Model/TexCoordMappers/UniformMapper.cc  Mon Sep 17 
15:30:53 2007
@@ -86,7 +86,7 @@
   REGISTER_CLASS(UniformMapper);
 };
 
-void UniformMapper::readwrite(Archive* archive)
+void UniformMapper::readwrite(ArchiveElement* archive)
 {
   ClassInfo<TexCoordMapper>::readwrite(archive, *this);
 }

Modified: branches/persistent/Model/TexCoordMappers/UniformMapper.h
==============================================================================
--- branches/persistent/Model/TexCoordMappers/UniformMapper.h   (original)
+++ branches/persistent/Model/TexCoordMappers/UniformMapper.h   Mon Sep 17 
15:30:53 2007
@@ -5,7 +5,7 @@
 #include <Interface/TexCoordMapper.h>
 
 namespace Manta {
-  class Archive;
+  class ArchiveElement;
 
   class UniformMapper : public TexCoordMapper {
   public:
@@ -17,7 +17,7 @@
     virtual void computeTexCoords3(const RenderContext& context,
                            RayPacket& rays) const;
 
-    void readwrite(Archive* archive);
+    void readwrite(ArchiveElement* archive);
   private:
     UniformMapper(const UniformMapper&);
     UniformMapper& operator=(const UniformMapper&);

Modified: branches/persistent/Model/Textures/CheckerTexture.h
==============================================================================
--- branches/persistent/Model/Textures/CheckerTexture.h (original)
+++ branches/persistent/Model/Textures/CheckerTexture.h Mon Sep 17 15:30:53 
2007
@@ -5,7 +5,7 @@
 #include <Interface/Texture.h>
 #include <Core/Color/Color.h>
 #include <Core/Geometry/Vector.h>
-#include <Core/Reflection/Archive.h>
+#include <Core/Persistent/ArchiveElement.h>
 #include <Interface/InterfaceClassInfo.h>
 #include <Interface/RayPacket.h>
 #include <MantaSSE.h>
@@ -23,7 +23,7 @@
     virtual ~CheckerTexture();
 
     virtual void mapValues(Packet<ValueType>&, const RenderContext& context, 
RayPacket& rays) const;
-    void readwrite(Archive* archive);
+    void readwrite(ArchiveElement* archive);
   private:
     CheckerTexture(const CheckerTexture&);
     CheckerTexture& operator=(const CheckerTexture&);
@@ -106,7 +106,7 @@
   typename ClassInfo<CheckerTexture<ValueType> >::Initializer 
ClassInfo<CheckerTexture<ValueType> >::init;
 
   template<class ValueType>
-  void CheckerTexture<ValueType>::readwrite(Archive* archive)
+  void CheckerTexture<ValueType>::readwrite(ArchiveElement* archive)
   {
     archive->readwrite("value1", values[0]);
     archive->readwrite("value2", values[1]);

Modified: branches/persistent/Model/Textures/Constant.h
==============================================================================
--- branches/persistent/Model/Textures/Constant.h       (original)
+++ branches/persistent/Model/Textures/Constant.h       Mon Sep 17 15:30:53 
2007
@@ -5,7 +5,7 @@
 #include <Interface/Texture.h>
 #include <Interface/RayPacket.h>
 #include <Interface/InterfaceClassInfo.h>
-#include <Core/Reflection/Archive.h>
+#include <Core/Persistent/ArchiveElement.h>
 #include <MantaSSE.h>
 
 namespace Manta {
@@ -24,7 +24,7 @@
     ValueType getValue() const { return value; }
     void setValue( const ValueType value_ ) { value = value_; }
 
-    void readwrite(Archive* archive);
+    void readwrite(ArchiveElement* archive);
   private:
     Constant(const Constant&);
     Constant& operator=(const Constant&);
@@ -76,7 +76,7 @@
   }
 
   template<class ValueType>
-  void Constant<ValueType>::readwrite(Archive* archive)
+  void Constant<ValueType>::readwrite(ArchiveElement* archive)
   {
     archive->readwrite("value", value);
   }

Modified: branches/persistent/StandAlone/savescene.cc
==============================================================================
--- branches/persistent/StandAlone/savescene.cc (original)
+++ branches/persistent/StandAlone/savescene.cc Mon Sep 17 15:30:53 2007
@@ -30,7 +30,8 @@
 #include <Core/Util/Args.h>
 #include <Core/Exceptions/IllegalArgument.h>
 #include <Core/Exceptions/OutputError.h>
-#include <Core/Reflection/Archive.h>
+#include <Core/Persistent/Archive.h>
+#include <Core/Persistent/ArchiveElement.h>
 #include <Engine/Factory/Factory.h>
 #include <Interface/MantaInterface.h>
 #include <Interface/InterfaceClassInfo.h>
@@ -90,11 +91,11 @@
     if(!archive)
       throw OutputError("Could not open Archive for writing: " + outfile);
     Scene* scene = rtrt->getScene();
-    archive->readwrite(0, scene);
+    ArchiveElement* root = archive->getRoot();
+    root->readwrite("scene", scene, Persistent::AnonymousField);
     delete archive;
     delete rtrt;
 
-    
   } catch (SCIRun::Exception& e) {
     cerr << "savescene.cc (top level): Caught SCIRun exception: " << 
e.message() << '\n';
     Thread::exitAll( 1 );

Modified: branches/persistent/TODO
==============================================================================
--- branches/persistent/TODO    (original)
+++ branches/persistent/TODO    Mon Sep 17 15:30:53 2007
@@ -1,4 +1,3 @@
-Fix tag names for templates values (is . legal?)
 instead of using precision 17, try different lengths of precision?  At least 
the default?
 Detect self references?
 Separate read for color (can read anything)
@@ -17,9 +16,6 @@
  - New point/vector? - templated on type and dimensionality
  - Nix vector2d...
  - circular dependency from rtrt master to UI - move UI in Engine???
- - mechanism to configure sci_defs files
- - build shared libraries
- - build scenes
  - configure threads/time classes properly
 
 Color:




  • [Manta] r1725 - in branches/persistent: . Core Core/Color Core/Geometry Core/Persistent Core/Reflection Engine/Factory Interface Model/AmbientLights Model/Backgrounds Model/Groups Model/Lights Model/Materials Model/Primitives Model/TexCoordMappers Model/Textures StandAlone, sparker, 09/17/2007

Archive powered by MHonArc 2.6.16.

Top of page