Text archives Help
- From: sparker@sci.utah.edu
- To: manta@sci.utah.edu
- Subject: [MANTA] r1395 - in branches/persistent: Core/Reflection Model/Textures
- Date: Thu, 17 May 2007 16:14:33 -0600 (MDT)
Author: sparker
Date: Thu May 17 16:14:33 2007
New Revision: 1395
Modified:
branches/persistent/Core/Reflection/ClassInfo.h
branches/persistent/Core/Reflection/stdClassInfo.h
branches/persistent/Model/Textures/Constant.h
Log:
Working on classinfo for templated classes
Modified: branches/persistent/Core/Reflection/ClassInfo.h
==============================================================================
--- branches/persistent/Core/Reflection/ClassInfo.h (original)
+++ branches/persistent/Core/Reflection/ClassInfo.h Thu May 17 16:14:33
2007
@@ -67,6 +67,7 @@
public:
template<class C>
static void registerClass(const std::string& name) {
+ std::cerr << "register: " << name << '\n';
ClassDatabase<T>* db = singleton();
ConcreteEntry<C>* entry = new ConcreteEntry<C>();
std::pair<typename namedb_type::iterator, bool> result;
@@ -235,6 +236,14 @@
registerClassAndParents<T>(_classname);
return true;
}
+
+ template<>
+ class ClassInfo<float> {
+ public:
+ static std::string getPublicClassname() {
+ return "float";
+ }
+ };
}
// Convenience macros
Modified: branches/persistent/Core/Reflection/stdClassInfo.h
==============================================================================
--- branches/persistent/Core/Reflection/stdClassInfo.h (original)
+++ branches/persistent/Core/Reflection/stdClassInfo.h Thu May 17 16:14:33
2007
@@ -13,9 +13,7 @@
public:
static std::string getPublicClassname() {
init.forceinit();
- if(!classname)
- throw SCIRun::InternalError(std::string("vector<") +
typeid(T).name() + "> is not registered", __FILE__, __LINE__);
- return *classname;
+ return "std::vector<" + ClassInfo<T>::getPublicClassname() + ">";
}
static std::vector<T>* createInstance() {
init.forceinit();
@@ -29,9 +27,7 @@
class Initializer {
public:
Initializer() {
- std::string name = "std::vector<" +
ClassInfo<T>::getPublicClassname() + ">";
- classname = new std::string(name);
- ClassDatabase<std::vector<T> >::template
registerClass<std::vector<T> >(name);
+ ClassDatabase<std::vector<T> >::template
registerClass<std::vector<T> >(getPublicClassname());
}
void forceinit() {
}
@@ -40,18 +36,13 @@
static std::string* classname;
};
template<class T>
- std::string* ClassInfo<std::vector<T> >::classname;
- template<class T>
typename ClassInfo<std::vector<T> >::Initializer ClassInfo<std::vector<T>
>
::init;
template<class T>
class ClassInfo<std::vector<T*> > {
public:
static std::string getPublicClassname() {
- init.forceinit();
- if(!classname)
- throw SCIRun::InternalError(std::string("vector<") +
typeid(T).name() + "*> is not registered", __FILE__, __LINE__);
- return *classname;
+ return "std::vector<" + ClassInfo<T>::getPublicClassname() + "*>";
}
static std::vector<T*>* createInstance() {
init.forceinit();
@@ -74,17 +65,12 @@
}
};
static Initializer init;
- static std::string* classname;
};
template<class T>
ClassInfo<std::vector<T*> >::Initializer::Initializer()
{
- std::string name = "std::vector<" + ClassInfo<T>::getPublicClassname() +
"*>";
- classname = new std::string(name);
- ClassDatabase<std::vector<T*> >::template registerClass<std::vector<T*>
>
(name);
+ ClassDatabase<std::vector<T*> >::template registerClass<std::vector<T*>
>
(getPublicClassname());
}
- template<class T>
- std::string* ClassInfo<std::vector<T*> >::classname;
template<class T>
typename ClassInfo<std::vector<T*> >::Initializer
ClassInfo<std::vector<T*> >::init;
Modified: branches/persistent/Model/Textures/Constant.h
==============================================================================
--- branches/persistent/Model/Textures/Constant.h (original)
+++ branches/persistent/Model/Textures/Constant.h Thu May 17 16:14:33
2007
@@ -4,6 +4,7 @@
#include <Interface/Texture.h>
#include <Interface/RayPacket.h>
+#include <Core/Reflection/Archive.h>
#include <MantaSSE.h>
namespace Manta {
@@ -12,6 +13,7 @@
template<typename ValueType>
class Constant : public Texture<ValueType> {
public:
+ Constant();
Constant(const ValueType& value);
virtual ~Constant();
@@ -21,6 +23,7 @@
ValueType getValue() const { return value; }
void setValue( const ValueType value_ ) { value = value_; }
+ void readwrite(Archive* archive);
private:
Constant(const Constant&);
Constant& operator=(const Constant&);
@@ -29,9 +32,41 @@
};
template<class ValueType>
+ class ClassInfo<Constant<ValueType> > : public
ClassInfo_ConcreteClass<Constant<ValueType> >, public
ClassInfo_readwriteMethod<Constant<ValueType> > {
+ public:
+ static std::string getPublicClassname() {
+ init.forceinit();
+ return "Constant<" + ClassInfo<ValueType>::getPublicClassname() + ">";
+ }
+
+ public:
+ class Initializer {
+ public:
+ Initializer() {
+ std::cerr << "register class: " << getPublicClassname() << '\n';
+ ClassDatabase<Constant<ValueType> >::template
registerClass<Constant<ValueType> >(getPublicClassname());
+ }
+ void forceinit() {
+ std::cerr << "forceinit\n";
+ }
+ };
+ static Initializer init;
+ };
+
+ template<class ValueType>
+ typename ClassInfo<Constant<ValueType> >::Initializer
ClassInfo<Constant<ValueType> >::init;
+
+ template<class ValueType>
Constant<ValueType>::Constant(const ValueType& value)
: value(value)
{
+ ClassInfo<Constant<ValueType> >::init.forceinit();
+ }
+
+ template<class ValueType>
+ Constant<ValueType>::Constant()
+ {
+ ClassInfo<Constant<ValueType> >::init.forceinit();
}
template<class ValueType>
@@ -46,6 +81,12 @@
{
for(int i=rays.begin();i<rays.end();i++)
results.set(i, value);
+ }
+
+ template<class ValueType>
+ void Constant<ValueType>::readwrite(Archive* archive)
+ {
+ archive->readwrite("value", value);
}
template<>
- [MANTA] r1395 - in branches/persistent: Core/Reflection Model/Textures, sparker, 05/17/2007
Archive powered by MHonArc 2.6.16.