Text archives Help
- From: sparker@sci.utah.edu
- To: manta@sci.utah.edu
- Subject: [MANTA] r1385 - in branches/persistent: . Core Core/Exceptions Core/Geometry Core/Reflection Engine/Factory Interface Model/Backgrounds Model/Groups Model/Primitives Model/Textures StandAlone
- Date: Sun, 13 May 2007 03:51:52 -0600 (MDT)
Author: sparker
Date: Sun May 13 03:51:44 2007
New Revision: 1385
Added:
branches/persistent/Core/Reflection/Archive.cc
branches/persistent/Core/Reflection/Archive.h
branches/persistent/Core/Reflection/ClassInfo.h
branches/persistent/Core/Reflection/stdClassInfo.h
branches/persistent/Interface/Clonable.cc
branches/persistent/Interface/InterfaceClassInfo.cc
branches/persistent/Interface/InterfaceClassInfo.h
branches/persistent/Interface/Interpolable.cc
Removed:
branches/persistent/Core/Reflection/Reflection.cc
branches/persistent/Core/Reflection/Reflection.h
branches/persistent/Core/Reflection/stdRefl.h
branches/persistent/Interface/InterfaceRefl.h
Modified:
branches/persistent/Core/CMakeLists.txt
branches/persistent/Core/Exceptions/SerializationError.h
branches/persistent/Core/Geometry/Vector.cc
branches/persistent/Core/Geometry/Vector.h
branches/persistent/Core/Reflection/XMLArchive.h
branches/persistent/Engine/Factory/Factory.cc
branches/persistent/Engine/Factory/Factory.h
branches/persistent/Interface/CMakeLists.txt
branches/persistent/Interface/CameraPath.cc
branches/persistent/Interface/Clonable.h
branches/persistent/Interface/Interpolable.h
branches/persistent/Interface/LightSet.cc
branches/persistent/Interface/Primitive.h
branches/persistent/Interface/RenderParameters.cc
branches/persistent/Interface/Scene.cc
branches/persistent/Model/Backgrounds/EnvMapBackground.cc
branches/persistent/Model/Groups/Group.cc
branches/persistent/Model/Groups/Group.h
branches/persistent/Model/Primitives/PrimitiveCommon.cc
branches/persistent/Model/Primitives/PrimitiveCommon.h
branches/persistent/Model/Primitives/Sphere.cc
branches/persistent/Model/Textures/ImageTexture.h
branches/persistent/StandAlone/savescene.cc
branches/persistent/TODO
Log:
Next iteration at persistent i/o
Modified: branches/persistent/Core/CMakeLists.txt
==============================================================================
--- branches/persistent/Core/CMakeLists.txt (original)
+++ branches/persistent/Core/CMakeLists.txt Sun May 13 03:51:44 2007
@@ -56,8 +56,9 @@
Math/SSEDefs.cc
)
SET (CORE_SOURCES ${CORE_SOURCES}
- Reflection/Reflection.h
- Reflection/Reflection.cc
+ Reflection/Archive.h
+ Reflection/Archive.cc
+ Reflection/ClassInfo.h
)
IF (LIBXML2_INCLUDE)
Modified: branches/persistent/Core/Exceptions/SerializationError.h
==============================================================================
--- branches/persistent/Core/Exceptions/SerializationError.h (original)
+++ branches/persistent/Core/Exceptions/SerializationError.h Sun May 13
03:51:44 2007
@@ -36,7 +36,6 @@
#include <sgi_stl_warnings_on.h>
namespace Manta {
- using namespace std;
// Serialization Errors are thrown when a problem occurs reading or
parsing some type
// of input, such as a texture is encountered.
Modified: branches/persistent/Core/Geometry/Vector.cc
==============================================================================
--- branches/persistent/Core/Geometry/Vector.cc (original)
+++ branches/persistent/Core/Geometry/Vector.cc Sun May 13 03:51:44 2007
@@ -28,6 +28,7 @@
*/
#include <Core/Geometry/Vector.h>
+#include <Core/Reflection/Archive.h>
#include <sgi_stl_warnings_off.h>
#include <iostream>
Modified: branches/persistent/Core/Geometry/Vector.h
==============================================================================
--- branches/persistent/Core/Geometry/Vector.h (original)
+++ branches/persistent/Core/Geometry/Vector.h Sun May 13 03:51:44 2007
@@ -42,7 +42,7 @@
#include <Core/Math/Expon.h>
#include <Core/Math/MinMax.h>
#include <Core/Math/MiscMath.h>
-#include <Core/Reflection/Reflection.h>
+#include <Core/Reflection/ClassInfo.h>
#include <sgi_stl_warnings_off.h>
#include <iosfwd>
@@ -557,7 +557,7 @@
}
template<>
- class ReflectionInfo<Vector> : public ReflectionInfo_BaseClass<Vector>,
public ReflectionInfo_readwriteMethod<Vector> {
+ class ClassInfo<Vector> : public ClassInfo_BaseClass<Vector>, public
ClassInfo_readwriteMethod<Vector> {
};
std::ostream& operator<< (std::ostream& os, const Vector& v);
Added: branches/persistent/Core/Reflection/Archive.cc
==============================================================================
--- (empty file)
+++ branches/persistent/Core/Reflection/Archive.cc Sun May 13 03:51:44
2007
@@ -0,0 +1,74 @@
+
+#include <Core/Reflection/Archive.h>
+#include <Core/Exceptions/InputError.h>
+#include <Core/Exceptions/OutputError.h>
+#include <Core/Exceptions/InternalError.h>
+#include <string>
+
+using namespace Manta;
+using namespace std;
+using namespace SCIRun;
+
+struct ArchiveType {
+ string name;
+ Archive* (*readopener)(const std::string&);
+ Archive* (*writeopener)(const std::string&);
+};
+
+static ArchiveType archiveTypes[10];
+static int numArchiveTypes = 0;
+
+bool Archive::registerArchiveType(const std::string& name,
+ Archive* (*readopener)(const std::string&),
+ Archive* (*writeopener)(const
std::string&))
+{
+ int maxArchiveTypes = sizeof(archiveTypes)/sizeof(ArchiveType);
+ if(numArchiveTypes >= maxArchiveTypes)
+ throw InternalError("Maximum number of archive types exceeded",
__FILE__, __LINE__);
+ archiveTypes[numArchiveTypes].name = name;
+ archiveTypes[numArchiveTypes].readopener = readopener;
+ archiveTypes[numArchiveTypes].writeopener = writeopener;
+ numArchiveTypes++;
+ return true;
+}
+
+Archive* Archive::openForReading(const std::string& filename)
+{
+ for(int i=0;i<numArchiveTypes;i++){
+ Archive* (*readopener)(const std::string&) = archiveTypes[i].readopener;
+ if(readopener){
+ Archive* archive = (*readopener)(filename);
+ if(archive)
+ return archive;
+ }
+ }
+ throw InputError("Cannot determine type of file for scene: " + filename);
+}
+
+Archive* Archive::openForWriting(const std::string& filename)
+{
+ Archive* result = 0;
+ for(int i=0;i<numArchiveTypes;i++){
+ Archive* (*writeopener)(const std::string&) =
archiveTypes[i].writeopener;
+ if(writeopener){
+ Archive* archive = (*writeopener)(filename);
+ if(archive){
+ if(result)
+ throw OutputError("Multiple archive writers support filename: " +
filename);
+ result = archive;
+ }
+ }
+ }
+ if(!result)
+ throw OutputError("Cannot determine archive writer for filename: " +
filename);
+ return result;
+}
+
+Archive::Archive(bool isreading)
+ : isreading(isreading)
+{
+}
+
+Archive::~Archive()
+{
+}
Added: branches/persistent/Core/Reflection/Archive.h
==============================================================================
--- (empty file)
+++ branches/persistent/Core/Reflection/Archive.h Sun May 13 03:51:44
2007
@@ -0,0 +1,137 @@
+
+#ifndef Manta_Archive_h
+#define Manta_Archive_h
+
+#include <Core/Reflection/ClassInfo.h>
+#include <Core/Exceptions/SerializationError.h>
+#include <Core/Util/NotFinished.h>
+#include <iostream>
+#include <map>
+#include <string>
+#include <typeinfo>
+
+namespace Manta {
+ class Archive {
+ public:
+ template<class T>
+ void readwrite(const char* fieldname, T& data);
+ template<class T>
+ void readwrite(const char* fieldname, T*& data);
+ template<class T>
+ void readwrite(const char* fieldname, const T*& data);
+ template<class T>
+ void readwriteObject(T*& data);
+
+ virtual void readwrite(const char* fieldname, int& data) = 0;
+ virtual void readwrite(const char* fieldname, float& data) = 0;
+ virtual void readwrite(const char* fieldname, float* data, int
numElements) = 0;
+ virtual void readwrite(const char* fieldname, double& data) = 0;
+
+ bool reading() const {
+ return isreading;
+ }
+ bool writing() const {
+ return !isreading;
+ }
+ static Archive* openForReading(const std::string& filename);
+ static Archive* openForWriting(const std::string& filename);
+ virtual std::string getClassname() const = 0;
+
+ virtual Archive* findField(const std::string& fieldname) const = 0;
+ virtual Archive* createField(const std::string& fieldname, const
std::string& classname) = 0;
+ //virtual Archive* addSequence(const std::string& sequencename);
+ virtual bool isNullPointer() const = 0;
+ virtual void writeNullPointer() = 0;
+
+ virtual ~Archive();
+ protected:
+ static bool registerArchiveType(const std::string& name, Archive*
(*readopener)(const std::string&), Archive* (*writeopener)(const
std::string&));
+ Archive(bool isreading);
+ bool isreading;
+ private:
+
+ };
+
+ template<class T>
+ void Archive::readwrite(const char* fieldname, T& data)
+ {
+ if(writing() && typeid(T) != typeid(data))
+ throw SerializationError("Error, cannot serialize reference to derived
class");
+
+ Archive* subArchive;
+ if(reading()){
+ subArchive = findField(fieldname);
+ if(!subArchive)
+ throw SerializationError("Cannot find field: " +
std::string(fieldname));
+ } else {
+ std::string classname = ClassInfo<T>::getPublicClassname();
+ subArchive = createField(fieldname, classname);
+ }
+ ClassInfo<T>::readwrite(subArchive, data);
+ delete subArchive;
+ }
+
+
+ template<class T>
+ void Archive::readwrite(const char* fieldname, T*& data) {
+ Archive* subArchive;
+ if(reading()){
+ subArchive = findField(fieldname);
+ if(!subArchive)
+ throw SerializationError("Cannot find field: " +
std::string(fieldname));
+ } else {
+ std::string classname = ClassInfo<T>::getPublicClassname();
+ subArchive = createField(fieldname, classname);
+ }
+ subArchive->readwriteObject(data);
+ delete subArchive;
+ }
+
+ template<class T>
+ void Archive::readwrite(const char* fieldname, const T*& data) {
+ if(reading()){
+ T* tmpdata;
+ readwrite(fieldname, tmpdata);
+ data = tmpdata;
+ } else {
+ T* tmpdata = const_cast<T*>(data);
+ readwrite(fieldname, tmpdata);
+ }
+ }
+
+ template<class T>
+ void Archive::readwriteObject(T*& data) {
+ if(reading()){
+ if(isNullPointer()){
+ data = 0;
+ return;
+ } else {
+ std::string classname = getClassname();
+ typename ClassDatabase<T>::Entry* dbentry =
ClassDatabase<T>::getEntry(classname);
+ if(!dbentry)
+ throw SerializationError("Cannot create class: " + classname + "
due to missing ClassInfo");
+ data = dbentry->createInstance();
+ dbentry->readwrite(this, data);
+ }
+ } else {
+ // Writing
+ if(!data){
+ writeNullPointer();
+ return;
+ }
+ if(typeid(T) == typeid(*data)){
+ ClassInfo<T>::readwrite(this, *data);
+ } 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");
+ }
+ dbentry->readwrite(this, data);
+ }
+ }
+ }
+
+}//namespace
+
+#endif
Added: branches/persistent/Core/Reflection/ClassInfo.h
==============================================================================
--- (empty file)
+++ branches/persistent/Core/Reflection/ClassInfo.h Sun May 13 03:51:44
2007
@@ -0,0 +1,237 @@
+
+#ifndef Manta_Reflection_h
+#define Manta_Reflection_h
+
+#include <Core/Exceptions/SerializationError.h>
+#include <Core/Exceptions/InternalError.h>
+#include <Core/Util/NotFinished.h>
+#include <iostream>
+#include <map>
+#include <string>
+#include <typeinfo>
+
+namespace Manta {
+ class Archive;
+
+ // 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 {
+ 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
+ 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 void readwrite(Archive* archive, T* ptr) const = 0;
+ virtual const std::type_info& get_typeinfo() const = 0;
+ };
+
+ private:
+ template<class Class>
+ class ConcreteEntry : public Entry {
+ public:
+ virtual ~ConcreteEntry() {}
+ virtual Class* createInstance() const {
+ return ClassInfo<Class>::createInstance();
+ }
+ virtual void readwrite(Archive* archive, T* ptr) const {
+ Class* derivedptr = dynamic_cast<Class*>(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)",
+ __FILE__, __LINE__);
+ }
+ ClassInfo<Class>::readwrite(archive, *derivedptr);
+ }
+ virtual const std::type_info& get_typeinfo() const {
+ return typeid(Class);
+ }
+ };
+
+ public:
+ template<class C>
+ static void registerClass(const std::string& name) {
+ ClassDatabase<T>* db = singleton();
+ ConcreteEntry<C>* entry = new ConcreteEntry<C>();
+ std::pair<typename namedb_type::iterator, bool> result;
+ result = db->database_publicname.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();
+ 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));
+
+ 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();
+ std::string n2 = ti.name();
+ throw SCIRun::InternalError("Distinct types (" + n1 + " and " + n2
+ ") registered under the same C++ type name (" + name + ")",
+ __FILE__, __LINE__);
+ }
+ }
+ }
+
+ static Entry* getEntry(const std::string& name) {
+ return singleton()->_getEntry(name);
+ }
+ static Entry* getEntry(const std::type_info& ti){
+ return singleton()->_getEntry(ti);
+ }
+
+ private:
+
+ static ClassDatabase<T>* singleton() {
+ if(!singleton_instance)
+ singleton_instance = new ClassDatabase<T>();
+ return singleton_instance;
+ }
+ Entry* _getEntry(const std::string& name) {
+ typename std::map<std::string, Entry*>::iterator iter =
database_publicname.find(name);
+ if(iter == database_publicname.end())
+ return 0;
+ return iter->second;
+ }
+ Entry* _getEntry(const std::type_info& ti) {
+ typename std::map<const char*, Entry*>::iterator iter =
database_typeinfoname.find(ti.name());
+ if(iter == database_typeinfoname.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;
+ };
+
+ template<class T>
+ ClassDatabase<T>* ClassDatabase<T>::singleton_instance;
+
+
+ // Helper classes for implementing ClassInfo specializations
+ template<class T>
+ class ClassInfo_readwriteMethod {
+ public:
+ static void readwrite(Archive* archive, T& data) {
+ data.readwrite(archive);
+ }
+ private:
+ ClassInfo_readwriteMethod();
+ };
+
+ template<class T>
+ class ClassInfo_readwriteNone {
+ public:
+ static void readwrite(Archive* archive, T& data) {
+ }
+ private:
+ ClassInfo_readwriteNone();
+ };
+
+ template<class T>
+ class ClassInfo_ConcreteClass {
+ public:
+ static T* createInstance() {
+ return new T();
+ }
+ private:
+ ClassInfo_ConcreteClass();
+ };
+ template<class T>
+ class ClassInfo_AbstractClass {
+ public:
+ static T* createInstance() {
+ return 0;
+ }
+ private:
+ ClassInfo_AbstractClass();
+ };
+
+ template<class T>
+ class ClassInfo_BaseClass {
+ public:
+ static std::string getPublicClassname() {
+ if(!classname)
+ throw SCIRun::InternalError(std::string("Class: ") +
typeid(T).name() + " is not registered", __FILE__, __LINE__);
+ return *classname;
+ }
+ static bool registerClass(const std::string& _classname);
+
+ template<class C>
+ static void registerClassAndParents(const std::string& classname) {
+ ClassDatabase<T>::template registerClass<C>(classname);
+ }
+ private:
+ ClassInfo_BaseClass();
+ static std::string* classname;
+ };
+ template<class T> std::string* ClassInfo_BaseClass<T>::classname;
+
+ template<class T>
+ bool ClassInfo_BaseClass<T>::registerClass(const std::string& _classname)
+ {
+ std::cerr << "Registering class: " << _classname << '\n';
+ if(!classname)
+ classname = new std::string(_classname);
+ registerClassAndParents<T>(_classname);
+ return true;
+ }
+
+ template<class T, class Parent>
+ class ClassInfo_DerivedClass {
+ public:
+ static std::string getPublicClassname() {
+ if(!classname)
+ throw SCIRun::InternalError(std::string("Class: ") +
typeid(T).name() + " is not registered", __FILE__, __LINE__);
+ return *classname;
+ }
+ static bool registerClass(const std::string& _classname);
+
+ template<class C>
+ static void registerClassAndParents(const std::string& classname) {
+ ClassDatabase<T>::template registerClass<C>(classname);
+ ClassInfo<Parent>::template registerClassAndParents<C>(classname);
+ }
+ private:
+ ClassInfo_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>
+ bool ClassInfo_DerivedClass<T, Parent>::registerClass(const std::string&
_classname)
+ {
+ std::cerr << "Registering class: " << _classname << '\n';
+ if(!classname)
+ classname = new std::string(_classname);
+ registerClassAndParents<T>(_classname);
+ return true;
+ }
+}
+
+#endif
Modified: branches/persistent/Core/Reflection/XMLArchive.h
==============================================================================
--- branches/persistent/Core/Reflection/XMLArchive.h (original)
+++ branches/persistent/Core/Reflection/XMLArchive.h Sun May 13 03:51:44
2007
@@ -2,7 +2,7 @@
#ifndef Manta_XMLArchive_h
#define Manta_XMLArchive_h
-#include <Core/Reflection/Reflection.h>
+#include <Core/Reflection/Archive.h>
#include <libxml/tree.h>
namespace Manta {
Added: branches/persistent/Core/Reflection/stdClassInfo.h
==============================================================================
--- (empty file)
+++ branches/persistent/Core/Reflection/stdClassInfo.h Sun May 13 03:51:44
2007
@@ -0,0 +1,44 @@
+
+#ifndef Manta_stdRefl_h
+#define Manta_stdRefl_h
+
+#include <Core/Reflection/ClassInfo.h>
+#include <Core/Util/NotFinished.h>
+#include <vector>
+
+namespace Manta {
+ template<class T>
+ class ClassInfo<std::vector<T> > {
+ public:
+ static std::string getPublicClassname() {
+ if(!classname)
+ throw SCIRun::InternalError(std::string("vector<") +
typeid(T).name() + "> is not registered", __FILE__, __LINE__);
+ return *classname;
+ }
+ static bool registerClass(const std::string& _classname);
+ static T* createInstance() {
+ return new std::vector<T>();
+ }
+ static void readwrite(Archive* archive, std::vector<T>& data) {
+ NOT_FINISHED("vector readwrite");
+ }
+ private:
+ class Initializer {
+ public:
+ Initializer() {
+ std::string name = "std::vector<" +
ClassInfo<T>::getPublicClassname() + ">";
+ std::cerr << "Registering vector: " << name << '\n';
+ classname = new std::string(name);
+ ClassDatabase<T>::template registerClass<std::vector<T> >(name);
+ }
+ };
+ static Initializer init;
+ static std::string* classname;
+ };
+ template<class T>
+ std::string* ClassInfo<std::vector<T> >::classname;
+ template<class T>
+ ClassInfo<std::vector<T> >::Initializer ClassInfo<std::vector<T> >::init;
+}
+
+#endif
Modified: branches/persistent/Engine/Factory/Factory.cc
==============================================================================
--- branches/persistent/Engine/Factory/Factory.cc (original)
+++ branches/persistent/Engine/Factory/Factory.cc Sun May 13 03:51:44
2007
@@ -33,12 +33,12 @@
#include <Core/Exceptions/IllegalValue.h>
#include <Core/Exceptions/InputError.h>
#include <Core/Exceptions/InternalError.h>
-#include <Core/Reflection/Reflection.h>
+#include <Core/Reflection/Archive.h>
#include <Core/Util/Args.h>
#include <Engine/Factory/RegisterKnownComponents.h>
#include <Interface/Context.h>
#include <Interface/MantaInterface.h>
-#include <Interface/InterfaceRefl.h>
+#include <Interface/InterfaceClassInfo.h>
#include <Interface/Scene.h>
#include <errno.h>
@@ -51,6 +51,9 @@
using namespace Manta;
using namespace SCIRun;
+Factory::~Factory()
+{
+}
ImageDisplay *Factory::createImageDisplay(const string& spec ) const
{
Modified: branches/persistent/Engine/Factory/Factory.h
==============================================================================
--- branches/persistent/Engine/Factory/Factory.h (original)
+++ branches/persistent/Engine/Factory/Factory.h Sun May 13 03:51:44
2007
@@ -65,6 +65,7 @@
manta_interface( interface_ ) {
if (AutoRegisterKnownComponents) registerKnownComponents( this );
}
+ virtual ~Factory();
typedef vector<string> listType;
Modified: branches/persistent/Interface/CMakeLists.txt
==============================================================================
--- branches/persistent/Interface/CMakeLists.txt (original)
+++ branches/persistent/Interface/CMakeLists.txt Sun May 13 03:51:44
2007
@@ -10,6 +10,7 @@
CameraPath.h
CameraPath.cc
Clonable.h
+ Clonable.cc
Context.h
Fragment.h
IdleMode.h
@@ -20,7 +21,10 @@
ImageDisplay.cc
ImageTraverser.h
ImageTraverser.cc
+ InterfaceClassInfo.h
+ InterfaceClassInfo.cc
Interpolable.h
+ Interpolable.cc
Light.h
Light.cc
LightSet.h
Modified: branches/persistent/Interface/CameraPath.cc
==============================================================================
--- branches/persistent/Interface/CameraPath.cc (original)
+++ branches/persistent/Interface/CameraPath.cc Sun May 13 03:51:44 2007
@@ -12,7 +12,7 @@
CameraPath::CameraPath(MantaInterface* interface, string const& fname,
IOMode mode, LoopMode loop, int max_count, int
offset) :
interface(interface), fname(fname), loop(loop), max_count(max_count),
offset(offset), handle(0),
- frame(0), max_frame(0), anim(false)
+ anim(false), frame(0), max_frame(0)
{
if (mode==ReadKnots) {
readKnots();
Added: branches/persistent/Interface/Clonable.cc
==============================================================================
--- (empty file)
+++ branches/persistent/Interface/Clonable.cc Sun May 13 03:51:44 2007
@@ -0,0 +1,8 @@
+
+#include <Interface/Clonable.h>
+
+using namespace Manta;
+
+Clonable::~Clonable()
+{
+}
Modified: branches/persistent/Interface/Clonable.h
==============================================================================
--- branches/persistent/Interface/Clonable.h (original)
+++ branches/persistent/Interface/Clonable.h Sun May 13 03:51:44 2007
@@ -4,6 +4,7 @@
namespace Manta {
class Clonable {
public:
+ virtual ~Clonable();
enum CloneDepth {shallow //
};
virtual Clonable* clone(CloneDepth depth, Clonable* incoming=0)
Added: branches/persistent/Interface/InterfaceClassInfo.cc
==============================================================================
--- (empty file)
+++ branches/persistent/Interface/InterfaceClassInfo.cc Sun May 13 03:51:44
2007
@@ -0,0 +1,10 @@
+
+#include <Interface/InterfaceClassInfo.h>
+#include <Interface/Interpolable.h>
+#include <Interface/Object.h>
+
+using namespace std;
+using namespace Manta;
+
+bool ClassInfo<Interpolable>::force_initialize =
ClassInfo<Interpolable>::registerClass("Interpolable");
+bool ClassInfo<Object>::force_initialize =
ClassInfo<Object>::registerClass("Object");
Added: branches/persistent/Interface/InterfaceClassInfo.h
==============================================================================
--- (empty file)
+++ branches/persistent/Interface/InterfaceClassInfo.h Sun May 13 03:51:44
2007
@@ -0,0 +1,83 @@
+
+#ifndef Manta_InterfaceRefl_h
+#define Manta_InterfaceRefl_h
+
+#include <Core/Reflection/ClassInfo.h>
+
+namespace Manta {
+ class AmbientLight;
+ class Background;
+ class Clonable;
+ class Interpolable;
+ class Light;
+ class LightSet;
+ class Material;
+ class Object;
+ class Primitive;
+ class RenderParameters;
+ class TexCoordMapper;
+ class Scene;
+
+ template<>
+ class ClassInfo<AmbientLight> : public ClassInfo_BaseClass<AmbientLight>,
public ClassInfo_AbstractClass<AmbientLight>, public
ClassInfo_readwriteNone<AmbientLight> {
+ static bool force_initialize;
+ };
+
+ template<>
+ class ClassInfo<Light> : public ClassInfo_BaseClass<Light>, public
ClassInfo_AbstractClass<AmbientLight>, public ClassInfo_readwriteNone<Light> {
+ static bool force_initialize;
+ };
+
+ template<>
+ class ClassInfo<Material> : public ClassInfo_DerivedClass<Material,
Interpolable>, public ClassInfo_AbstractClass<Material>, public
ClassInfo_readwriteNone<Material> {
+ static bool force_initialize;
+ };
+
+ template<>
+ class ClassInfo<TexCoordMapper> : public
ClassInfo_DerivedClass<TexCoordMapper, Interpolable>, public
ClassInfo_AbstractClass<TexCoordMapper>, public
ClassInfo_readwriteNone<TexCoordMapper> {
+ static bool force_initialize;
+ };
+
+ template<>
+ class ClassInfo<Scene> : public ClassInfo_BaseClass<Scene>, public
ClassInfo_ConcreteClass<Scene>, public ClassInfo_readwriteMethod<Scene> {
+ static bool force_initialize;
+ };
+
+ template<>
+ class ClassInfo<Background> : public ClassInfo_BaseClass<Background>,
public ClassInfo_AbstractClass<Background>, public
ClassInfo_readwriteNone<Background> {
+ static bool force_initialize;
+ };
+
+ template<>
+ class ClassInfo<Object> : public ClassInfo_DerivedClass<Object,
Interpolable>, public ClassInfo_AbstractClass<Object>, public
ClassInfo_readwriteNone<Object> {
+ static bool force_initialize;
+ };
+
+ template<>
+ class ClassInfo<Primitive> : public ClassInfo_DerivedClass<Primitive,
Object>, public ClassInfo_AbstractClass<Primitive>, public
ClassInfo_readwriteNone<Primitive> {
+ static bool force_initialize;
+ };
+
+ template<>
+ class ClassInfo<LightSet> : public ClassInfo_BaseClass<LightSet>, public
ClassInfo_ConcreteClass<LightSet>, public ClassInfo_readwriteMethod<LightSet>
{
+ static bool force_initialize;
+ };
+
+ template<>
+ class ClassInfo<RenderParameters> : public
ClassInfo_BaseClass<RenderParameters>, public
ClassInfo_readwriteMethod<RenderParameters> {
+ static bool force_initialize;
+ };
+
+ template<>
+ class ClassInfo<Interpolable> : public
ClassInfo_DerivedClass<Interpolable, Clonable>, public
ClassInfo_AbstractClass<Interpolable>, public
ClassInfo_readwriteNone<Clonable> {
+ static bool force_initialize;
+ };
+
+ template<>
+ class ClassInfo<Clonable> : public ClassInfo_BaseClass<Clonable>, public
ClassInfo_AbstractClass<Clonable>, public ClassInfo_readwriteNone<Clonable> {
+ static bool force_initialize;
+ };
+
+}
+
+#endif
Added: branches/persistent/Interface/Interpolable.cc
==============================================================================
--- (empty file)
+++ branches/persistent/Interface/Interpolable.cc Sun May 13 03:51:44
2007
@@ -0,0 +1,8 @@
+
+#include <Interface/Interpolable.h>
+
+using namespace Manta;
+
+Interpolable::~Interpolable()
+{
+}
Modified: branches/persistent/Interface/Interpolable.h
==============================================================================
--- branches/persistent/Interface/Interpolable.h (original)
+++ branches/persistent/Interface/Interpolable.h Sun May 13 03:51:44
2007
@@ -7,6 +7,7 @@
namespace Manta {
class Interpolable : public Clonable {
public:
+ virtual ~Interpolable();
enum InterpErr{success,
notInterpolable}; //cannot interpolate. No interpolation
performed.
Modified: branches/persistent/Interface/LightSet.cc
==============================================================================
--- branches/persistent/Interface/LightSet.cc (original)
+++ branches/persistent/Interface/LightSet.cc Sun May 13 03:51:44 2007
@@ -2,8 +2,9 @@
#include <Interface/LightSet.h>
#include <Interface/AmbientLight.h>
#include <Interface/Light.h>
-#include <Interface/InterfaceRefl.h>
-#include <Core/Reflection/stdRefl.h>
+#include <Interface/InterfaceClassInfo.h>
+#include <Core/Reflection/Archive.h>
+#include <Core/Reflection/stdClassInfo.h>
#include <Core/Util/Assert.h>
#include <sgi_stl_warnings_off.h>
Modified: branches/persistent/Interface/Primitive.h
==============================================================================
--- branches/persistent/Interface/Primitive.h (original)
+++ branches/persistent/Interface/Primitive.h Sun May 13 03:51:44 2007
@@ -19,7 +19,7 @@
RayPacket& rays) const = 0;
virtual void setTexCoordMapper(const TexCoordMapper* new_tex) = 0;
private:
- Primitive(const Primitive&);
+ Primitive(const Primitive&);
Primitive& operator=(const Primitive&);
};
}
Modified: branches/persistent/Interface/RenderParameters.cc
==============================================================================
--- branches/persistent/Interface/RenderParameters.cc (original)
+++ branches/persistent/Interface/RenderParameters.cc Sun May 13 03:51:44
2007
@@ -1,6 +1,6 @@
#include <Interface/RenderParameters.h>
-#include <Core/Reflection/Reflection.h>
+#include <Core/Reflection/Archive.h>
using namespace Manta;
Modified: branches/persistent/Interface/Scene.cc
==============================================================================
--- branches/persistent/Interface/Scene.cc (original)
+++ branches/persistent/Interface/Scene.cc Sun May 13 03:51:44 2007
@@ -1,8 +1,9 @@
#include <Interface/Scene.h>
-#include <Core/Reflection/stdRefl.h>
+#include <Core/Reflection/stdClassInfo.h>
+#include <Core/Reflection/Archive.h>
#include <Interface/Background.h>
-#include <Interface/InterfaceRefl.h>
+#include <Interface/InterfaceClassInfo.h>
#include <Interface/LightSet.h>
using namespace Manta;
@@ -28,7 +29,7 @@
currentBookmark = bookmark;
if(currentBookmark < 0)
currentBookmark = 0;
- if(bookmarks.size() > 0 && currentBookmark >= bookmarks.size())
+ if(bookmarks.size() > 0 && currentBookmark >=
static_cast<int>(bookmarks.size()))
currentBookmark = bookmarks.size()-1;
}
@@ -38,7 +39,7 @@
return 0;
currentBookmark++;
- if(currentBookmark >= bookmarks.size())
+ if(currentBookmark >= static_cast<int>(bookmarks.size()))
currentBookmark = 0;
return &bookmarks[currentBookmark]->cameradata;
Modified: branches/persistent/Model/Backgrounds/EnvMapBackground.cc
==============================================================================
--- branches/persistent/Model/Backgrounds/EnvMapBackground.cc (original)
+++ branches/persistent/Model/Backgrounds/EnvMapBackground.cc Sun May 13
03:51:44 2007
@@ -93,6 +93,6 @@
Packet<Color> colors;
image->mapValues(colors, context, rays);
- for (unsigned int i=rays.begin(); i<rays.end(); ++i)
+ for (int i=rays.begin(); i<rays.end(); ++i)
rays.setColor(i, colors.get(i));
}
Modified: branches/persistent/Model/Groups/Group.cc
==============================================================================
--- branches/persistent/Model/Groups/Group.cc (original)
+++ branches/persistent/Model/Groups/Group.cc Sun May 13 03:51:44 2007
@@ -1,5 +1,8 @@
#include <Model/Groups/Group.h>
+#include <Interface/InterfaceClassInfo.h>
+#include <Core/Reflection/stdClassInfo.h>
+#include <Core/Reflection/Archive.h>
#include <SCIRun/Core/Util/Assert.h>
#include <algorithm>
#include <assert.h>
@@ -53,7 +56,7 @@
vector<keyframe_t> keyframes(group_keyframes);
Group *groups[group_keyframes.size()];
- for(int frame=0; frame < keyframes.size(); ++frame) {
+ for(unsigned int frame=0; frame < keyframes.size(); ++frame) {
Group *group = dynamic_cast<Group*>(group_keyframes[frame].keyframe);
if (group == NULL)
return notInterpolable;
@@ -66,7 +69,7 @@
int start = proc*serialSize/numProc;
int end = (proc+1)*serialSize/numProc;
for (int i=start; i < end; ++i) {
- for(int frame=0; frame < keyframes.size(); ++frame) {
+ for(unsigned int frame=0; frame < keyframes.size(); ++frame) {
keyframes[frame].keyframe = groups[frame]->get(i);
}
InterpErr retcode = objs[i]->serialInterpolate(keyframes);
@@ -75,8 +78,8 @@
}
//now do the parallel objects
- for (int i=serialSize; i < objs.size(); ++i) {
- for(int frame=0; frame < keyframes.size(); ++frame) {
+ for (unsigned int i=serialSize; i < objs.size(); ++i) {
+ for(unsigned int frame=0; frame < keyframes.size(); ++frame) {
keyframes[frame].keyframe = groups[frame]->get(i);
}
InterpErr retcode = objs[i]->parallelInterpolate(keyframes, proc,
numProc);
@@ -130,7 +133,7 @@
//partition so that objs are serial and then parallel
parallelSplit = partition(objs.begin(), objs.end(), isSerial);
- for(int i=0; i<objs.size(); ++i)
+ for(unsigned int i=0; i<objs.size(); ++i)
objs[i]->preprocess(context);
for(vector<Object*>::iterator iter = objs.begin();
@@ -150,4 +153,19 @@
for(vector<Object*>::const_iterator iter = objs.begin();
iter != objs.end(); ++iter)
(*iter)->intersect(context, rays);
+}
+
+namespace Manta {
+template<>
+class ClassInfo<Group> : public ClassInfo_DerivedClass<Group, Object>,
public ClassInfo_ConcreteClass<Group>, public ClassInfo_readwriteMethod<Group>
+{
+ static bool force_initialize;
+};
+}
+bool ClassInfo<Group>::force_initialize =
ClassInfo<Group>::registerClass("Group");
+
+void Group::readwrite(Archive* archive)
+{
+ ClassInfo<Object>::readwrite(archive, *this);
+ archive->readwrite("objs", objs);
}
Modified: branches/persistent/Model/Groups/Group.h
==============================================================================
--- branches/persistent/Model/Groups/Group.h (original)
+++ branches/persistent/Model/Groups/Group.h Sun May 13 03:51:44 2007
@@ -32,6 +32,7 @@
#include <Interface/Object.h>
+#include <Core/Reflection/ClassInfo.h>
#include <sgi_stl_warnings_off.h>
#include <vector>
#include <string>
@@ -69,6 +70,7 @@
static Group* create(const vector<string>& args);
+ void readwrite(Archive* archive);
protected:
vector<Object*> objs;
vector<Object*>::iterator parallelSplit; //point to the start of the
parallel objects
Modified: branches/persistent/Model/Primitives/PrimitiveCommon.cc
==============================================================================
--- branches/persistent/Model/Primitives/PrimitiveCommon.cc (original)
+++ branches/persistent/Model/Primitives/PrimitiveCommon.cc Sun May 13
03:51:44 2007
@@ -1,8 +1,9 @@
#include <Model/Primitives/PrimitiveCommon.h>
-#include <Core/Reflection/Reflection.h>
+#include <Core/Reflection/Archive.h>
+#include <Core/Reflection/ClassInfo.h>
#include <Interface/Material.h>
-#include <Interface/InterfaceRefl.h>
+#include <Interface/InterfaceClassInfo.h>
#include <Model/TexCoordMappers/UniformMapper.h>
#include <assert.h>
@@ -52,7 +53,7 @@
float maxT=-1;
int maxTindex=-1;
- for (int frame=0; frame < keyframes.size(); ++frame) {
+ for (unsigned int frame=0; frame < keyframes.size(); ++frame) {
if (keyframes[frame].t > maxT) {
maxT = keyframes[frame].t;
maxTindex = frame;
@@ -71,23 +72,9 @@
return success;
}
-namespace Manta {
- template<>
- class ReflectionInfo<PrimitiveCommon> : public
ReflectionInfo_DerivedClass<PrimitiveCommon, Primitive>
- {
- char force_initialize;
- };
-
-#if 0
- template<>
- ReflectionInfo<PrimitiveCommon>::force_initialize =
ReflectionInfo<PrimitiveCommon>::register_class("Manta::PrimitiveCommon");
-#endif
-}
-
void PrimitiveCommon::readwrite(Archive* archive)
{
- //Primitive::readwrite(archive);
- NOT_FINISHED("readwrite parent");
+ ClassInfo<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 Sun May 13
03:51:44 2007
@@ -4,6 +4,7 @@
#include <Interface/Interpolable.h>
#include <Interface/Primitive.h>
+#include <Core/Reflection/ClassInfo.h>
namespace Manta {
class Archive;
@@ -31,7 +32,6 @@
virtual InterpErr interpolate(const std::vector<keyframe_t> &keyframes);
#endif
- protected:
void readwrite(Archive* archive);
private:
@@ -41,6 +41,11 @@
PrimitiveCommon( const PrimitiveCommon & );
PrimitiveCommon &operator = ( const PrimitiveCommon & );
};
+
+ template<>
+ class ClassInfo<PrimitiveCommon> : public
ClassInfo_DerivedClass<PrimitiveCommon, Primitive>, public
ClassInfo_readwriteMethod<PrimitiveCommon> {
+ };
+
}
#endif
Modified: branches/persistent/Model/Primitives/Sphere.cc
==============================================================================
--- branches/persistent/Model/Primitives/Sphere.cc (original)
+++ branches/persistent/Model/Primitives/Sphere.cc Sun May 13 03:51:44
2007
@@ -1,13 +1,15 @@
#include <Model/Primitives/Sphere.h>
-#include <Interface/RayPacket.h>
#include <Core/Geometry/BBox.h>
#include <Core/Math/MiscMath.h>
#include <Core/Math/Trig.h>
#include <Core/Math/Expon.h>
-#include <MantaSSE.h>
#include <Core/Math/SSEDefs.h>
-#include <Core/Reflection/Reflection.h>
+#include <Core/Reflection/Archive.h>
+#include <Core/Reflection/ClassInfo.h>
+#include <Interface/RayPacket.h>
+#include <Interface/InterfaceClassInfo.h>
+#include <MantaSSE.h>
using namespace Manta;
using namespace SCIRun;
@@ -396,7 +398,7 @@
center = Vector(0,0,0);
radius = 0.0f;
- for (int i=0; i < keyframes.size(); ++i) {
+ for (unsigned int i=0; i < keyframes.size(); ++i) {
Interpolable::keyframe_t kt = keyframes[i];
Sphere *sphere = dynamic_cast<Sphere*>(keyframes[i].keyframe);
if (sphere == NULL)
@@ -412,20 +414,20 @@
namespace Manta {
template<>
-class ReflectionInfo<Sphere> : public ReflectionInfo_DerivedClass<Sphere,
PrimitiveCommon>
+class ClassInfo<Sphere> : public ClassInfo_DerivedClass<Sphere,
PrimitiveCommon>
{
char force_initialize;
};
#if 0
template<>
-bool ReflectionInfo<Sphere>::force_initialize =
ReflectionInfo<Sphere>::register_class("Manta::Sphere");
+bool ClassInfo<Sphere>::force_initialize =
ClassInfo<Sphere>::register_class("Manta::Sphere");
#endif
}
void Sphere::readwrite(Archive* archive)
{
- PrimitiveCommon::readwrite(archive);
+ ClassInfo<PrimitiveCommon>::readwrite(archive, *this);
archive->readwrite("center", center);
archive->readwrite("radius", radius);
if(archive->reading())
Modified: branches/persistent/Model/Textures/ImageTexture.h
==============================================================================
--- branches/persistent/Model/Textures/ImageTexture.h (original)
+++ branches/persistent/Model/Textures/ImageTexture.h Sun May 13 03:51:44
2007
@@ -189,6 +189,9 @@
case Clamp:
result = SCIRun::Clamp(val, 0, size-1);
break;
+ default:
+ result = 0;
+ break;
}
return result;
}
Modified: branches/persistent/StandAlone/savescene.cc
==============================================================================
--- branches/persistent/StandAlone/savescene.cc (original)
+++ branches/persistent/StandAlone/savescene.cc Sun May 13 03:51:44 2007
@@ -30,10 +30,10 @@
#include <Core/Util/Args.h>
#include <Core/Exceptions/IllegalArgument.h>
#include <Core/Exceptions/OutputError.h>
-#include <Core/Reflection/Reflection.h>
+#include <Core/Reflection/Archive.h>
#include <Engine/Factory/Factory.h>
#include <Interface/MantaInterface.h>
-#include <Interface/InterfaceRefl.h>
+#include <Interface/InterfaceClassInfo.h>
#include <Interface/Scene.h>
#include <SCIRun/Core/Thread/Thread.h>
Modified: branches/persistent/TODO
==============================================================================
--- branches/persistent/TODO (original)
+++ branches/persistent/TODO Sun May 13 03:51:44 2007
@@ -1,25 +1,16 @@
-Error checking in xmlarchive
+specialization for vector<T*>
+SError checking in xmlarchive
Set class for top level object
why is maxdepth attached to top object
-complete reflectiondb
Need to mark objects already emitted
-
-XML types:
-1. <object type="a">
- <object type="b">
- </object>
- </object>
-
-2. <object type="b">
- </object>
- <object type="a">
- <ref b/>
- </object>
-
-3. <a>
- <b>
- </b>
- </a>
+reference by id
+can backward references work?
+properly handlenamespaces in:
+ - read
+ - write
+ - register
+fix xml format
+more convenience classinfo classes for common cases?
Cmake:
- Class rtrt fix
- [MANTA] r1385 - in branches/persistent: . Core Core/Exceptions Core/Geometry Core/Reflection Engine/Factory Interface Model/Backgrounds Model/Groups Model/Primitives Model/Textures StandAlone, sparker, 05/13/2007
Archive powered by MHonArc 2.6.16.