From 8eeca2c45e6efc6233f127b2a90ab03368a81cee Mon Sep 17 00:00:00 2001 From: Amorilia <amorilia@users.sourceforge.net> Date: Tue, 14 Sep 2010 15:20:34 +0100 Subject: [PATCH] Type::Create() method (requested by DragoonWraith). --- change_log.txt | 1 + include/Type.h | 4 ++++ src/Type.cpp | 5 +++++ 3 files changed, 10 insertions(+) diff --git a/change_log.txt b/change_log.txt index dbb13388..b1bbe9dd 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 accd220f..0db9db5c 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 89cc80c7..1a4a41e0 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); +} -- GitLab