c:/nebula3/code/foundation/core/rttimacros.h File Reference
Detailed Description
This defines the macros for Nebula3's RTTI mechanism (__DeclareClass, __ImplementClass, etc...).(C) 2008 Radon Labs GmbH
Defines | |
#define | __DeclareClass(type) |
#define | __RegisterClass(type) static const bool type##_registered = type::RegisterWithFactory(); \ |
#define | __ImplementClass(type, fourcc, baseType) |
#define | __ImplementRootClass(type, fourcc) |
Define Documentation
#define __DeclareClass | ( | type | ) |
Value:
public: \ void* operator new(size_t size) \ { \ return RTTI.AllocInstanceMemory(); \ }; \ void operator delete(void* p) \ { \ RTTI.FreeInstanceMemory(p); \ }; \ static Core::Rtti RTTI; \ static Core::RefCounted* FactoryCreator(); \ static type* Create(); \ static bool RegisterWithFactory(); \ virtual Core::Rtti* GetRtti() const; \ private:
#define __RegisterClass | ( | type | ) | static const bool type##_registered = type::RegisterWithFactory(); \ |
Register a class with the factory. This is only necessary for classes which can create objects by name or fourcc.
#define __ImplementClass | ( | type, | |||
fourcc, | |||||
baseType | ) |
Value:
Core::Rtti type::RTTI(#type, fourcc, type::FactoryCreator, &baseType::RTTI, sizeof(type)); \ Core::Rtti* type::GetRtti() const { return &this->RTTI; } \ Core::RefCounted* type::FactoryCreator() { return type::Create(); } \ type* type::Create() \ { \ return n_new(type); \ }\ bool type::RegisterWithFactory() \ { \ Core::SysFunc::Setup(); \ if (!Core::Factory::Instance()->ClassExists(#type)) \ { \ Core::Factory::Instance()->Register(&type::RTTI, #type, fourcc); \ } \ return true; \ }
#define __ImplementRootClass | ( | type, | |||
fourcc | ) |
Value:
Core::Rtti type::RTTI(#type, fourcc, type::FactoryCreator, 0, sizeof(type)); \ Core::Rtti* type::GetRtti() const { return &this->RTTI; } \ Core::RefCounted* type::FactoryCreator() { return type::Create(); } \ type* type::Create() \ { \ return n_new(type); \ }\ bool type::RegisterWithFactory() \ { \ if (!Core::Factory::Instance()->ClassExists(#type)) \ { \ Core::Factory::Instance()->Register(&type::RTTI, #type, fourcc); \ } \ return true; \ }