diff --git a/change_log.txt b/change_log.txt index dbb1338812bade5bf9752d9e386eaa4632198c76..b1bbe9dd0263605ced6c5d881fc4b9c3162d9357 100644 --- a/change_log.txt +++ b/change_log.txt @@ -640,3 +640,4 @@ * Store block number in NiObject when reading a nif file (requested by DragoonWraith). * Added cmake build script. * GetTexture() now returns a TexDesc reference (requested by DragoonWraith). + * Type::Create() method (requested by DragoonWraith). diff --git a/include/Type.h b/include/Type.h index accd220f38c3cb60ab4fcbaf52edf1d9df91fccc..0db9db5c5303689c2ce2d3225c4d57245cf5e49f 100644 --- a/include/Type.h +++ b/include/Type.h @@ -10,6 +10,9 @@ All rights reserved. Please see niflib.h for license. */ using namespace std; namespace Niflib { +// forward declaration +class NiObject; + /** * Run Time Type Information Class */ @@ -23,6 +26,7 @@ public: NIFLIB_API bool IsSameType ( const Type & compare_to ) const; NIFLIB_API bool IsDerivedType ( const Type & compare_to ) const; NIFLIB_API bool operator<( const Type & compare_to ) const; + NIFLIB_API NiObject * Create() const; const Type * base_type; private: string name; diff --git a/src/Type.cpp b/src/Type.cpp index 89cc80c719ba23be8407f8befd5ac259f60bcaa7..1a4a41e035a4f3ce3ba25eec6e29f78eb4329cd5 100644 --- a/src/Type.cpp +++ b/src/Type.cpp @@ -2,6 +2,7 @@ All rights reserved. Please see niflib.h for license. */ #include "../include/Type.h" +#include "../include/ObjectRegistry.h" using namespace Niflib; Type::Type (const string & type_name, const Type * par_type ) : name(type_name), base_type(par_type) {} @@ -31,3 +32,7 @@ bool Type::IsDerivedType( const Type & compare_to ) const { string Type::GetTypeName() const { return name; } + +NiObject * Type::Create() const { + return ObjectRegistry::CreateObject(name); +}