Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[Manta] r1791 - in branches/persistent: Core Core/Color Core/Geometry Core/Persistent 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] r1791 - in branches/persistent: Core Core/Color Core/Geometry Core/Persistent Engine/Factory Interface Model/AmbientLights Model/Backgrounds Model/Groups Model/Lights Model/Materials Model/Primitives Model/TexCoordMappers Model/Textures StandAlone
  • Date: Fri, 26 Oct 2007 11:34:40 -0600 (MDT)

Author: sparker
Date: Fri Oct 26 11:34:34 2007
New Revision: 1791

Added:
   branches/persistent/Core/Persistent/MantaRTTI.cc
   branches/persistent/Core/Persistent/MantaRTTI.h
      - copied, changed from r1735, 
branches/persistent/Core/Persistent/ClassInfo.h
   branches/persistent/Core/Persistent/stdRTTI.h
      - copied, changed from r1735, 
branches/persistent/Core/Persistent/stdClassInfo.h
   branches/persistent/Interface/InterfaceRTTI.cc
      - copied, changed from r1735, 
branches/persistent/Interface/InterfaceClassInfo.cc
   branches/persistent/Interface/InterfaceRTTI.h
      - copied, changed from r1735, 
branches/persistent/Interface/InterfaceClassInfo.h
Removed:
   branches/persistent/Core/Persistent/ClassInfo.h
   branches/persistent/Core/Persistent/XMLArchive.h
   branches/persistent/Core/Persistent/stdClassInfo.h
   branches/persistent/Interface/InterfaceClassInfo.cc
   branches/persistent/Interface/InterfaceClassInfo.h
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/ArchiveElement.cc
   branches/persistent/Core/Persistent/ArchiveElement.h
   branches/persistent/Core/Persistent/XMLArchive.cc
   branches/persistent/Engine/Factory/Factory.cc
   branches/persistent/Interface/CMakeLists.txt
   branches/persistent/Interface/Camera.cc
   branches/persistent/Interface/Camera.h
   branches/persistent/Interface/LightSet.cc
   branches/persistent/Interface/Scene.cc
   branches/persistent/Interface/Texture.h
   branches/persistent/Model/AmbientLights/ArcAmbient.cc
   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/Materials/Lambertian.cc
   branches/persistent/Model/Materials/LitMaterial.cc
   branches/persistent/Model/Materials/LitMaterial.h
   branches/persistent/Model/Materials/MetalMaterial.cc
   branches/persistent/Model/Materials/OpaqueShadower.cc
   branches/persistent/Model/Materials/OpaqueShadower.h
   branches/persistent/Model/Primitives/Parallelogram.cc
   branches/persistent/Model/Primitives/PrimitiveCommon.cc
   branches/persistent/Model/Primitives/PrimitiveCommon.h
   branches/persistent/Model/Primitives/Sphere.cc
   branches/persistent/Model/TexCoordMappers/UniformMapper.cc
   branches/persistent/Model/Textures/CheckerTexture.h
   branches/persistent/Model/Textures/Constant.h
   branches/persistent/StandAlone/savescene.cc
Log:
Major revamp of persistent i/o and rtti
Writes function completely for test cases and reads are 90% there (pointers 
not yet working)


Modified: branches/persistent/Core/CMakeLists.txt
==============================================================================
--- branches/persistent/Core/CMakeLists.txt     (original)
+++ branches/persistent/Core/CMakeLists.txt     Fri Oct 26 11:34:34 2007
@@ -62,12 +62,12 @@
      Persistent/Archive.cc
      Persistent/ArchiveElement.h
      Persistent/ArchiveElement.cc
-     Persistent/ClassInfo.h
+     Persistent/MantaRTTI.h
+     Persistent/MantaRTTI.cc
      )
 
 IF (LIBXML2_INCLUDE)
      SET (CORE_SOURCES ${CORE_SOURCES}
-          Persistent/XMLArchive.h
           Persistent/XMLArchive.cc
          )
      INCLUDE_DIRECTORIES(${LIBXML2_INCLUDE})

Modified: branches/persistent/Core/Color/ColorSpace.h
==============================================================================
--- branches/persistent/Core/Color/ColorSpace.h (original)
+++ branches/persistent/Core/Color/ColorSpace.h Fri Oct 26 11:34:34 2007
@@ -8,7 +8,7 @@
 #include <Core/Color/RGBTraits.h>
 #include <Core/Math/Expon.h>
 #include <Core/Persistent/ArchiveElement.h>
-#include <Core/Persistent/ClassInfo.h>
+#include <Core/Persistent/MantaRTTI.h>
 
 #include <sgi_stl_warnings_off.h>
 #include <sstream>
@@ -259,7 +259,7 @@
       for(int i=0;i<NumComponents;i++)
         data[i] = fillValue;
     }
-    friend class ClassInfo<ColorSpace<Traits> >;
+    friend class MantaRTTI<ColorSpace<Traits> >;
   };
 
   template<typename Traits, typename Scalar>
@@ -272,7 +272,10 @@
     }
 
   template<typename Traits>
-  class ClassInfo<ColorSpace<Traits> > {
+    class MantaRTTI<ColorSpace<Traits> >
+    : public MantaRTTI_ConcreteClass<ColorSpace<Traits> >,
+      public MantaRTTI_BaseClass<ColorSpace<Traits> >
+  {
   public:
     static std::string getPublicClassname() {
       return "Color";
@@ -294,7 +297,6 @@
         archive->readwrite("data", str);
         if(str[0] == '#'){
           // Parse html style hex string
-          int l = 0;
           std::string::size_type idx = 1;
           while(idx < str.size() && ((str[idx] >= '0' && str[idx] <= '9') || 
(str[idx] >= 'a' && str[idx] <= 'f') || (str[idx] >= 'A' && str[idx] <= 'F')))
             idx++;
@@ -338,8 +340,8 @@
         Traits::readwrite(archive, data.data);
       }
     }
-    static Persistent::StorageHint storageHint() {
-      return Persistent::LightweightObject;
+    static PersistentStorage::StorageHint storageHint() {
+      return PersistentStorage::Lightweight;
     }
     static bool force_initialize;
   };

Modified: branches/persistent/Core/Color/RGBTraits.cc
==============================================================================
--- branches/persistent/Core/Color/RGBTraits.cc (original)
+++ branches/persistent/Core/Color/RGBTraits.cc Fri Oct 26 11:34:34 2007
@@ -1,11 +1,15 @@
 
 #include <Core/Color/RGBTraits.h>
+#include <Core/Color/ColorSpace.h>
 #include <Core/Persistent/ArchiveElement.h>
 #include <sstream>
 #include <iomanip>
 
 using namespace Manta;
 using namespace std;
+
+template<>
+bool MantaRTTI<ColorSpace<RGBTraits> >::force_initialize = 
MantaRTTI<ColorSpace<RGBTraits> >::registerClass("Color");
 
 void RGBTraits::readwrite(ArchiveElement* archive, ComponentType data[3])
 {

Modified: branches/persistent/Core/Color/RGBTraits.h
==============================================================================
--- branches/persistent/Core/Color/RGBTraits.h  (original)
+++ branches/persistent/Core/Color/RGBTraits.h  Fri Oct 26 11:34:34 2007
@@ -4,7 +4,7 @@
 
 #include <Core/Color/RGBColor.h>
 #include <Core/Color/Conversion.h>
-#include <Core/Persistent/ClassInfo.h>
+#include <Core/Persistent/MantaRTTI.h>
 
 namespace Manta {
   class ArchiveElement;

Modified: branches/persistent/Core/Geometry/Vector.cc
==============================================================================
--- branches/persistent/Core/Geometry/Vector.cc (original)
+++ branches/persistent/Core/Geometry/Vector.cc Fri Oct 26 11:34:34 2007
@@ -52,7 +52,7 @@
   }
 }
 
-REGISTER_CLASS(Vector);
+MANTA_REGISTER_CLASS(Vector);
 
 void Vector::readwrite(ArchiveElement* archive)
 {

Modified: branches/persistent/Core/Geometry/Vector.h
==============================================================================
--- branches/persistent/Core/Geometry/Vector.h  (original)
+++ branches/persistent/Core/Geometry/Vector.h  Fri Oct 26 11:34:34 2007
@@ -42,7 +42,7 @@
 #include <Core/Math/Expon.h>
 #include <Core/Math/MinMax.h>
 #include <Core/Math/MiscMath.h>
-#include <Core/Persistent/ClassInfo.h>
+#include <Core/Persistent/MantaRTTI.h>
 
 #include <sgi_stl_warnings_off.h>
 #include <iosfwd>
@@ -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_lightweight);
+  MANTA_DECLARE_RTTI_BASECLASS(Vector, ConcreteClass, 
readwriteMethod_lightweight);
 }
 
 namespace SCIRun {

Modified: branches/persistent/Core/Persistent/ArchiveElement.cc
==============================================================================
--- branches/persistent/Core/Persistent/ArchiveElement.cc       (original)
+++ branches/persistent/Core/Persistent/ArchiveElement.cc       Fri Oct 26 
11:34:34 2007
@@ -18,3 +18,7 @@
 {
 }
 
+ArchiveElement::PointerWrapper::~PointerWrapper()
+{
+}
+

Modified: branches/persistent/Core/Persistent/ArchiveElement.h
==============================================================================
--- branches/persistent/Core/Persistent/ArchiveElement.h        (original)
+++ branches/persistent/Core/Persistent/ArchiveElement.h        Fri Oct 26 
11:34:34 2007
@@ -2,13 +2,16 @@
 #ifndef Manta_ArchiveElement_h
 #define Manta_ArchiveElement_h
 
-#include <Core/Persistent/ClassInfo.h>
+#include <Core/Persistent/MantaRTTI.h>
 #include <Core/Exceptions/SerializationError.h>
+#include <Core/Util/NotFinished.h>
 #include <string>
 #include <typeinfo>
 
 namespace Manta {
   class ArchiveElement {
+  protected:
+    class PointerWrapper;
   public:
     bool reading() const {
       return isreading;
@@ -18,149 +21,146 @@
     }
 
     template<class T>
-      void readwrite(const std::string& fieldname, T& data, 
Persistent::StorageHint hint = Persistent::Default);
+      void readwrite(const std::string& fieldname, T& data);
     template<class T>
-      void readwrite(const std::string& fieldname, T*& data, 
Persistent::StorageHint hint = Persistent::Default);
+      void readwrite(const std::string& fieldname, T*& data);
     template<class T>
-      void readwrite(const std::string& fieldname, const T*& data, 
Persistent::StorageHint hint = Persistent::Default);
+      void readwrite(const std::string& fieldname, const T*& data);
 
-    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;
+    virtual void readwrite(const std::string& fieldname, bool& data) = 0;
+    virtual void readwrite(const std::string& fieldname, double& data) = 0;
+    virtual void readwrite(const std::string& fieldname, float& data) = 0;
+    virtual void readwrite(const std::string& fieldname, float* data, int 
numElements) = 0;
+    virtual void readwrite(const std::string& fieldname, int& data) = 0;
+    virtual void readwrite(const std::string& fieldname, std::string& data) 
= 0;
 
-    virtual ArchiveElement* firstChild() = 0;
-    virtual ArchiveElement* nextChild() = 0;
+    virtual bool nextContainerElement() = 0;
   protected:
-    virtual ArchiveElement* findObject(const std::string& fieldname,
-                                       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 void readwrite(const std::string& fieldname, PointerWrapper& 
ptr, bool isPointer) = 0;
 
     virtual ~ArchiveElement();
     ArchiveElement(bool isreading);
     bool isreading;
-  private:
+
+    class PointerWrapper {
+    public:
+      virtual ~PointerWrapper();
+
+      virtual bool isNull() const = 0;
+      virtual void setNull() = 0;
+      virtual bool createObject(const std::string& classname) = 0;
+      virtual bool copyPointer(PointerWrapper* copy) = 0;
+      virtual void* getUniqueID() const = 0;
+      virtual void readwrite(ArchiveElement*) = 0;
+      virtual const GenericRTTIInterface* getRTTI() const = 0;
+      virtual PointerWrapper* clone() const = 0;
+    };
+
+    template<class T>
+    class ConcretePointerWrapper : public PointerWrapper {
+    public:
+    ConcretePointerWrapper(T* data, const ClassRTTIInterface<T>* rtti) 
+      : data(data), rtti(rtti) {
+      }
+      virtual ~ConcretePointerWrapper() {}
+      T* getData() const {
+        return data;
+      }
+
+      bool isNull() const {
+        return data == 0;
+      }
+      void setNull() {
+        data = 0;
+      }
+      virtual bool createObject(const std::string& classname) {
+        ClassRTTIInterface<T>* new_rtti = ClassIndex<T>::getRTTI(classname);
+        if(!new_rtti)
+          return false;
+        data = new_rtti->createInstance();
+        if(!data)
+          return false;
+        rtti = new_rtti;
+        return true;
+      }
+      virtual bool copyPointer(PointerWrapper* copy) {
+        NOT_FINISHED("copyPointer");
+        return false;
+      }
+      virtual void* getUniqueID() const {
+        // This will cast it to the most derived class and return the void* 
equivalent.
+        // This ensures that the pointer will be unique.
+        return rtti->getPointerValue(data);
+      }
+      virtual void readwrite(ArchiveElement* element) {
+        rtti->readwrite(element, data);
+      }
+      virtual const GenericRTTIInterface* getRTTI() const {
+        return rtti;
+      }
+      virtual ConcretePointerWrapper<T>* clone() const {
+        return new ConcretePointerWrapper(data, rtti);
+      }
+    private:
+      T* data;
+      const ClassRTTIInterface<T>* rtti;
+    };
 
   };
 
   template<class T>
-  void ArchiveElement::readwrite(const std::string& fieldname, T& data, 
Persistent::StorageHint instancehint)
+  void ArchiveElement::readwrite(const std::string& fieldname, T& data)
   {
     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, classname, 
classhint, instancehint);
-      if(!subelement)
-        throw SerializationError("Cannot find field: " + 
std::string(fieldname) + " of type " + typeid(T).name());
-
-      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;
+    ClassRTTIInterface<T>* rtti = ClassIndex<T>::getRTTI(typeid(T));
+    if(!rtti){
+      std::string baseclassname = MantaRTTI<T>::getPublicClassname();
+      std::string derivedclassname = typeid(data).name();
+      throw SerializationError("Class: " + derivedclassname + " is not a 
known subclass of " + baseclassname + "(probably missing RTTI information)");
     }
+    ConcretePointerWrapper<T> ptr(&data, rtti);
+    readwrite(fieldname, ptr, false);
   }
 
 
   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,
-                                                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){
-          dbentry = ClassDatabase<T>::getEntry(typeid(T));
-          if(classname == dbentry->getPublicClassname())
-            throw SerializationError("Class: " + classname + " does not have 
persistent object information");
-          else
-            throw SerializationError("Class: " + classname + " is not a 
known subclass of " + dbentry->getPublicClassname());
-        }
-        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;
-        }
-      }
+  void ArchiveElement::readwrite(const std::string& fieldname, T*& data)
+  {
+    ClassRTTIInterface<T>* rtti;
+    if(reading() || !data)
+      rtti = ClassIndex<T>::getRTTI(typeid(T));
+    else
+      rtti = ClassIndex<T>::getRTTI(typeid(*data));
+    if(!rtti){
+      std::string baseclassname = MantaRTTI<T>::getPublicClassname();
+      std::string derivedclassname = typeid(*data).name();
+      throw SerializationError("Class: " + derivedclassname + " is not a 
known subclass of " + baseclassname + "(probably missing RTTI information)");
     }
+    ConcretePointerWrapper<T> ptr(data, rtti);
+    readwrite(fieldname, ptr, true);
+    if(reading())
+      data = ptr.getData();
   }
 
   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);
+  void ArchiveElement::readwrite(const std::string& fieldname, const T*& 
data) {
+    T* tmp = const_cast<T*>(data);
+    ClassRTTIInterface<T>* rtti;
+    if(reading() || !tmp)
+      rtti = ClassIndex<T>::getRTTI(typeid(T));
+    else
+      rtti = ClassIndex<T>::getRTTI(typeid(*tmp));
+    if(!rtti){
+      std::string baseclassname = MantaRTTI<T>::getPublicClassname();
+      std::string derivedclassname = typeid(*tmp).name();
+      throw SerializationError("Class: " + derivedclassname + " is not a 
known subclass of " + baseclassname + "(probably missing RTTI information)");
     }
+    ConcretePointerWrapper<T> ptr(tmp, rtti);
+    readwrite(fieldname, ptr, true);
+    if(reading())
+      data = ptr.getData();
   }
 
 }//namespace

Added: branches/persistent/Core/Persistent/MantaRTTI.cc
==============================================================================
--- (empty file)
+++ branches/persistent/Core/Persistent/MantaRTTI.cc    Fri Oct 26 11:34:34 
2007
@@ -0,0 +1,8 @@
+
+#include <Core/Persistent/MantaRTTI.h>
+
+using namespace Manta;
+
+GenericRTTIInterface::~GenericRTTIInterface()
+{
+}

Copied: branches/persistent/Core/Persistent/MantaRTTI.h (from r1735, 
branches/persistent/Core/Persistent/ClassInfo.h)
==============================================================================
--- branches/persistent/Core/Persistent/ClassInfo.h     (original)
+++ branches/persistent/Core/Persistent/MantaRTTI.h     Fri Oct 26 11:34:34 
2007
@@ -1,10 +1,9 @@
 
-#ifndef Manta_Reflection_h
-#define Manta_Reflection_h
+#ifndef Manta_MantaRTTI_h
+#define Manta_MantaRTTI_h
 
 #include <Core/Exceptions/SerializationError.h>
 #include <Core/Exceptions/InternalError.h>
-#include <Core/Util/NotFinished.h>
 #include <map>
 #include <string>
 #include <typeinfo>
@@ -12,98 +11,170 @@
 namespace Manta {
   class ArchiveElement;
 
-  class Persistent {
+  /**
+   * Degenerate class to specify hints to contain an enum that
+   * provides hints to the persistent storage facility about how
+   * an object should be stored.
+   *   Default: use a hierchical mechanism
+   *   Container: the object is a container and does not need type 
information.
+   *   Lightweight: the object is a small class that could be inlined.
+   */
+  class PersistentStorage {
   public:
     enum StorageHint {
-      Default, ContainerObject, LightweightObject, AnonymousField, 
SimpleObject
+      Default, Container, Lightweight
     };
   private:
-    Persistent();
+    PersistentStorage();
   };
 
-  // This class should always be specialized.  If you see an error
-  // here, you need to define the specialization for the class
+  /**
+   * The MantaRTTI<T> class is templated over all types that can be
+   * used with the persistent I/O capability.  These classes are never
+   * instantiated.  It should implement several static methods,
+   * including the following:
+   *
+   * // Return a human readable string that indicated the name of the
+   * // class
+   * string getPublicClassname();
+   *
+   *  // Create an empty instance of the class using the new operator
+   *  T* createInstance();
+   *
+   *  // Recursively serialize/deserialize the object into the given
+   *  // record
+   *  void readwrite(ArchiveElement*, T&);
+   * 
+   * These methods can often be provided by the default classes below
+   * that provide standard implementations by making the
+   * specialization inherit from the default implementation class.
+   * Macros are provided to further simplify this for most classes.
+   *
+   * The constructor for these classes should take no arguments.
+   * Instances of it are held by the ClassIndex class that indexes all
+   * of the children of a given type.
+   *
+   * This class should always be specialized.  If you see an error
+   * here, you need to define the specialization for the class.
+   */
   template<class T>
-  class ClassInfo {
+  class MantaRTTI {
     char force_error[0];
   private:
-    // If you get a compile error here complaining about private scope then 
you likely
-    // do have the specialized ClassInfo defined for the parent, or you have 
not included it
-    // in the current compilation unit
+    /*
+     * If you get a compile error here complaining about private scope
+     * then you likely do have the specialized MantaRTTI defined for
+     * the parent, or you have not included it in the current
+     * compilation unit
+     */
     template<class C>
       static void registerClassAndParents(const std::string& classname);
   };
 
-  template<class T>
-  class ClassDatabase {
-  public:
-    class Entry {
-    public:
-      virtual ~Entry() {}
-      virtual T* createInstance() const = 0;
-      virtual std::string getPublicClassname() 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;
-    };
-
+  /**
+   * This is the interface to dynamic RTTI.  Use the ClassIndex below to get
+   * instances of this given a classname or a typeid.  Functionality is 
limited
+   * but this can operate on any class type.
+   */
+  class GenericRTTIInterface {
+  public:
+    virtual ~GenericRTTIInterface();
+    virtual std::string getPublicClassname() const = 0;
+    virtual PersistentStorage::StorageHint storageHint() const = 0;
+    virtual const std::type_info& get_typeinfo() const = 0;
+  };
+
+  /**
+   * This is the interface to dynamic RTTI for types derived from the given 
Base.
+   * In addition to the capabilities of the GenericRTTIInterface, you can
+   * create instances of a class, trigger persistent I/O and get a unique
+   * pointer value.  Use the ClassIndex below to get an instance of this
+   * interface.
+   */
+  template<class Base> class ClassRTTIInterface : public 
GenericRTTIInterface {
+  public:
+    virtual ~ClassRTTIInterface() {}
+    virtual Base* createInstance() const = 0;
+    virtual void readwrite(ArchiveElement* archive, Base* ptr) const = 0;
+    virtual void* getPointerValue(Base* ptr) const = 0;
+  };
+
+  /**
+   * This class indexes MantaRTTI information for all of the known subclasses
+   * of a particular class.  For example, for the following classes:
+   * class A {};
+   * class B : public A {};
+   * class C : public B {};
+   * There will be three different index classes, ClassIndex<A> will contain
+   * records for A, B, and C, ClassIndex<B> will contain records for B and C,
+   * and C will contain a record only for C.
+   *
+   * This provides access to the MantaRTTI information through an
+   * abstract interface.  This design avoids the need to require virtual
+   * functions in the class.
+   */
+  template<class Base>
+  class ClassIndex {
   private:
-    template<class Class>
-    class ConcreteEntry : public Entry {
+    template<class Derived>
+    class Entry : public ClassRTTIInterface<Base> {
     public:
-      virtual ~ConcreteEntry() {}
-      virtual T* createInstance() const {
-        return ClassInfo<Class>::createInstance();
-      }
+      virtual ~Entry() {}
       virtual std::string getPublicClassname() const {
-        return ClassInfo<Class>::getPublicClassname();
+        return MantaRTTI<Derived>::getPublicClassname();
+      }
+      virtual PersistentStorage::StorageHint storageHint() const {
+        return MantaRTTI<Derived>::storageHint();
+      }
+      virtual const std::type_info& get_typeinfo() const {
+        return typeid(Derived);
+      }
+      virtual Derived* createInstance() const {
+        return MantaRTTI<Derived>::createInstance();
       }
-      virtual void readwrite(ArchiveElement* archive, T* ptr) const {
-        Class* derivedptr = dynamic_cast<Class*>(ptr);
+      virtual void readwrite(ArchiveElement* archive, Base* ptr) const {
+        Derived* derivedptr = dynamic_cast<Derived*>(ptr);
         if(!derivedptr){
-          std::string n1 = typeid(T).name();
-          std::string n2 = typeid(Class).name();
-          throw SCIRun::InternalError("failed dynamic cast from " + n1 + " 
to " + n2 + " in ClassDatabase(should not fail)",
+          std::string n1 = typeid(Derived).name();
+          std::string n2 = typeid(Base).name();
+          throw SCIRun::InternalError("failed dynamic cast from " + n1 + " 
to " + n2 + " in ClassIndex(should not fail)",
                                       __FILE__, __LINE__);
         }
-        ClassInfo<Class>::readwrite(archive, *derivedptr);
-      }
-      virtual const std::type_info& get_typeinfo() const {
-        return typeid(Class);
+        MantaRTTI<Derived>::readwrite(archive, *derivedptr);
       }
-      virtual void* getPointerValue(T* ptr) const {
-        Class* derivedptr = dynamic_cast<Class*>(ptr);
+      virtual void* getPointerValue(Base* ptr) const {
+        Derived* derivedptr = dynamic_cast<Derived*>(ptr);
         return static_cast<void*>(derivedptr);
       }
     };
-
   public:
-    template<class C>
+
+    template<class Derived>
     static void registerClass(const std::string& name) {
-      ClassDatabase<T>* db = singleton();
-      ConcreteEntry<C>* entry = new ConcreteEntry<C>();
+      ClassIndex<Base>* db = singleton();
+      Entry<Derived>* entry = new Entry<Derived>();
       std::pair<typename namedb_type::iterator, bool> result;
-      result = db->database_publicname.insert(typename 
namedb_type::value_type(name, entry));
+      result = db->index.insert(typename namedb_type::value_type(name, 
entry));
 
       if(result.second){
         // Duplicate entry
         const std::type_info& ti = result.first->second->get_typeinfo();
-        if(ti != typeid(C)){
-          std::string n1 = typeid(C).name();
+        if(ti != typeid(Derived)){
+          std::string n1 = typeid(Derived).name();
           std::string n2 = ti.name();
           throw SCIRun::InternalError("Distinct types (" + n1 + " and " + n2 
+ ") registered under the same public classname (" + name + ")",
                                       __FILE__, __LINE__);
         }
       }
 
-      std::pair<typename typedb_type::iterator, bool> result2;
-      result2 = db->database_typeinfoname.insert(typename 
typedb_type::value_type(entry->get_typeinfo().name(), entry));
+      std::pair<typename namedb_type::iterator, bool> result2;
+      result2 = db->index.insert(typename 
namedb_type::value_type(entry->get_typeinfo().name(), entry));
 
       if(result2.second){
         // Duplicate entry
         const std::type_info& ti = result.first->second->get_typeinfo();
-        if(ti != typeid(C)){
-          std::string n1 = typeid(C).name();
+        if(ti != typeid(Derived)){
+          std::string n1 = typeid(Derived).name();
           std::string n2 = ti.name();
           throw SCIRun::InternalError("Distinct types (" + n1 + " and " + n2 
+ ") registered under the same C++ type name (" + name + ")",
                                       __FILE__, __LINE__);
@@ -111,107 +182,103 @@
       }
     }
 
-    static Entry* getEntry(const std::string& name) {
-      return singleton()->_getEntry(name);
+    static ClassRTTIInterface<Base>* getRTTI(const std::string& name) {
+      return singleton()->lookupEntry(name);
     }
-    static Entry* getEntry(const std::type_info& ti){
-      return singleton()->_getEntry(ti);
+    static ClassRTTIInterface<Base>* getRTTI(const std::type_info& ti){
+      return singleton()->lookupEntry(ti);
     }
 
-    virtual std::string getPublicClassname() const {
-      return _getEntry(typeid(T))->getPublicClassname();
+    std::string getPublicClassname() const {
+      return lookupEntry(typeid(Base))->getPublicClassname();
     }
-
   private:
-    static ClassDatabase<T>* singleton() {
+    static ClassIndex<Base>* singleton() {
       if(!singleton_instance)
-        singleton_instance = new ClassDatabase<T>();
+        singleton_instance = new ClassIndex<Base>();
       return singleton_instance;
     }
-    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())
+    ClassRTTIInterface<Base>* lookupEntry(const std::string& name) const {
+      typename std::map<std::string, 
ClassRTTIInterface<Base>*>::const_iterator iter = index.find(name);
+      if(iter == index.end())
         return 0;
       return iter->second;
     }
-    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())
+    ClassRTTIInterface<Base>* lookupEntry(const std::type_info& ti) const {
+      typename std::map<std::string, 
ClassRTTIInterface<Base>*>::const_iterator iter = index.find(ti.name());
+      if(iter == index.end())
         return 0;
       return iter->second;
     }
 
-    static ClassDatabase<T>* singleton_instance;
-    typedef std::map<std::string, Entry*> namedb_type;
-    namedb_type database_publicname;
-    typedef std::map<const char*, Entry*> typedb_type;
-    typedb_type database_typeinfoname;
+    static ClassIndex<Base>* singleton_instance;
+    typedef std::map<std::string, ClassRTTIInterface<Base>*> namedb_type;
+    namedb_type index;
   };
 
-  template<class T>
-  ClassDatabase<T>* ClassDatabase<T>::singleton_instance;
-
+  template<class Class>
+  ClassIndex<Class>* ClassIndex<Class>::singleton_instance;
 
-  // Helper classes for implementing ClassInfo specializations
+  // Helper classes for implementing MantaRTTI specializations
   template<class T>
-  class ClassInfo_readwriteMethod {
+  class MantaRTTI_readwriteMethod {
   public:
     static void readwrite(ArchiveElement* archive, T& data) {
       data.readwrite(archive);
     }
-    static Persistent::StorageHint storageHint() {
-      return Persistent::Default;
+    static PersistentStorage::StorageHint storageHint() {
+      return PersistentStorage::Default;
     }
   private:
-    ClassInfo_readwriteMethod();
+    MantaRTTI_readwriteMethod();
   };
 
   template<class T>
-  class ClassInfo_readwriteMethod_lightweight {
+  class MantaRTTI_readwriteMethod_lightweight {
   public:
     static void readwrite(ArchiveElement* archive, T& data) {
       data.readwrite(archive);
     }
-    static Persistent::StorageHint storageHint() {
-      return Persistent::LightweightObject;
+    static PersistentStorage::StorageHint storageHint() {
+      return PersistentStorage::Lightweight;
     }
   private:
-    ClassInfo_readwriteMethod_lightweight();
+    MantaRTTI_readwriteMethod_lightweight();
   };
 
   template<class T>
-  class ClassInfo_readwriteNone {
+  class MantaRTTI_readwriteNone {
   public:
     static void readwrite(ArchiveElement* archive, T& data) {
     }
-    static Persistent::StorageHint storageHint() {
-      return Persistent::Default;
+    static PersistentStorage::StorageHint storageHint() {
+      return PersistentStorage::Default;
     }
   private:
-    ClassInfo_readwriteNone();
+    MantaRTTI_readwriteNone();
   };
 
   template<class T>
-  class ClassInfo_ConcreteClass {
+  class MantaRTTI_ConcreteClass {
   public:
     static T* createInstance() {
       return new T();
     }
   private:
-    ClassInfo_ConcreteClass();
+    MantaRTTI_ConcreteClass();
   };
   template<class T>
-  class ClassInfo_AbstractClass {
+  class MantaRTTI_AbstractClass {
   public:
     static T* createInstance() {
       return 0;
     }
   private:
-    ClassInfo_AbstractClass();
+    MantaRTTI_AbstractClass();
   };
 
   template<class T>
-  class ClassInfo_BaseClass {
+  class MantaRTTI_BaseClass {
   public:
     static std::string getPublicClassname() {
       if(!classname){
@@ -223,20 +290,16 @@
 
     template<class C>
     static void registerClassAndParents(const std::string& classname) {
-      ClassDatabase<T>::template registerClass<C>(classname);
-    }
-
-    static bool isSimpleContainer() {
-      return false;
+      ClassIndex<T>::template registerClass<C>(classname);
     }
   private:
-    ClassInfo_BaseClass();
+    MantaRTTI_BaseClass();
     static std::string* classname;
   };
-  template<class T> std::string* ClassInfo_BaseClass<T>::classname;
+  template<class T> std::string* MantaRTTI_BaseClass<T>::classname;
 
   template<class T, class Parent>
-  class ClassInfo_DerivedClass {
+  class MantaRTTI_DerivedClass {
   public:
     static std::string getPublicClassname() {
       if(!classname)
@@ -247,30 +310,27 @@
 
     template<class C>
     static void registerClassAndParents(const std::string& classname) {
-      ClassDatabase<T>::template registerClass<C>(classname);
-      ClassInfo<Parent>::template registerClassAndParents<C>(classname);
-    }
-    static bool isSimpleContainer() {
-      return false;
+      ClassIndex<T>::template registerClass<C>(classname);
+      MantaRTTI<Parent>::template registerClassAndParents<C>(classname);
     }
   private:
-    ClassInfo_DerivedClass();
+    MantaRTTI_DerivedClass();
     // This is a string* instead of a string to avoid initialization order 
issues
     static std::string* classname;
   };
-  template<class T, class Parent> std::string* ClassInfo_DerivedClass<T, 
Parent>::classname;
+  template<class T, class Parent> std::string* MantaRTTI_DerivedClass<T, 
Parent>::classname;
 
   template<class T, class Parent>
-    bool ClassInfo_DerivedClass<T, Parent>::registerClass(const std::string& 
_classname)
+    bool MantaRTTI_DerivedClass<T, Parent>::registerClass(const std::string& 
_classname)
   {
     if(!classname)
       classname = new std::string(_classname);
     registerClassAndParents<T>(_classname);
-    return true;
+    return MantaRTTI<Parent>::force_initialize;
   }
 
   template<class T, class Parent1, class Parent2>
-  class ClassInfo_DerivedClass2 {
+  class MantaRTTI_DerivedClass2 {
   public:
     static std::string getPublicClassname() {
       if(!classname)
@@ -281,31 +341,28 @@
 
     template<class C>
     static void registerClassAndParents(const std::string& classname) {
-      ClassDatabase<T>::template registerClass<C>(classname);
-      ClassInfo<Parent1>::template registerClassAndParents<C>(classname);
-      ClassInfo<Parent2>::template registerClassAndParents<C>(classname);
-    }
-    static bool isSimpleContainer() {
-      return false;
+      ClassIndex<T>::template registerClass<C>(classname);
+      MantaRTTI<Parent1>::template registerClassAndParents<C>(classname);
+      MantaRTTI<Parent2>::template registerClassAndParents<C>(classname);
     }
   private:
-    ClassInfo_DerivedClass2();
+    MantaRTTI_DerivedClass2();
     // This is a string* instead of a string to avoid initialization order 
issues
     static std::string* classname;
   };
-  template<class T, class Parent1, class Parent2> std::string* 
ClassInfo_DerivedClass2<T, Parent1, Parent2>::classname;
+  template<class T, class Parent1, class Parent2> std::string* 
MantaRTTI_DerivedClass2<T, Parent1, Parent2>::classname;
 
   template<class T, class Parent1, class Parent2>
-    bool ClassInfo_DerivedClass2<T, Parent1, Parent2>::registerClass(const 
std::string& _classname)
+    bool MantaRTTI_DerivedClass2<T, Parent1, Parent2>::registerClass(const 
std::string& _classname)
   {
     if(!classname)
       classname = new std::string(_classname);
     registerClassAndParents<T>(_classname);
-    return true;
+    return MantaRTTI<Parent1>::force_initialize | 
MantaRTTI<Parent2>::force_initialize;
   }
 
   template<class T>
-  bool ClassInfo_BaseClass<T>::registerClass(const std::string& _classname)
+  bool MantaRTTI_BaseClass<T>::registerClass(const std::string& _classname)
   {
     if(!classname)
       classname = new std::string(_classname);
@@ -314,7 +371,7 @@
   }
 
   template<>
-  class ClassInfo<float> {
+  class MantaRTTI<float> {
   public:
     static std::string getPublicClassname() {
       return "float";
@@ -323,35 +380,38 @@
 }
 
 // Convenience macros
-#define DECLARE_CLASSINFO_DERIVEDCLASS(declclass, baseclass, classtype, 
rwtype)  \
+#define MANTA_DECLARE_RTTI_DERIVEDCLASS(declclass, baseclass, classtype, 
rwtype)  \
 template<>\
-class ClassInfo<declclass> : public ClassInfo_DerivedClass<declclass, 
baseclass>, \
-                             public ClassInfo_##classtype<declclass>, \
-                             public ClassInfo_##rwtype<declclass> \
+class MantaRTTI<declclass> : public MantaRTTI_DerivedClass<declclass, 
baseclass>, \
+                             public MantaRTTI_##classtype<declclass>, \
+                             public MantaRTTI_##rwtype<declclass> \
 { \
+ public: \
   static bool force_initialize; \
 }
 
-#define DECLARE_CLASSINFO_DERIVEDCLASS2(declclass, baseclass1, baseclass2, 
classtype, rwtype) \
+#define MANTA_DECLARE_RTTI_DERIVEDCLASS2(declclass, baseclass1, baseclass2, 
classtype, rwtype) \
 template<>\
-class ClassInfo<declclass> : public ClassInfo_DerivedClass2<declclass, 
baseclass1, baseclass2>, \
-                             public ClassInfo_##classtype<declclass>, \
-                             public ClassInfo_##rwtype<declclass> \
+class MantaRTTI<declclass> : public MantaRTTI_DerivedClass2<declclass, 
baseclass1, baseclass2>, \
+                             public MantaRTTI_##classtype<declclass>, \
+                             public MantaRTTI_##rwtype<declclass> \
 { \
+ public: \
   static bool force_initialize; \
 }
 
-#define DECLARE_CLASSINFO_BASECLASS(declclass, classtype, rwtype)  \
+#define MANTA_DECLARE_RTTI_BASECLASS(declclass, classtype, rwtype)  \
 template<>\
-class ClassInfo<declclass> : public ClassInfo_BaseClass<declclass>, \
-                             public ClassInfo_##classtype<declclass>, \
-                             public ClassInfo_##rwtype<declclass> \
+class MantaRTTI<declclass> : public MantaRTTI_BaseClass<declclass>, \
+                             public MantaRTTI_##classtype<declclass>, \
+                             public MantaRTTI_##rwtype<declclass> \
 { \
+ public: \
   static bool force_initialize; \
 }
 
 
-#define REGISTER_CLASS(classname) \
-bool ClassInfo<classname>::force_initialize = 
ClassInfo<classname>::registerClass(#classname)
+#define MANTA_REGISTER_CLASS(classname) \
+bool MantaRTTI<classname>::force_initialize = 
MantaRTTI<classname>::registerClass(#classname)
 
 #endif

Modified: branches/persistent/Core/Persistent/XMLArchive.cc
==============================================================================
--- branches/persistent/Core/Persistent/XMLArchive.cc   (original)
+++ branches/persistent/Core/Persistent/XMLArchive.cc   Fri Oct 26 11:34:34 
2007
@@ -1,20 +1,85 @@
 
-#include <Core/Persistent/XMLArchive.h>
+#include <Core/Persistent/Archive.h>
 #include <Core/Persistent/ArchiveElement.h>
 #include <Core/Exceptions/InputError.h>
 #include <Core/Exceptions/SerializationError.h>
+#include <Core/Util/NotFinished.h>
 #include <libxml/parser.h>
+#include <libxml/tree.h>
+#include <map>
 #include <sstream>
+#include <string>
 
 using namespace Manta;
 using namespace std;
 
-inline
+namespace /* Anonymous */ {
+  struct RefInfo {
+    xmlNodePtr node;
+    std::string refname;
+    int useCount;
+  };
+  class XMLArchive;
+
+  class XMLArchiveElement : public ArchiveElement {
+  public:
+    enum ElementType {
+      RootElement, NormalElement, TagElement, UsedTagElement, 
ContainerElement
+    };
+    XMLArchiveElement(XMLArchive* archive, xmlNodePtr node, ElementType 
element_type);
+    XMLArchiveElement(XMLArchive* archive, xmlNodePtr node, const 
std::string& tagname);
+    virtual ~XMLArchiveElement();
+
+    virtual void readwrite(const std::string& fieldname, bool& data);
+    virtual void readwrite(const std::string& fieldname, double& data);
+    virtual void readwrite(const std::string& fieldname, float& data);
+    virtual void readwrite(const std::string& fieldname, float* data, int 
numElements);
+    virtual void readwrite(const std::string& fieldname, int& data);
+    virtual void readwrite(const std::string& fieldname, std::string& data);
+
+    virtual void readwrite(const std::string& fieldname, PointerWrapper& 
ptr, bool isPointer);
+
+    virtual bool nextContainerElement();
+
+    typedef std::map<std::string, XMLArchiveElement::PointerWrapper*> 
pointermaptype;
+  protected:
+    XMLArchive* archive;
+    xmlNodePtr node;
+    ElementType element_type;
+    xmlNodePtr current_container_child;
+    string tagname;
+    void writeProperty(const std::string& fieldname, const std::string& 
value);
+    std::string readProperty(const std::string& fieldname);
+  };
+
+  typedef std::map<void*, RefInfo> refmaptype;
+  typedef std::map<std::string, int> countmaptype;
+
+  class XMLArchive : public Archive {
+  public:
+    XMLArchive(xmlDocPtr doc);
+    XMLArchive(const std::string& filename);
+    virtual ~XMLArchive();
+
+    virtual ArchiveElement* getRoot();
+
+    refmaptype refmap;
+    countmaptype countmap;
+    XMLArchiveElement::pointermaptype pointermap;
+  private:
+    std::string filename;
+    xmlDocPtr doc;
+
+    static bool force_initialize;
+  };
+}
+
+static inline
 const char* to_char_ptr(const xmlChar *t) {
   return (const char*)t;
 }
 
-inline
+static inline
 const xmlChar* to_xml_ch_ptr(const char *t) {
   return (xmlChar*)t;
 }
@@ -53,75 +118,27 @@
   }
 }
 
-static std::string get_classname(const xmlChar* ptr)
+static std::string get_classname(xmlNodePtr node, const std::string& 
fieldname)
 {
-  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,
-                                       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);
-
-    virtual ArchiveElement* firstChild();
-    virtual ArchiveElement* nextChild();
-  private:
-    XMLArchive* archive;
-    xmlNodePtr node;
-    string tagname;
-    bool isTagElement;
-    bool tagUsed;
-    void writeProperty(const std::string& fieldname, const std::string& 
value,
-                       Persistent::StorageHint hint);
-    std::string readProperty(const std::string& fieldname, 
Persistent::StorageHint hint);
-
-    typedef XMLArchive::refmaptype refmaptype;
-    typedef XMLArchive::countmaptype countmaptype;
-    typedef XMLArchive::RefInfo RefInfo;
-  };
+  if(strcmp(to_char_ptr(node->name), "template") == 0){
+    xmlChar* templname = xmlGetProp(node, to_xml_ch_ptr("type"));
+    if(!templname)
+      throw SerializationError("Unspecified type for template: " + 
fieldname);
+    return to_char_ptr(templname);
+  } else {
+    string classname = to_char_ptr(node->name);
+    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;
+  }
 }
 
 static Archive* readopener(const std::string& filename)
@@ -185,21 +202,22 @@
 {
   if(reading()){
     xmlNodePtr root = xmlDocGetRootElement(doc);
-    return new XMLArchiveElement(this, root);
+    return new XMLArchiveElement(this, root, XMLArchiveElement::RootElement);
   } else {
     xmlNodePtr top = xmlNewNode(0, to_xml_ch_ptr("Manta"));
     xmlDocSetRootElement(doc, top);
-    return new XMLArchiveElement(this, top);
+    return  new XMLArchiveElement(this, top, XMLArchiveElement::RootElement);
   }
 }
 
-XMLArchiveElement::XMLArchiveElement(XMLArchive* archive, xmlNodePtr node)
-  : ArchiveElement(archive->reading()), archive(archive), node(node), 
isTagElement(false)
+XMLArchiveElement::XMLArchiveElement(XMLArchive* archive, xmlNodePtr node, 
ElementType element_type)
+  : ArchiveElement(archive->reading()), archive(archive), node(node), 
element_type(element_type),
+    current_container_child(0)
 {
 }
 
 XMLArchiveElement::XMLArchiveElement(XMLArchive* archive, xmlNodePtr node, 
const std::string& tagname)
-  : ArchiveElement(archive->reading()), archive(archive), node(node), 
tagname(tagname), isTagElement(true), tagUsed(false)
+  : ArchiveElement(archive->reading()), archive(archive), node(node), 
element_type(TagElement), tagname(tagname)
 {
 }
 
@@ -207,16 +225,15 @@
 {
 }
 
-void XMLArchiveElement::writeProperty(const std::string& fieldname, const 
std::string& value,
-                                      Persistent::StorageHint hint)
+void XMLArchiveElement::writeProperty(const std::string& fieldname, const 
std::string& value)
 {
-  if(isTagElement){
-    if(tagUsed)
-      throw SerializationError("Lightweight class written with more than one 
data member");
-    tagUsed = true;
+  if(element_type == UsedTagElement)
+    throw SerializationError("Lightweight class written with more than one 
data member");
+  else if(element_type == TagElement){
+    element_type = UsedTagElement;
     if(xmlHasProp(node, to_xml_ch_ptr(tagname.c_str()))){
       ostringstream msg;
-      msg << "Writing duplicate field (" << fieldname << ") in writing class 
" << to_char_ptr(node->name);
+      msg << "Writing duplicate field (" << tagname << ") in writing class " 
<< to_char_ptr(node->name);
       throw SerializationError(msg.str());
     }
     xmlSetProp(node, to_xml_ch_ptr(tagname.c_str()), 
to_xml_ch_ptr(value.c_str()));
@@ -230,9 +247,11 @@
   }
 }
 
-std::string XMLArchiveElement::readProperty(const std::string& fieldname, 
Persistent::StorageHint hint)
+std::string XMLArchiveElement::readProperty(const std::string& fieldname)
 {
-  if(isTagElement){
+  if(element_type == UsedTagElement)
+    throw SerializationError("Lightweight class read with more than one data 
member");
+  if(element_type == TagElement){
     xmlChar* prop = xmlGetProp(node, to_xml_ch_ptr(tagname.c_str()));
     if(!prop)
       throw SerializationError(std::string("Missing tag: ") + 
to_char_ptr(prop));
@@ -251,10 +270,10 @@
   }
 }
 
-void XMLArchiveElement::readwrite(const std::string& fieldname, bool& data, 
Persistent::StorageHint hint)
+void XMLArchiveElement::readwrite(const std::string& fieldname, bool& data)
 {
   if(reading()){
-    string str = readProperty(fieldname, hint);
+    string str = readProperty(fieldname);
     if(str == "true" || str == "1" || str == "TRUE" || str == "yes")
       data = true;
     else if(str == "false" || str == "0" || str == "FALSE" || str == "no")
@@ -262,14 +281,14 @@
     else
       throw SerializationError("Unknown boolean value: " + str);
   } else {
-    writeProperty(fieldname, data?"true":"false", hint);
+    writeProperty(fieldname, data?"true":"false");
   }
 }
     
-void XMLArchiveElement::readwrite(const std::string& fieldname, double& 
data, Persistent::StorageHint hint)
+void XMLArchiveElement::readwrite(const std::string& fieldname, double& data)
 {
   if(reading()){
-    istringstream in(readProperty(fieldname, hint));
+    istringstream in(readProperty(fieldname));
     in >> data;
     if(!in)
       throw SerializationError("Error parsing double: " + in.str());
@@ -277,14 +296,14 @@
     ostringstream datastring;
     datastring.precision(17);
     datastring << data;
-    writeProperty(fieldname, datastring.str(), hint);
+    writeProperty(fieldname, datastring.str());
   }
 }
 
-void XMLArchiveElement::readwrite(const std::string& fieldname, float& data, 
Persistent::StorageHint hint)
+void XMLArchiveElement::readwrite(const std::string& fieldname, float& data)
 {
   if(reading()){
-    istringstream in(readProperty(fieldname, hint));
+    istringstream in(readProperty(fieldname));
     in >> data;
     if(!in)
       throw SerializationError("Error parsing float: " + in.str());
@@ -292,14 +311,14 @@
     ostringstream datastring;
     datastring.precision(8);
     datastring << data;
-    writeProperty(fieldname, datastring.str(), hint);
+    writeProperty(fieldname, datastring.str());
   }
 }
 
-void XMLArchiveElement::readwrite(const std::string& fieldname, float* data, 
int numelements, Persistent::StorageHint hint)
+void XMLArchiveElement::readwrite(const std::string& fieldname, float* data, 
int numelements)
 {
   if(reading()){
-    istringstream in(readProperty(fieldname, hint));
+    istringstream in(readProperty(fieldname));
     for(int i=0;i<numelements;i++)
       in >> data[i];
     if(!in)
@@ -312,262 +331,310 @@
         datastring << " ";
       datastring << data[i];
     }
-    writeProperty(fieldname, datastring.str(), hint);
+    writeProperty(fieldname, datastring.str());
   }
 }
 
-void XMLArchiveElement::readwrite(const std::string& fieldname, int& data, 
Persistent::StorageHint hint)
+void XMLArchiveElement::readwrite(const std::string& fieldname, int& data)
 {
   if(reading()){
-    istringstream in(readProperty(fieldname, hint));
+    istringstream in(readProperty(fieldname));
     in >> data;
     if(!in)
       throw SerializationError("Error parsing integer: " + in.str());
   } else {
     ostringstream datastring;
     datastring << data;
-    writeProperty(fieldname, datastring.str(), hint);
+    writeProperty(fieldname, datastring.str());
   }
 }
 
-void XMLArchiveElement::readwrite(const std::string& fieldname, std::string& 
data, Persistent::StorageHint hint)
+void XMLArchiveElement::readwrite(const std::string& fieldname, std::string& 
data)
 {
   if(reading()){
-    data = readProperty(fieldname, hint);
+    data = readProperty(fieldname);
   } else {
-    writeProperty(fieldname, data, hint);
+    writeProperty(fieldname, data);
   }
 }
 
-ArchiveElement* XMLArchiveElement::firstChild()
+bool XMLArchiveElement::nextContainerElement()
 {
-  if(isTagElement)
-    throw SerializationError("Object cannot be stored in a property");
-
-  xmlNode* child = node->children;
-  while(child && child->type != XML_ELEMENT_NODE)
-    child = child->next;
-  if(child)
-    return new XMLArchiveElement(archive, child);
-  else
-    return 0;
+  if(reading()){
+    if(!node)
+      return false;
+    if(!current_container_child)
+      current_container_child = node->children;
+    else
+      current_container_child = current_container_child->next;
+    while(current_container_child && current_container_child->type != 
XML_ELEMENT_NODE)
+      current_container_child = current_container_child->next;
+    if(current_container_child == 0){
+      node = 0;
+      return false;
+    } else {
+      return true;
+    }
+  } else {
+    return true;
+  }
 }
 
-ArchiveElement* XMLArchiveElement::nextChild()
+void XMLArchiveElement::readwrite(const std::string& fieldname, 
PointerWrapper& ptr, bool isPointer)
 {
-  if(isTagElement)
-    throw SerializationError("Object cannot be stored in a property");
+  cerr << "Reading field: " << fieldname << '\n';
+  if(reading()){
+    if(element_type == TagElement || element_type == UsedTagElement)
+      throw SerializationError("Object cannot be stored in a property: " + 
fieldname);
+    // First, check if this is a null pointer
+    // A null pointer can be specified in one of two ways: a tag with the 
value "null"
+    // or a single child with a name "null".  We only check for pointers,
+    // because a lightweight object could easily have a value called "null".
+    if(isPointer){
+      xmlChar* prop = xmlGetProp(node, to_xml_ch_ptr(fieldname.c_str()));
+      xmlNodePtr child = node->children;
+      if((prop && strcmp(to_char_ptr(prop), "null") == 0)
+         || (!prop && strcmp(to_char_ptr(child->name), "null") == 0)){
+        if(!isPointer)
+          throw SerializationError("Cannot read a reference to a null 
pointer");
+        ptr.setNull();
+        cerr << "Null\n";
+        return;
+      }
+    }
+    if(element_type == ContainerElement){
+      cerr << "Is a container element\n";
+      // Second, see if this is a container - it must be handled separately
+      // If this is a container element, try to create the next class
+      if(!node || !current_container_child)
+        throw SerializationError("Container must iterate reads with 
nextContainerObject");
+      string classname = get_classname(current_container_child, fieldname);
+      cerr << "Creating container class: " << classname << " from 
current_container_child: " << current_container_child << '\n';
+      if(isPointer){
+        if(!ptr.createObject(classname))
+          throw SerializationError("Cannot instantiate class: " + classname 
+ " for field: " + fieldname);
+      }
+      const GenericRTTIInterface* classinfo = ptr.getRTTI();
+      PersistentStorage::StorageHint storagehint = classinfo->storageHint();
+      ElementType child_element_type = NormalElement;
+      if(storagehint == PersistentStorage::Container)
+        child_element_type = ContainerElement;
+
+      // See if the object has a tag called "id".  If so, save that as the 
pointer name
+      xmlChar* id = xmlGetProp(current_container_child, to_xml_ch_ptr("id"));
+      if(id){
+        string sid(to_char_ptr(id));
+        if(archive->pointermap.find(sid) != archive->pointermap.end())
+          throw SerializationError("Pointer: " + sid + " defined twice while 
reading field: " + fieldname + " in class: " + classname);
+        archive->pointermap.insert(std::make_pair(sid, ptr.clone()));
+      }
 
-  xmlNode* child = node->next;
-  while(child && child->type != XML_ELEMENT_NODE)
-    child = child->next;
-  if(child)
-    return new XMLArchiveElement(archive, child);
-  else
-    return 0;
-}
+      XMLArchiveElement subelement(archive, current_container_child, 
child_element_type);
+      ptr.readwrite(&subelement);
+      return;
+    }
+
+    const GenericRTTIInterface* classinfo = ptr.getRTTI();
+    PersistentStorage::StorageHint storagehint = classinfo->storageHint();
+
+    // Third, look for a property with the fieldname
+    xmlChar* prop = xmlGetProp(node, to_xml_ch_ptr(fieldname.c_str()));
+    if(prop){
+      // Make sure that there are no children with the same name
+      for(xmlNode* child = node->children; child != 0; child = child->next){
+        if(child->type == XML_ELEMENT_NODE && 
strcmp(to_char_ptr(child->name), fieldname.c_str()) == 0)
+          throw SerializationError("Ambigious field: " + fieldname);
+      }
+
+      // If this is a lightweight object, read it directly.  Otherwise, it
+      // should be the name of a pointer
+      if(storagehint == PersistentStorage::Lightweight){
+        cerr << "Is lightweight\n";
+        XMLArchiveElement subelement(archive, node, fieldname);
+        ptr.readwrite(&subelement);
+        return;
+      } else {
+        cerr << "Is a pointer\n";
+        string pointername = to_char_ptr(prop);
+        pointermaptype::iterator iter = 
archive->pointermap.find(pointername);
+        if(iter == archive->pointermap.end())
+          throw SerializationError("Unknown pointer: " + pointername + " 
while reading field: " + fieldname + " (forward references not yet 
supported)");
+        if(!ptr.copyPointer(iter->second))
+          throw SerializationError("Pointer type mismatch while reading 
field: " + fieldname);
+        return;
+      }
+    }
 
-ArchiveElement* XMLArchiveElement::findObject(const std::string& fieldname,
-                                              std::string& classname,
-                                              Persistent::StorageHint 
classhint,
-                                              Persistent::StorageHint 
instancehint)
-{
-  if(isTagElement)
-    throw SerializationError("Object cannot be stored in a property: " + 
fieldname);
-  // First look for a property with the fieldname
-  xmlChar* prop = xmlGetProp(node, to_xml_ch_ptr(fieldname.c_str()));
-  if(prop){
-    // Make sure that there are no children with the same name
-    for(xmlNode* child = node->children; child != 0; child = child->next){
-      if(child->type == XML_ELEMENT_NODE && strcmp(to_char_ptr(child->name), 
fieldname.c_str()) == 0)
-        throw SerializationError("Ambigious field: " + fieldname);
-    }
-    classname = "<unknown>";
-    return new XMLArchiveElement(archive, node, fieldname);
-  }
-
-  // Then look for a node with the fieldname
-  for(xmlNode* child = node->children; child != 0; child = child->next){
-    if(child->type == XML_ELEMENT_NODE && strcmp(to_char_ptr(child->name), 
fieldname.c_str()) == 0){
+    xmlNodePtr child = 0;
+    ElementType child_element_type = NormalElement;
+    bool object_created;
+    string classname;
+
+    cerr << "4\n";
+    // Fourth, look for a node with the fieldname
+    child = node->children;
+    while(child && (child->type != XML_ELEMENT_NODE || 
strcmp(to_char_ptr(child->name), fieldname.c_str()) != 0))
+      child = child->next;
+    if(child){
       // Make sure that there are no other children with the same name
-      for(xmlNode* child2 = child->next; child2 != 0; child2 = child2->next){
-        if(child2->type == XML_ELEMENT_NODE && 
strcmp(to_char_ptr(child2->name), fieldname.c_str()) == 0)
+      for(xmlNode* c = child->next; c != 0; c = c->next){
+        if(c->type == XML_ELEMENT_NODE && strcmp(to_char_ptr(c->name), 
fieldname.c_str()) == 0)
           throw SerializationError("Ambiguous field: " + fieldname);
       }
 
       // The classname can be in one of several locations:
       // 1. As a property of the field with the tag "type"
       // 2. The sole child of the element
-      // 3. Implied, but only if the classhint is ContainerObject or 
SimpleObject
+      // 3. Implied, but only if we are not reading a pointer or this is a 
container type
       xmlChar* type = xmlGetProp(child, to_xml_ch_ptr("type"));
       if(type){
         classname = to_char_ptr(type);
-        return new XMLArchiveElement(archive, child);
-      }
-
-      if(classhint == Persistent::ContainerObject || classhint == 
Persistent::SimpleObject){
+      } else if(!isPointer || storagehint == PersistentStorage::Container){
         classname = "<unknown>";
-        return new XMLArchiveElement(archive, child);
+        child_element_type = ContainerElement;
+      } else {
+        xmlNode* c = child->children;
+        while(c && c->type != XML_ELEMENT_NODE)
+          c = c->next;
+        if(c){
+          child = c;
+          classname = get_classname(c, fieldname);
+        }
+        cerr << "field, class=" << classname << '\n';
+        c = c->next;
+        while(c && c->type != XML_ELEMENT_NODE)
+          c = c->next;
+        if(c)
+          throw SerializationError("Ambiguous value for field: " + fieldname 
+ "(" + classname + " and " + to_char_ptr(c->name) + ")");
       }
-
-      xmlNode* child2 = child->children;
-      while(child2 && child2->type != XML_ELEMENT_NODE)
-        child2 = child2->next;
-      if(child2){
-        if(strcmp(to_char_ptr(child2->name), "template") == 0){
-          xmlChar* templname = xmlGetProp(child2, to_xml_ch_ptr("type"));
-          if(!templname)
-            throw SerializationError("Unspecified type for template: " + 
fieldname);
-          classname = to_char_ptr(templname);
+    } else if(element_type == RootElement){
+      // If this is the root element, find the first class that matches
+      cerr << "Root:\n";
+      child = node->children;
+      do {
+        while(child && child->type != XML_ELEMENT_NODE)
+          child = child->next;
+        if(child){
+          classname = get_classname(child, fieldname);
+          cerr << "Trying root class: " << classname << " from node: " << 
child << '\n';
+          if(ptr.createObject(classname))
+            object_created = true;
+          else
+            child = child->next;
         } else {
-          classname = get_classname(child2->name);
-        }
-        for(xmlNode* child3 = child2->next; child3 != 0; child3 = 
child3->next){
-          if(child3->type == XML_ELEMENT_NODE)
-            throw SerializationError("Ambiguous value for field: " + 
fieldname + "(" + classname + " and " + to_char_ptr(child3->name) + ")");
+          throw SerializationError("Cannot find root object for field: " + 
fieldname);
         }
-        return new XMLArchiveElement(archive, child2);
-      }
-      throw SerializationError("Empty field named: " + fieldname);
+      } while(child && !object_created);
+    } else {
+      throw SerializationError("Cannot find field: " + fieldname);
     }
-  }
 
-  // Finally, we could have an anonymous field
-  if(instancehint == Persistent::AnonymousField){
-    xmlNode* child = node->children;
-    while(child && child->type != XML_ELEMENT_NODE)
-      child = child->next;
-    if(child){
-      if(strcmp(to_char_ptr(child->name), "template") == 0){
-        xmlChar* templname = xmlGetProp(child, to_xml_ch_ptr("type"));
-        if(!templname)
-          throw SerializationError("Unspecified type for template: " + 
fieldname);
-        classname = to_char_ptr(templname);
-      } else {
-        classname = get_classname(child->name);
-      }
-      return new XMLArchiveElement(archive, child);
+    if(isPointer){
+      if(!ptr.createObject(classname))
+        throw SerializationError("Cannot instantiate class: " + classname + 
" for field: " + fieldname);
     }
-  }
-
-  return 0;
-}
-
-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);
-    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;
-  }
-
 
-  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 XMLArchiveElement::isNullPointer(const std::string& fieldname) const
-{
-  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 XMLArchiveElement::writeNullPointer(const std::string& fieldname)
-{
-  if(fieldname == ""){
-    xmlNodePtr field = xmlNewNode(0, to_xml_ch_ptr("null"));
-    xmlAddChild(node, field);
-  } else {
-    xmlSetProp(node, to_xml_ch_ptr(fieldname.c_str()), 
to_xml_ch_ptr("null"));
-  }
-}
-
-void XMLArchiveElement::writeObjectReference(const std::string& fieldname,
-                                             const std::string& classname,
-                                             const std::string& refname)
-{
-  if(xmlHasProp(node, to_xml_ch_ptr(fieldname.c_str())))
-    throw SerializationError("Pointer written twice");
-  xmlSetProp(node, to_xml_ch_ptr(fieldname.c_str()), 
to_xml_ch_ptr(refname.c_str()));
-}
-
-bool XMLArchiveElement::haveReference(void* ptr, std::string& refname)
-{
-  refmaptype::iterator iter = archive->refmap.find(ptr);
-  if(iter == archive->refmap.end()){
-    return false;
+    // See if the object has a tag called "id".  If so, save that as the 
pointer name
+    xmlChar* id = xmlGetProp(child, to_xml_ch_ptr("id"));
+    if(id){
+      string sid(to_char_ptr(id));
+      if(archive->pointermap.find(sid) != archive->pointermap.end())
+        throw SerializationError("Pointer: " + sid + " defined twice while 
reading field: " + fieldname + " in class: " + classname);
+      archive->pointermap.insert(std::make_pair(sid, ptr.clone()));
+    }
+    XMLArchiveElement subelement(archive, child, child_element_type);
+    ptr.readwrite(&subelement);
   } else {
-    XMLArchive::RefInfo& ri = iter->second;
-    if(!ri.used){
-      // Append the count to make it unique
-      // 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 == archive->countmap.end()){
-        count = 0;
-        archive->countmap.insert(make_pair(ri.refname, 1));
+    // Writing
+    if(element_type == TagElement || element_type == UsedTagElement)
+      throw SerializationError("Creating complex object in lightweight 
archive element");
+    if(ptr.isNull()){
+      // A null pointer, mark it appropriately
+      xmlSetProp(node, to_xml_ch_ptr(fieldname.c_str()), 
to_xml_ch_ptr("null"));
+      return;
+    }
+    // Check to see if this pointer has already been emitted.
+    if(isPointer){
+      void* id = ptr.getUniqueID();
+      refmaptype::iterator iter = archive->refmap.find(id);
+      if(iter != archive->refmap.end()){
+        // This is a reference to a pointer that has already been
+        // emitted.  Emit the reference.
+        RefInfo& ri = iter->second;
+        if(ri.useCount == 1){
+          // Append the count to make it unique
+          // We do it here so that we only change the number for pointers
+          // that are actually used more than once
+          countmaptype::iterator citer = archive->countmap.find(ri.refname);
+          int count;
+          if(citer == archive->countmap.end()){
+            count = 0;
+            archive->countmap.insert(make_pair(ri.refname, 1));
+          } else {
+            count = citer->second++;
+          }
+
+          ostringstream str;
+          str << ri.refname << count;
+          ri.refname = str.str();
+          xmlSetProp(ri.node, to_xml_ch_ptr("id"), 
to_xml_ch_ptr(ri.refname.c_str()));
+        }
+        ri.useCount++;
+        if(xmlHasProp(node, to_xml_ch_ptr(fieldname.c_str())))
+          throw SerializationError("Pointer written twice");
+        xmlSetProp(node, to_xml_ch_ptr(fieldname.c_str()), 
to_xml_ch_ptr(ri.refname.c_str()));
+        return;
+      }
+    }
+    const GenericRTTIInterface* classinfo = ptr.getRTTI();
+    bool have_complex_classname;
+    string safe_classname = classinfo->getPublicClassname();
+    make_safe_classname(safe_classname, have_complex_classname);
+
+    PersistentStorage::StorageHint storagehint = classinfo->storageHint();
+    if(storagehint == PersistentStorage::Lightweight && !isPointer){
+      // Store one value in the tag
+      XMLArchiveElement subelement(archive, node, fieldname);
+      ptr.readwrite(&subelement);
+    } else {
+      xmlNodePtr childnode;
+      ElementType child_element_type = NormalElement;
+      if(element_type == RootElement || element_type == ContainerElement){
+        // Store only the class name
+        childnode = xmlNewNode(0, to_xml_ch_ptr(safe_classname.c_str()));
+        if(have_complex_classname)
+          xmlSetProp(childnode, to_xml_ch_ptr("type"), 
to_xml_ch_ptr(safe_classname.c_str()));
+        xmlAddChild(node, childnode);
+      } else if(storagehint == PersistentStorage::Container){
+        // Store only the field name
+        childnode = xmlNewNode(0, to_xml_ch_ptr(fieldname.c_str()));
+        xmlAddChild(node, childnode);
+        child_element_type = ContainerElement;
+      } else if(!isPointer){
+        // Store only the field name
+        childnode = xmlNewNode(0, to_xml_ch_ptr(fieldname.c_str()));
+        xmlAddChild(node, childnode);
       } else {
-        count = citer->second++;
+        // Store both field name and class
+        childnode = xmlNewNode(0, to_xml_ch_ptr(safe_classname.c_str()));
+        if(have_complex_classname)
+          xmlSetProp(childnode, to_xml_ch_ptr("type"), 
to_xml_ch_ptr(safe_classname.c_str()));
+        xmlNodePtr fieldnode = xmlNewNode(0, 
to_xml_ch_ptr(fieldname.c_str()));
+        xmlAddChild(fieldnode, childnode);
+        xmlAddChild(node, fieldnode);
       }
 
-      ostringstream str;
-      str << ri.refname << count;
-      ri.refname = str.str();
-      xmlSetProp(ri.node, to_xml_ch_ptr("id"), 
to_xml_ch_ptr(ri.refname.c_str()));
-      ri.used = true;
+      if(isPointer){
+        // Save this pointer for possible later use
+        RefInfo ri;
+        ri.node = childnode;
+        ri.refname = classinfo->getPublicClassname(); // Will be appended 
with unique ID in haveReference
+        ri.useCount = 1;
+        void* id = ptr.getUniqueID();
+        archive->refmap.insert(make_pair(id, ri));
+      }
+      XMLArchiveElement subelement(archive, childnode, child_element_type);
+      ptr.readwrite(&subelement);
     }
-    refname = ri.refname;
-    return true;
   }
 }
-

Copied: branches/persistent/Core/Persistent/stdRTTI.h (from r1735, 
branches/persistent/Core/Persistent/stdClassInfo.h)
==============================================================================
--- branches/persistent/Core/Persistent/stdClassInfo.h  (original)
+++ branches/persistent/Core/Persistent/stdRTTI.h       Fri Oct 26 11:34:34 
2007
@@ -2,18 +2,18 @@
 #ifndef Manta_stdRefl_h
 #define Manta_stdRefl_h
 
-#include <Core/Persistent/ClassInfo.h>
+#include <Core/Persistent/MantaRTTI.h>
 #include <Core/Persistent/ArchiveElement.h>
 #include <Core/Util/NotFinished.h>
 #include <vector>
 
 namespace Manta {
   template<class T>
-    class ClassInfo<std::vector<T> > {
+    class MantaRTTI<std::vector<T> > {
   public:
     static std::string getPublicClassname() {
       init.forceinit();
-      return "std::vector<" + ClassInfo<T>::getPublicClassname() + ">";
+      return "std::vector<" + MantaRTTI<T>::getPublicClassname() + ">";
     }
     static std::vector<T>* createInstance() {
       init.forceinit();
@@ -23,14 +23,11 @@
       init.forceinit();
       NOT_FINISHED("vector readwrite");
     }
-    static bool isSimpleContainer() {
-      return true;
-    }
   private:
     class Initializer {
     public:
       Initializer() {
-        ClassDatabase<std::vector<T> >::template 
registerClass<std::vector<T> >(getPublicClassname());
+        ClassIndex<std::vector<T> >::template registerClass<std::vector<T> 
>(getPublicClassname());
       }
       void forceinit() {
       }
@@ -39,34 +36,34 @@
     static std::string* classname;
   };
   template<class T>
-  typename ClassInfo<std::vector<T> >::Initializer ClassInfo<std::vector<T> 
>::init;
+  typename MantaRTTI<std::vector<T> >::Initializer MantaRTTI<std::vector<T> 
>::init;
 
   template<class T>
-    class ClassInfo<std::vector<T*> > {
+    class MantaRTTI<std::vector<T*> > {
   public:
     static std::string getPublicClassname() {
-      return "std::vector<" + ClassInfo<T>::getPublicClassname() + "*>";
+      init.forceinit();
+      return "std::vector<" + MantaRTTI<T>::getPublicClassname() + "*>";
     }
     static std::vector<T*>* createInstance() {
-      init.forceinit();
       return new std::vector<T*>();
     }
     static void readwrite(ArchiveElement* archive, std::vector<T*>& data) {
       init.forceinit();
       if(archive->reading()){
         data.resize(0);
-        for(ArchiveElement* child = archive->firstChild(); child != 0; child 
= child->nextChild()){
+        while(archive->nextContainerElement()){
           T* ptr;
-          archive->readwrite("element", ptr, Persistent::AnonymousField);
+          archive->readwrite("element", ptr);
           data.push_back(ptr);
         }
       } else {
         for(typename std::vector<T*>::iterator iter = data.begin(); iter != 
data.end(); iter++)
-          archive->readwrite("element", *iter, Persistent::AnonymousField);
+          archive->readwrite("element", *iter);
       }
     }
-    static Persistent::StorageHint storageHint() {
-      return Persistent::ContainerObject;
+    static PersistentStorage::StorageHint storageHint() {
+      return PersistentStorage::Container;
     }
   private:
     class Initializer {
@@ -78,12 +75,12 @@
     static Initializer init;
   };
   template<class T>
-  ClassInfo<std::vector<T*> >::Initializer::Initializer()
+  MantaRTTI<std::vector<T*> >::Initializer::Initializer()
   {
-    ClassDatabase<std::vector<T*> >::template registerClass<std::vector<T*> 
>(getPublicClassname());
+    ClassIndex<std::vector<T*> >::template registerClass<std::vector<T*> 
>(getPublicClassname());
   }
   template<class T>
-  typename ClassInfo<std::vector<T*> >::Initializer 
ClassInfo<std::vector<T*> >::init;
+  typename MantaRTTI<std::vector<T*> >::Initializer 
MantaRTTI<std::vector<T*> >::init;
 
 }
 

Modified: branches/persistent/Engine/Factory/Factory.cc
==============================================================================
--- branches/persistent/Engine/Factory/Factory.cc       (original)
+++ branches/persistent/Engine/Factory/Factory.cc       Fri Oct 26 11:34:34 
2007
@@ -39,7 +39,7 @@
 #include <Engine/Factory/RegisterKnownComponents.h>
 #include <Interface/Context.h>
 #include <Interface/MantaInterface.h>
-#include <Interface/InterfaceClassInfo.h>
+#include <Interface/InterfaceRTTI.h>
 #include <Interface/Scene.h>
 
 #include <errno.h>
@@ -463,7 +463,7 @@
   if(!root)
     throw InputError("Cannot find scene in file: " + fullname);
   Scene* scene = 0;
-  root->readwrite("scene", scene, Persistent::AnonymousField);
+  root->readwrite("scene", scene);
   if(!scene)
     throw InternalError("Error reading file: " + fullname, __FILE__, 
__LINE__);
   return scene;

Modified: branches/persistent/Interface/CMakeLists.txt
==============================================================================
--- branches/persistent/Interface/CMakeLists.txt        (original)
+++ branches/persistent/Interface/CMakeLists.txt        Fri Oct 26 11:34:34 
2007
@@ -21,8 +21,8 @@
         ImageDisplay.cc
         ImageTraverser.h
         ImageTraverser.cc
-        InterfaceClassInfo.h
-        InterfaceClassInfo.cc
+        InterfaceRTTI.h
+        InterfaceRTTI.cc
         Interpolable.h
         Interpolable.cc
         Light.h

Modified: branches/persistent/Interface/Camera.cc
==============================================================================
--- branches/persistent/Interface/Camera.cc     (original)
+++ branches/persistent/Interface/Camera.cc     Fri Oct 26 11:34:34 2007
@@ -18,7 +18,7 @@
 {
 }
 
-REGISTER_CLASS(BasicCameraData);
+MANTA_REGISTER_CLASS(BasicCameraData);
 
 void BasicCameraData::readwrite(ArchiveElement* archive)
 {

Modified: branches/persistent/Interface/Camera.h
==============================================================================
--- branches/persistent/Interface/Camera.h      (original)
+++ branches/persistent/Interface/Camera.h      Fri Oct 26 11:34:34 2007
@@ -39,7 +39,7 @@
     void readwrite(ArchiveElement* archive);
   };
 
-  DECLARE_CLASSINFO_BASECLASS(BasicCameraData, ConcreteClass, 
readwriteMethod);
+  MANTA_DECLARE_RTTI_BASECLASS(BasicCameraData, ConcreteClass, 
readwriteMethod);
 
   class Camera : public Interpolable {
   public:

Copied: branches/persistent/Interface/InterfaceRTTI.cc (from r1735, 
branches/persistent/Interface/InterfaceClassInfo.cc)
==============================================================================
--- branches/persistent/Interface/InterfaceClassInfo.cc (original)
+++ branches/persistent/Interface/InterfaceRTTI.cc      Fri Oct 26 11:34:34 
2007
@@ -1,5 +1,5 @@
 
-#include <Interface/InterfaceClassInfo.h>
+#include <Interface/InterfaceRTTI.h>
 #include <Interface/AmbientLight.h>
 #include <Interface/Background.h>
 #include <Interface/Clonable.h>
@@ -11,19 +11,21 @@
 #include <Interface/Primitive.h>
 #include <Interface/RenderParameters.h>
 #include <Interface/Scene.h>
+#include <Interface/Texture.h>
 
 using namespace std;
 using namespace Manta;
 
-REGISTER_CLASS(AmbientLight);
-REGISTER_CLASS(Light);
-REGISTER_CLASS(Material);
-REGISTER_CLASS(TexCoordMapper);
-REGISTER_CLASS(Scene);
-REGISTER_CLASS(Background);
-REGISTER_CLASS(Object);
-REGISTER_CLASS(Primitive);
-REGISTER_CLASS(LightSet);
-REGISTER_CLASS(RenderParameters);
-REGISTER_CLASS(Interpolable);
-REGISTER_CLASS(Clonable);
+MANTA_REGISTER_CLASS(AmbientLight);
+MANTA_REGISTER_CLASS(Light);
+MANTA_REGISTER_CLASS(Material);
+MANTA_REGISTER_CLASS(TexCoordMapper);
+MANTA_REGISTER_CLASS(Scene);
+MANTA_REGISTER_CLASS(Background);
+MANTA_REGISTER_CLASS(Object);
+MANTA_REGISTER_CLASS(Primitive);
+MANTA_REGISTER_CLASS(LightSet);
+MANTA_REGISTER_CLASS(RenderParameters);
+MANTA_REGISTER_CLASS(Interpolable);
+MANTA_REGISTER_CLASS(Clonable);
+

Copied: branches/persistent/Interface/InterfaceRTTI.h (from r1735, 
branches/persistent/Interface/InterfaceClassInfo.h)
==============================================================================
--- branches/persistent/Interface/InterfaceClassInfo.h  (original)
+++ branches/persistent/Interface/InterfaceRTTI.h       Fri Oct 26 11:34:34 
2007
@@ -1,8 +1,8 @@
 
-#ifndef Manta_InterfaceRefl_h
-#define Manta_InterfaceRefl_h
+#ifndef Manta_InterfaceRTTI_h
+#define Manta_InterfaceRTTI_h
 
-#include <Core/Persistent/ClassInfo.h>
+#include <Core/Persistent/MantaRTTI.h>
 
 namespace Manta {
   class AmbientLight;
@@ -19,23 +19,27 @@
   class Scene;
   template<class ValueType> class Texture;
 
-  DECLARE_CLASSINFO_BASECLASS(AmbientLight, AbstractClass, readwriteNone);
-  DECLARE_CLASSINFO_BASECLASS(Light, AbstractClass,readwriteNone);
-  DECLARE_CLASSINFO_DERIVEDCLASS(Material, Interpolable, AbstractClass, 
readwriteNone);
-  DECLARE_CLASSINFO_DERIVEDCLASS(TexCoordMapper, Interpolable, 
AbstractClass, readwriteNone);
-  DECLARE_CLASSINFO_BASECLASS(Scene, ConcreteClass, readwriteMethod);
-  DECLARE_CLASSINFO_BASECLASS(Background, AbstractClass, readwriteNone);
-  DECLARE_CLASSINFO_DERIVEDCLASS(Object, Interpolable, AbstractClass, 
readwriteNone);
-  DECLARE_CLASSINFO_DERIVEDCLASS(Primitive, Object, AbstractClass, 
readwriteNone);
-  DECLARE_CLASSINFO_BASECLASS(LightSet, ConcreteClass, readwriteMethod);
-  DECLARE_CLASSINFO_BASECLASS(RenderParameters, ConcreteClass, 
readwriteMethod);
-  DECLARE_CLASSINFO_DERIVEDCLASS(Interpolable, Clonable, AbstractClass, 
readwriteNone);
-  DECLARE_CLASSINFO_BASECLASS(Clonable, AbstractClass, readwriteNone);
+  MANTA_DECLARE_RTTI_BASECLASS(AmbientLight, AbstractClass, readwriteNone);
+  MANTA_DECLARE_RTTI_BASECLASS(Light, AbstractClass,readwriteNone);
+  MANTA_DECLARE_RTTI_DERIVEDCLASS(Material, Interpolable, AbstractClass, 
readwriteNone);
+  MANTA_DECLARE_RTTI_DERIVEDCLASS(TexCoordMapper, Interpolable, 
AbstractClass, readwriteNone);
+  MANTA_DECLARE_RTTI_BASECLASS(Scene, ConcreteClass, readwriteMethod);
+  MANTA_DECLARE_RTTI_BASECLASS(Background, AbstractClass, readwriteNone);
+  MANTA_DECLARE_RTTI_DERIVEDCLASS(Object, Interpolable, AbstractClass, 
readwriteNone);
+  MANTA_DECLARE_RTTI_DERIVEDCLASS(Primitive, Object, AbstractClass, 
readwriteNone);
+  MANTA_DECLARE_RTTI_BASECLASS(LightSet, ConcreteClass, readwriteMethod);
+  MANTA_DECLARE_RTTI_BASECLASS(RenderParameters, ConcreteClass, 
readwriteMethod);
+  MANTA_DECLARE_RTTI_DERIVEDCLASS(Interpolable, Clonable, AbstractClass, 
readwriteNone);
+  MANTA_DECLARE_RTTI_BASECLASS(Clonable, AbstractClass, readwriteNone);
 
   template<class ValueType>
-  class ClassInfo<Texture<ValueType> > : public 
ClassInfo_DerivedClass<Texture<ValueType>, Interpolable>, public 
ClassInfo_AbstractClass<Texture<ValueType> >, public 
ClassInfo_readwriteNone<Texture<ValueType> > {
+  class MantaRTTI<Texture<ValueType> > : public 
MantaRTTI_DerivedClass<Texture<ValueType>, Interpolable>, public 
MantaRTTI_AbstractClass<Texture<ValueType> >, public 
MantaRTTI_readwriteNone<Texture<ValueType> > {
+  public:
     static bool force_initialize;
   };
+
+  template<class ValueType>
+    bool MantaRTTI<Texture<ValueType> >::force_initialize = 
MantaRTTI<Texture<ValueType> 
>::registerClass("Texture<"+MantaRTTI<ValueType>::getPublicClassname()+">");
 }
 
 #endif

Modified: branches/persistent/Interface/LightSet.cc
==============================================================================
--- branches/persistent/Interface/LightSet.cc   (original)
+++ branches/persistent/Interface/LightSet.cc   Fri Oct 26 11:34:34 2007
@@ -2,9 +2,9 @@
 #include <Interface/LightSet.h>
 #include <Interface/AmbientLight.h>
 #include <Interface/Light.h>
-#include <Interface/InterfaceClassInfo.h>
+#include <Interface/InterfaceRTTI.h>
 #include <Core/Persistent/ArchiveElement.h>
-#include <Core/Persistent/stdClassInfo.h>
+#include <Core/Persistent/stdRTTI.h>
 #include <Core/Util/Assert.h>
 
 #include <sgi_stl_warnings_off.h>

Modified: branches/persistent/Interface/Scene.cc
==============================================================================
--- branches/persistent/Interface/Scene.cc      (original)
+++ branches/persistent/Interface/Scene.cc      Fri Oct 26 11:34:34 2007
@@ -1,9 +1,9 @@
 
 #include <Interface/Scene.h>
-#include <Core/Persistent/stdClassInfo.h>
+#include <Core/Persistent/stdRTTI.h>
 #include <Core/Persistent/ArchiveElement.h>
 #include <Interface/Background.h>
-#include <Interface/InterfaceClassInfo.h>
+#include <Interface/InterfaceRTTI.h>
 #include <Interface/LightSet.h>
 
 using namespace Manta;
@@ -56,8 +56,8 @@
 }
 
 namespace Manta {
-  DECLARE_CLASSINFO_BASECLASS(Scene::Bookmark, ConcreteClass, 
readwriteMethod);
-  REGISTER_CLASS(Scene::Bookmark);
+  MANTA_DECLARE_RTTI_BASECLASS(Scene::Bookmark, ConcreteClass, 
readwriteMethod);
+  MANTA_REGISTER_CLASS(Scene::Bookmark);
 }
 
 void Scene::Bookmark::readwrite(ArchiveElement* archive)

Modified: branches/persistent/Interface/Texture.h
==============================================================================
--- branches/persistent/Interface/Texture.h     (original)
+++ branches/persistent/Interface/Texture.h     Fri Oct 26 11:34:34 2007
@@ -11,8 +11,8 @@
   template<typename ValueType>
   class Texture : virtual public Interpolable {
   public:
-    Texture() {};
-    virtual ~Texture() {};
+    Texture() {}
+    virtual ~Texture() {}
 
     virtual void mapValues(Packet<ValueType>& results,
                            const RenderContext&,

Modified: branches/persistent/Model/AmbientLights/ArcAmbient.cc
==============================================================================
--- branches/persistent/Model/AmbientLights/ArcAmbient.cc       (original)
+++ branches/persistent/Model/AmbientLights/ArcAmbient.cc       Fri Oct 26 
11:34:34 2007
@@ -1,7 +1,7 @@
 
 #include <Model/AmbientLights/ArcAmbient.h>
 #include <Interface/RayPacket.h>
-#include <Interface/InterfaceClassInfo.h>
+#include <Interface/InterfaceRTTI.h>
 #include <Core/Persistent/ArchiveElement.h>
 
 #include <sgi_stl_warnings_off.h>
@@ -74,13 +74,13 @@
 }
 
 namespace Manta {
-DECLARE_CLASSINFO_DERIVEDCLASS(ArcAmbient, AmbientLight, ConcreteClass, 
readwriteMethod);
-REGISTER_CLASS(ArcAmbient);
+MANTA_DECLARE_RTTI_DERIVEDCLASS(ArcAmbient, AmbientLight, ConcreteClass, 
readwriteMethod);
+MANTA_REGISTER_CLASS(ArcAmbient);
 }
 
 void ArcAmbient::readwrite(ArchiveElement* archive)
 {
-  ClassInfo<AmbientLight>::readwrite(archive, *this);
+  MantaRTTI<AmbientLight>::readwrite(archive, *this);
   archive->readwrite("cup", cup);
   archive->readwrite("cdown", cdown);
   archive->readwrite("up", up);

Modified: branches/persistent/Model/Backgrounds/LinearBackground.cc
==============================================================================
--- branches/persistent/Model/Backgrounds/LinearBackground.cc   (original)
+++ branches/persistent/Model/Backgrounds/LinearBackground.cc   Fri Oct 26 
11:34:34 2007
@@ -1,7 +1,7 @@
 
 #include <Model/Backgrounds/LinearBackground.h>
 #include <Core/Persistent/ArchiveElement.h>
-#include <Interface/InterfaceClassInfo.h>
+#include <Interface/InterfaceRTTI.h>
 #include <Interface/RayPacket.h>
 #include <MantaTypes.h>
 
@@ -40,13 +40,13 @@
 }
 
 namespace Manta {
-DECLARE_CLASSINFO_DERIVEDCLASS(LinearBackground, Background, ConcreteClass, 
readwriteMethod);
-REGISTER_CLASS(LinearBackground);
+MANTA_DECLARE_RTTI_DERIVEDCLASS(LinearBackground, Background, ConcreteClass, 
readwriteMethod);
+MANTA_REGISTER_CLASS(LinearBackground);
 }
 
 void LinearBackground::readwrite(ArchiveElement* archive)
 {
-  ClassInfo<Background>::readwrite(archive, *this);
+  MantaRTTI<Background>::readwrite(archive, *this);
   archive->readwrite("cup", cup);
   archive->readwrite("cdown", cdown);
   archive->readwrite("up", up);

Modified: branches/persistent/Model/Backgrounds/LinearBackground.h
==============================================================================
--- branches/persistent/Model/Backgrounds/LinearBackground.h    (original)
+++ branches/persistent/Model/Backgrounds/LinearBackground.h    Fri Oct 26 
11:34:34 2007
@@ -5,7 +5,7 @@
 #include <Interface/Background.h>
 #include <Core/Color/Color.h>
 #include <Core/Geometry/Vector.h>
-#include <Core/Persistent/ClassInfo.h>
+#include <Core/Persistent/MantaRTTI.h>
 
 namespace Manta {
 

Modified: branches/persistent/Model/Groups/Group.cc
==============================================================================
--- branches/persistent/Model/Groups/Group.cc   (original)
+++ branches/persistent/Model/Groups/Group.cc   Fri Oct 26 11:34:34 2007
@@ -1,7 +1,7 @@
 
 #include <Model/Groups/Group.h>
-#include <Interface/InterfaceClassInfo.h>
-#include <Core/Persistent/stdClassInfo.h>
+#include <Interface/InterfaceRTTI.h>
+#include <Core/Persistent/stdRTTI.h>
 #include <Core/Persistent/ArchiveElement.h>
 #include <SCIRun/Core/Util/Assert.h>
 #include <algorithm>
@@ -156,12 +156,12 @@
 }
 
 namespace Manta {
-DECLARE_CLASSINFO_DERIVEDCLASS(Group, Object, ConcreteClass, 
readwriteMethod);
-REGISTER_CLASS(Group);
+MANTA_DECLARE_RTTI_DERIVEDCLASS(Group, Object, ConcreteClass, 
readwriteMethod);
+MANTA_REGISTER_CLASS(Group);
 }
 
 void Group::readwrite(ArchiveElement* archive)
 {
-  ClassInfo<Object>::readwrite(archive, *this);
+  MantaRTTI<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    Fri Oct 26 11:34:34 2007
@@ -32,7 +32,7 @@
 
 
 #include <Interface/Object.h>
-#include <Core/Persistent/ClassInfo.h>
+#include <Core/Persistent/MantaRTTI.h>
 #include <sgi_stl_warnings_off.h>
 #include <vector>
 #include <string>

Modified: branches/persistent/Model/Lights/PointLight.cc
==============================================================================
--- branches/persistent/Model/Lights/PointLight.cc      (original)
+++ branches/persistent/Model/Lights/PointLight.cc      Fri Oct 26 11:34:34 
2007
@@ -1,8 +1,8 @@
 
 #include <Model/Lights/PointLight.h>
 #include <Core/Persistent/ArchiveElement.h>
-#include <Core/Persistent/ClassInfo.h>
-#include <Interface/InterfaceClassInfo.h>
+#include <Core/Persistent/MantaRTTI.h>
+#include <Interface/InterfaceRTTI.h>
 #include <MantaSSE.h>
 
 using namespace Manta;
@@ -66,13 +66,13 @@
 }
 
 namespace Manta {
-  DECLARE_CLASSINFO_DERIVEDCLASS(PointLight, Light, ConcreteClass, 
readwriteMethod);
-  REGISTER_CLASS(PointLight);
+  MANTA_DECLARE_RTTI_DERIVEDCLASS(PointLight, Light, ConcreteClass, 
readwriteMethod);
+  MANTA_REGISTER_CLASS(PointLight);
 }
 
 void PointLight::readwrite(ArchiveElement* archive)
 {
-  ClassInfo<Light>::readwrite(archive, *this);
+  MantaRTTI<Light>::readwrite(archive, *this);
   archive->readwrite("position", position);
   archive->readwrite("color", color);
 }

Modified: branches/persistent/Model/Materials/Lambertian.cc
==============================================================================
--- branches/persistent/Model/Materials/Lambertian.cc   (original)
+++ branches/persistent/Model/Materials/Lambertian.cc   Fri Oct 26 11:34:34 
2007
@@ -34,9 +34,9 @@
 #include <Interface/AmbientLight.h>
 #include <Interface/Context.h>
 #include <Interface/ShadowAlgorithm.h>
-#include <Core/Persistent/ClassInfo.h>
+#include <Core/Persistent/MantaRTTI.h>
 #include <Core/Persistent/ArchiveElement.h>
-#include <Interface/InterfaceClassInfo.h>
+#include <Interface/InterfaceRTTI.h>
 #include <Model/Textures/Constant.h>
 #include <iostream>
 using namespace Manta;
@@ -237,12 +237,12 @@
 }
 
 namespace Manta {
-  DECLARE_CLASSINFO_DERIVEDCLASS(Lambertian, LitMaterial, ConcreteClass, 
readwriteMethod);
-  REGISTER_CLASS(Lambertian);
+  MANTA_DECLARE_RTTI_DERIVEDCLASS(Lambertian, LitMaterial, ConcreteClass, 
readwriteMethod);
+  MANTA_REGISTER_CLASS(Lambertian);
 }
 
 void Lambertian::readwrite(ArchiveElement* archive)
 {
-  ClassInfo<LitMaterial>::readwrite(archive, *this);
+  MantaRTTI<LitMaterial>::readwrite(archive, *this);
   archive->readwrite("color", colortex);
 }

Modified: branches/persistent/Model/Materials/LitMaterial.cc
==============================================================================
--- branches/persistent/Model/Materials/LitMaterial.cc  (original)
+++ branches/persistent/Model/Materials/LitMaterial.cc  Fri Oct 26 11:34:34 
2007
@@ -1,6 +1,6 @@
 
 #include <Model/Materials/LitMaterial.h>
-#include <Interface/InterfaceClassInfo.h>
+#include <Interface/InterfaceRTTI.h>
 #include <Interface/LightSet.h>
 #include <Interface/Context.h>
 #include <Core/Persistent/ArchiveElement.h>
@@ -31,12 +31,12 @@
 }
 
 namespace Manta {
-  REGISTER_CLASS(LitMaterial);
+  MANTA_REGISTER_CLASS(LitMaterial);
 }
 
 void LitMaterial::readwrite(ArchiveElement* archive)
 {
-  ClassInfo<OpaqueShadower>::readwrite(archive, *this);
+  MantaRTTI<OpaqueShadower>::readwrite(archive, *this);
   archive->readwrite("localLights", localLights);
   archive->readwrite("localLightsOverrideGlobal", localLightsOverrideGlobal);
 }

Modified: branches/persistent/Model/Materials/LitMaterial.h
==============================================================================
--- branches/persistent/Model/Materials/LitMaterial.h   (original)
+++ branches/persistent/Model/Materials/LitMaterial.h   Fri Oct 26 11:34:34 
2007
@@ -3,7 +3,7 @@
 #define Manta_Model_LitMaterial_h
 
 #include <Model/Materials/OpaqueShadower.h>
-#include <Core/Persistent/ClassInfo.h>
+#include <Core/Persistent/MantaRTTI.h>
 
 namespace Manta {
   class LightSet;
@@ -22,7 +22,7 @@
     bool localLightsOverrideGlobal;
   };
 
-  DECLARE_CLASSINFO_DERIVEDCLASS(LitMaterial, OpaqueShadower, AbstractClass, 
readwriteMethod);
+  MANTA_DECLARE_RTTI_DERIVEDCLASS(LitMaterial, OpaqueShadower, 
AbstractClass, readwriteMethod);
 }
 
 #endif

Modified: branches/persistent/Model/Materials/MetalMaterial.cc
==============================================================================
--- branches/persistent/Model/Materials/MetalMaterial.cc        (original)
+++ branches/persistent/Model/Materials/MetalMaterial.cc        Fri Oct 26 
11:34:34 2007
@@ -1,7 +1,7 @@
 
 #include <Model/Materials/MetalMaterial.h>
 #include <Core/Math/ipow.h>
-#include <Core/Persistent/ClassInfo.h>
+#include <Core/Persistent/MantaRTTI.h>
 #include <Core/Persistent/ArchiveElement.h>
 #include <Interface/Context.h>
 #include <Interface/Light.h>
@@ -84,13 +84,13 @@
 }
 
 namespace Manta {
-  DECLARE_CLASSINFO_DERIVEDCLASS(MetalMaterial, LitMaterial, ConcreteClass, 
readwriteMethod);
-  REGISTER_CLASS(MetalMaterial);
+  MANTA_DECLARE_RTTI_DERIVEDCLASS(MetalMaterial, LitMaterial, ConcreteClass, 
readwriteMethod);
+  MANTA_REGISTER_CLASS(MetalMaterial);
 }
 
 void MetalMaterial::readwrite(ArchiveElement* archive)
 {
-  ClassInfo<LitMaterial>::readwrite(archive, *this);
+  MantaRTTI<LitMaterial>::readwrite(archive, *this);
   archive->readwrite("reflectance", specular_reflectance);
   archive->readwrite("phong_exponent", phong_exponent);
 }

Modified: branches/persistent/Model/Materials/OpaqueShadower.cc
==============================================================================
--- branches/persistent/Model/Materials/OpaqueShadower.cc       (original)
+++ branches/persistent/Model/Materials/OpaqueShadower.cc       Fri Oct 26 
11:34:34 2007
@@ -27,7 +27,7 @@
 */
 
 #include <Model/Materials/OpaqueShadower.h>
-#include <Interface/InterfaceClassInfo.h>
+#include <Interface/InterfaceRTTI.h>
 #include <MantaSSE.h>
 #include <Interface/RayPacket.h>
 #include <Interface/Context.h>
@@ -68,5 +68,5 @@
 }
 
 namespace Manta {
-  REGISTER_CLASS(OpaqueShadower);
+  MANTA_REGISTER_CLASS(OpaqueShadower);
 }

Modified: branches/persistent/Model/Materials/OpaqueShadower.h
==============================================================================
--- branches/persistent/Model/Materials/OpaqueShadower.h        (original)
+++ branches/persistent/Model/Materials/OpaqueShadower.h        Fri Oct 26 
11:34:34 2007
@@ -30,7 +30,7 @@
 */
 
 #include <Interface/Material.h>
-#include <Core/Persistent/ClassInfo.h>
+#include <Core/Persistent/MantaRTTI.h>
 
 namespace Manta {
   
@@ -48,7 +48,7 @@
 
   };
 
-  DECLARE_CLASSINFO_DERIVEDCLASS(OpaqueShadower, Material, AbstractClass, 
readwriteNone);
+  MANTA_DECLARE_RTTI_DERIVEDCLASS(OpaqueShadower, Material, AbstractClass, 
readwriteNone);
 } // end namespace Manta
 
 #endif // #ifndef MODEL_MATERIALS_OPAQUESHADOWER_H__

Modified: branches/persistent/Model/Primitives/Parallelogram.cc
==============================================================================
--- branches/persistent/Model/Primitives/Parallelogram.cc       (original)
+++ branches/persistent/Model/Primitives/Parallelogram.cc       Fri Oct 26 
11:34:34 2007
@@ -1,13 +1,14 @@
 
 #include <Model/Primitives/Parallelogram.h>
-#include <Interface/InterfaceClassInfo.h>
+#include <Interface/InterfaceRTTI.h>
 #include <Interface/RayPacket.h>
 #include <Core/Persistent/ArchiveElement.h>
-#include <Core/Persistent/ClassInfo.h>
+#include <Core/Persistent/MantaRTTI.h>
 #include <Core/Geometry/BBox.h>
 #include <Core/Math/MiscMath.h>
 #include <MantaSSE.h>
 #include <Core/Math/SSEDefs.h>
+#include <Core/Util/NotFinished.h>
 
 using namespace Manta;
 using SCIRun::Abs;
@@ -551,14 +552,14 @@
 }
 
 namespace Manta {
-  DECLARE_CLASSINFO_DERIVEDCLASS2(Parallelogram, PrimitiveCommon, 
TexCoordMapper, ConcreteClass, readwriteMethod);
-  REGISTER_CLASS(Parallelogram);
+  MANTA_DECLARE_RTTI_DERIVEDCLASS2(Parallelogram, PrimitiveCommon, 
TexCoordMapper, ConcreteClass, readwriteMethod);
+  MANTA_REGISTER_CLASS(Parallelogram);
 }
 
 void Parallelogram::readwrite(ArchiveElement* archive)
 {
-  ClassInfo<PrimitiveCommon>::readwrite(archive, *this);
-  ClassInfo<TexCoordMapper>::readwrite(archive, *this);
+  MantaRTTI<PrimitiveCommon>::readwrite(archive, *this);
+  MantaRTTI<TexCoordMapper>::readwrite(archive, *this);
   archive->readwrite("anchor", anchor);
   archive->readwrite("v1", v1);
   archive->readwrite("v2", v2);

Modified: branches/persistent/Model/Primitives/PrimitiveCommon.cc
==============================================================================
--- branches/persistent/Model/Primitives/PrimitiveCommon.cc     (original)
+++ branches/persistent/Model/Primitives/PrimitiveCommon.cc     Fri Oct 26 
11:34:34 2007
@@ -1,9 +1,9 @@
 
 #include <Model/Primitives/PrimitiveCommon.h>
 #include <Core/Persistent/ArchiveElement.h>
-#include <Core/Persistent/ClassInfo.h>
+#include <Core/Persistent/MantaRTTI.h>
 #include <Interface/Material.h>
-#include <Interface/InterfaceClassInfo.h>
+#include <Interface/InterfaceRTTI.h>
 #include <Model/TexCoordMappers/UniformMapper.h>
 #include <assert.h>
 
@@ -72,9 +72,11 @@
   return success;
 }
 
+MANTA_REGISTER_CLASS(PrimitiveCommon);
+
 void PrimitiveCommon::readwrite(ArchiveElement* archive)
 {
-  ClassInfo<Primitive>::readwrite(archive, *this);
+  MantaRTTI<Primitive>::readwrite(archive, *this);
   archive->readwrite("material", material);
   archive->readwrite("tex", tex);
 }

Modified: branches/persistent/Model/Primitives/PrimitiveCommon.h
==============================================================================
--- branches/persistent/Model/Primitives/PrimitiveCommon.h      (original)
+++ branches/persistent/Model/Primitives/PrimitiveCommon.h      Fri Oct 26 
11:34:34 2007
@@ -4,7 +4,7 @@
 
 #include <Interface/Interpolable.h>
 #include <Interface/Primitive.h>
-#include <Core/Persistent/ClassInfo.h>
+#include <Core/Persistent/MantaRTTI.h>
 
 namespace Manta {
   class ArchiveElement;
@@ -42,9 +42,7 @@
     PrimitiveCommon &operator = ( const PrimitiveCommon & );
   };
 
-  template<>
-  class ClassInfo<PrimitiveCommon> : public 
ClassInfo_DerivedClass<PrimitiveCommon, Primitive>, public 
ClassInfo_readwriteMethod<PrimitiveCommon> {
-  };
+  MANTA_DECLARE_RTTI_DERIVEDCLASS(PrimitiveCommon, Primitive, AbstractClass, 
readwriteMethod);
 
 }
 

Modified: branches/persistent/Model/Primitives/Sphere.cc
==============================================================================
--- branches/persistent/Model/Primitives/Sphere.cc      (original)
+++ branches/persistent/Model/Primitives/Sphere.cc      Fri Oct 26 11:34:34 
2007
@@ -6,9 +6,9 @@
 #include <Core/Math/Expon.h>
 #include <Core/Math/SSEDefs.h>
 #include <Core/Persistent/ArchiveElement.h>
-#include <Core/Persistent/ClassInfo.h>
+#include <Core/Persistent/MantaRTTI.h>
 #include <Interface/RayPacket.h>
-#include <Interface/InterfaceClassInfo.h>
+#include <Interface/InterfaceRTTI.h>
 #include <MantaSSE.h>
 
 using namespace Manta;
@@ -417,13 +417,13 @@
 }
 
 namespace Manta {
-  DECLARE_CLASSINFO_DERIVEDCLASS(Sphere, PrimitiveCommon, ConcreteClass, 
readwriteMethod);
-  REGISTER_CLASS(Sphere);
+  MANTA_DECLARE_RTTI_DERIVEDCLASS(Sphere, PrimitiveCommon, ConcreteClass, 
readwriteMethod);
+  MANTA_REGISTER_CLASS(Sphere);
 }
 
 void Sphere::readwrite(ArchiveElement* archive)
 {
-  ClassInfo<PrimitiveCommon>::readwrite(archive, *this);
+  MantaRTTI<PrimitiveCommon>::readwrite(archive, *this);
   archive->readwrite("center", center);
   archive->readwrite("radius", radius);
   if(archive->reading())

Modified: branches/persistent/Model/TexCoordMappers/UniformMapper.cc
==============================================================================
--- branches/persistent/Model/TexCoordMappers/UniformMapper.cc  (original)
+++ branches/persistent/Model/TexCoordMappers/UniformMapper.cc  Fri Oct 26 
11:34:34 2007
@@ -1,6 +1,6 @@
 
 #include <Model/TexCoordMappers/UniformMapper.h>
-#include <Interface/InterfaceClassInfo.h>
+#include <Interface/InterfaceRTTI.h>
 #include <Interface/RayPacket.h>
 
 using namespace Manta;
@@ -82,11 +82,11 @@
 }
 
 namespace Manta {
-  DECLARE_CLASSINFO_DERIVEDCLASS(UniformMapper, TexCoordMapper, 
ConcreteClass, readwriteMethod);
-  REGISTER_CLASS(UniformMapper);
+  MANTA_DECLARE_RTTI_DERIVEDCLASS(UniformMapper, TexCoordMapper, 
ConcreteClass, readwriteMethod);
+  MANTA_REGISTER_CLASS(UniformMapper);
 };
 
 void UniformMapper::readwrite(ArchiveElement* archive)
 {
-  ClassInfo<TexCoordMapper>::readwrite(archive, *this);
+  MantaRTTI<TexCoordMapper>::readwrite(archive, *this);
 }

Modified: branches/persistent/Model/Textures/CheckerTexture.h
==============================================================================
--- branches/persistent/Model/Textures/CheckerTexture.h (original)
+++ branches/persistent/Model/Textures/CheckerTexture.h Fri Oct 26 11:34:34 
2007
@@ -6,7 +6,7 @@
 #include <Core/Color/Color.h>
 #include <Core/Geometry/Vector.h>
 #include <Core/Persistent/ArchiveElement.h>
-#include <Interface/InterfaceClassInfo.h>
+#include <Interface/InterfaceRTTI.h>
 #include <Interface/RayPacket.h>
 #include <MantaSSE.h>
 
@@ -89,12 +89,12 @@
 #endif
 
   template<class ValueType>
-    class ClassInfo<CheckerTexture<ValueType> > : public 
ClassInfo_DerivedClass<CheckerTexture<ValueType>, Texture<ValueType> >, 
public ClassInfo_ConcreteClass<CheckerTexture<ValueType> >, public 
ClassInfo_readwriteMethod<CheckerTexture<ValueType> > {
+    class MantaRTTI<CheckerTexture<ValueType> > : public 
MantaRTTI_DerivedClass<CheckerTexture<ValueType>, Texture<ValueType> >, 
public MantaRTTI_ConcreteClass<CheckerTexture<ValueType> >, public 
MantaRTTI_readwriteMethod<CheckerTexture<ValueType> > {
   public:
     class Initializer {
     public:
       Initializer() {
-        ClassInfo<CheckerTexture<ValueType> 
>::registerClass("CheckerTexture<"+ClassInfo<ValueType>::getPublicClassname()+">");
+        MantaRTTI<CheckerTexture<ValueType> 
>::registerClass("CheckerTexture<"+MantaRTTI<ValueType>::getPublicClassname()+">");
       }
       void forceinit() {
       }
@@ -103,7 +103,7 @@
   };
 
   template<class ValueType>
-  typename ClassInfo<CheckerTexture<ValueType> >::Initializer 
ClassInfo<CheckerTexture<ValueType> >::init;
+  typename MantaRTTI<CheckerTexture<ValueType> >::Initializer 
MantaRTTI<CheckerTexture<ValueType> >::init;
 
   template<class ValueType>
   void CheckerTexture<ValueType>::readwrite(ArchiveElement* archive)
@@ -123,7 +123,7 @@
   template<class ValueType>
   CheckerTexture<ValueType>::~CheckerTexture()
   {
-    ClassInfo<CheckerTexture<ValueType> >::init.forceinit();
+    MantaRTTI<CheckerTexture<ValueType> >::init.forceinit();
   }
   
   template<>

Modified: branches/persistent/Model/Textures/Constant.h
==============================================================================
--- branches/persistent/Model/Textures/Constant.h       (original)
+++ branches/persistent/Model/Textures/Constant.h       Fri Oct 26 11:34:34 
2007
@@ -4,7 +4,8 @@
 
 #include <Interface/Texture.h>
 #include <Interface/RayPacket.h>
-#include <Interface/InterfaceClassInfo.h>
+
+#include <Interface/InterfaceRTTI.h>
 #include <Core/Persistent/ArchiveElement.h>
 #include <MantaSSE.h>
 
@@ -33,12 +34,12 @@
   };
 
   template<class ValueType>
-    class ClassInfo<Constant<ValueType> > : public 
ClassInfo_DerivedClass<Constant<ValueType>, Texture<ValueType> >, public 
ClassInfo_ConcreteClass<Constant<ValueType> >, public 
ClassInfo_readwriteMethod<Constant<ValueType> > {
+    class MantaRTTI<Constant<ValueType> > : public 
MantaRTTI_DerivedClass<Constant<ValueType>, Texture<ValueType> >, public 
MantaRTTI_ConcreteClass<Constant<ValueType> >, public 
MantaRTTI_readwriteMethod<Constant<ValueType> > {
   public:
     class Initializer {
     public:
       Initializer() {
-        ClassInfo<Constant<ValueType> 
>::registerClass("Constant<"+ClassInfo<ValueType>::getPublicClassname()+">");
+        MantaRTTI<Constant<ValueType> 
>::registerClass("Constant<"+MantaRTTI<ValueType>::getPublicClassname()+">");
       }
       void forceinit() {
       }
@@ -47,7 +48,7 @@
   };
 
   template<class ValueType>
-  typename ClassInfo<Constant<ValueType> >::Initializer 
ClassInfo<Constant<ValueType> >::init;
+  typename MantaRTTI<Constant<ValueType> >::Initializer 
MantaRTTI<Constant<ValueType> >::init;
 
   template<class ValueType>
   Constant<ValueType>::Constant(const ValueType& value)
@@ -63,7 +64,7 @@
   template<class ValueType>
   Constant<ValueType>::~Constant()
   {
-    ClassInfo<Constant<ValueType> >::init.forceinit();
+    MantaRTTI<Constant<ValueType> >::init.forceinit();
   }
   
   template<class ValueType>

Modified: branches/persistent/StandAlone/savescene.cc
==============================================================================
--- branches/persistent/StandAlone/savescene.cc (original)
+++ branches/persistent/StandAlone/savescene.cc Fri Oct 26 11:34:34 2007
@@ -34,7 +34,7 @@
 #include <Core/Persistent/ArchiveElement.h>
 #include <Engine/Factory/Factory.h>
 #include <Interface/MantaInterface.h>
-#include <Interface/InterfaceClassInfo.h>
+#include <Interface/InterfaceRTTI.h>
 #include <Interface/Scene.h>
 #include <SCIRun/Core/Thread/Thread.h>
 
@@ -92,7 +92,7 @@
       throw OutputError("Could not open Archive for writing: " + outfile);
     Scene* scene = rtrt->getScene();
     ArchiveElement* root = archive->getRoot();
-    root->readwrite("scene", scene, Persistent::AnonymousField);
+    root->readwrite("scene", scene);
     delete archive;
     delete rtrt;
 




  • [Manta] r1791 - in branches/persistent: Core Core/Color Core/Geometry Core/Persistent Engine/Factory Interface Model/AmbientLights Model/Backgrounds Model/Groups Model/Lights Model/Materials Model/Primitives Model/TexCoordMappers Model/Textures StandAlone, sparker, 10/26/2007

Archive powered by MHonArc 2.6.16.

Top of page