Sfoglia il codice sorgente

Before refactoring some RTTI stuff and adding class meta-data

Marko Pintera 13 anni fa
parent
commit
afba83d7fd

+ 23 - 0
CamelotRenderer/Include/CmResource.h

@@ -37,5 +37,28 @@ namespace CamelotEngine
 
 
 		virtual SerializableType* getSerializable() const;
 		virtual SerializableType* getSerializable() const;
 		static Resource* newObject();
 		static Resource* newObject();
+
+	protected:
+		struct RTTIInitOnStart
+		{
+			RTTIInitOnStart()
+			{
+				static RTTIMetaType<Resource> myClassMetaType;
+				ISerializable::registerRTTIDerivedClass(&myClassMetaType);
+			}
+		};
+
+		static RTTIInitOnStart initOnStart;
+
+		static vector<RTTIMetaTypeBase*>::type& getRTTIDerivedClasses()
+		{
+			static vector<RTTIMetaTypeBase*>::type mRTTIDerivedClasses;
+			return mRTTIDerivedClasses;
+		}
+
+		static void registerRTTIDerivedClass(RTTIMetaTypeBase* derivedClass)
+		{
+			getRTTIDerivedClasses().push_back(derivedClass);
+		}
 	};
 	};
 }
 }

+ 2 - 0
CamelotRenderer/TODO.txt

@@ -45,6 +45,8 @@ TODO:
  - OpenGL too
  - OpenGL too
 
 
 TOMORROW:
 TOMORROW:
+ - ISerializable class and begin/endSerialization are probably not needed and can be removed
+ - Depth test is disabled by default (OpenGL renderer at least)
  - Non-dynamic-size types cannot have size over 255 bytes but that isn't marked or checked anywhere!
  - Non-dynamic-size types cannot have size over 255 bytes but that isn't marked or checked anywhere!
  - Serializable callbacks can't be null otherwise compiler complains
  - Serializable callbacks can't be null otherwise compiler complains
  - Ogre performed special DDS loading. I removed that. I'm not sure if I'll need to re-add it?
  - Ogre performed special DDS loading. I removed that. I'm not sure if I'll need to re-add it?

+ 36 - 0
CamelotUtility/Include/CmISerializable.h

@@ -6,10 +6,46 @@
 
 
 namespace CamelotEngine
 namespace CamelotEngine
 {
 {
+	// TODO - Move these classes up to IReflectable, and remove ISerializable because it's not used
+	class CM_UTILITY_EXPORT RTTIMetaTypeBase
+	{
+	public:
+		//virtual String getRTTIName() = 0;
+		//virtual UINT32 getRTTITypeId() = 0;
+		//virtual RTTITypeBase* getRTTI() = 0;
+		virtual IReflectable* newObject() = 0;
+	};
+
+	template <class T>
+	class CM_UTILITY_EXPORT RTTIMetaType : public RTTIMetaTypeBase
+	{
+	public:
+		//virtual String getRTTIName()
+		//{ return T::getRTTIName(); } // TODO - Maybe add static asserts to add a better error message if method doesn't exist
+		//virtual UINT32 getRTTITypeId() 
+		//{ return T::getRTTITypeId(); }
+		//virtual RTTITypeBase* getRTTI()
+		//{ return T::getRTTI(); }
+		virtual IReflectable* newObject()
+		{ return T::newObject(); }
+	};
+
 	class CM_UTILITY_EXPORT ISerializable : public IReflectable
 	class CM_UTILITY_EXPORT ISerializable : public IReflectable
 	{
 	{
 	public:
 	public:
 		virtual RTTITypeBase* getRTTI() const { return getSerializable(); }
 		virtual RTTITypeBase* getRTTI() const { return getSerializable(); }
 		virtual SerializableType* getSerializable() const = 0;
 		virtual SerializableType* getSerializable() const = 0;
+
+	protected:
+		static vector<RTTIMetaTypeBase*>::type& getRTTIDerivedClasses()
+		{
+			static vector<RTTIMetaTypeBase*>::type mRTTIDerivedClasses;
+			return mRTTIDerivedClasses;
+		}
+
+		static void registerRTTIDerivedClass(RTTIMetaTypeBase* derivedClass)
+		{
+			getRTTIDerivedClasses().push_back(derivedClass);
+		}
 	};
 	};
 }
 }