Nebula
|
#include <factory.h>
Provides the central object factory mechanism for Nebula.
Classes which are derived from RefCounted register themselves automatically to the central Factory object through the __DeclareClass and __ImplementClass macros.
Public Member Functions | |
void | Register (const Rtti *rtti, const Util::String &className, const Util::FourCC &classFourCC) |
register a RTTI object with the factory (with class name and class fourcc code) | |
void | Register (const Rtti *rtti, const Util::String &className) |
register a RTTI object with the factory (without fourcc code) | |
bool | ClassExists (const Util::String &className) const |
check if a class exists by class name | |
bool | ClassExists (const Util::FourCC classFourCC) const |
check if a class exists by FourCC code | |
const Rtti * | GetClassRtti (const Util::String &className) const |
get class rtti object by name | |
const Rtti * | GetClassRtti (const Util::FourCC &classFourCC) const |
get class rtti object by fourcc code | |
void * | Create (const Util::String &className) const |
create an object by class name | |
void * | Create (const Util::FourCC classFourCC) const |
create an object by FourCC code | |
void * | CreateArray (const Util::String &className, SizeT num) const |
create an array of objects by class name | |
void * | CreateArray (const Util::FourCC classFourCC, SizeT num) const |
create an array object by FourCC code | |
Static Public Member Functions | |
static Factory * | Instance () |
get pointer to singleton instance (cannot use singleton.h!) | |
static void | Destroy () |
static instance destruction method | |
Private Member Functions | |
Factory () | |
constructor is private | |
~Factory () | |
destructor is private | |
Private Attributes | |
Util::HashTable< Util::String, const Rtti *, 1024 > | nameTable |
Util::Dictionary< Util::FourCC, const Rtti * > | fourccTable |
Static Private Attributes | |
static Factory * | Singleton = 0 |
|
private |
constructor is private
The factory's constructor is private so that it may only be called by Factory::Instance().
|
private |
destructor is private
The factory's destructor is private so that it may only be called by Factory::Destroy().
bool Core::Factory::ClassExists | ( | const Util::FourCC | classFourCC | ) | const |
check if a class exists by FourCC code
This method checks if a class with the given fourcc code has been registered.
bool Core::Factory::ClassExists | ( | const Util::String & | className | ) | const |
check if a class exists by class name
This method checks if a class with the given name has been registered.
void * Core::Factory::Create | ( | const Util::FourCC | classFourCC | ) | const |
create an object by FourCC code
Create an object by FourCC code.
void * Core::Factory::Create | ( | const Util::String & | className | ) | const |
create an object by class name
Create an object by class name.
void * Core::Factory::CreateArray | ( | const Util::FourCC | classFourCC, |
SizeT | num ) const |
create an array object by FourCC code
Create an object by FourCC code.
void * Core::Factory::CreateArray | ( | const Util::String & | className, |
SizeT | num ) const |
create an array of objects by class name
Create an object by string name.
|
static |
static instance destruction method
This static method is used to destroy the factory object and should be called right before the main function exits.
It will make sure that no accidential memory leaks are reported by the debug heap.
const Rtti * Core::Factory::GetClassRtti | ( | const Util::FourCC & | classFourCC | ) | const |
get class rtti object by fourcc code
const Rtti * Core::Factory::GetClassRtti | ( | const Util::String & | className | ) | const |
get class rtti object by name
|
static |
get pointer to singleton instance (cannot use singleton.h!)
The factory's constructor is called by the Instance() method, and nobody else.
void Core::Factory::Register | ( | const Rtti * | rtti, |
const Util::String & | className ) |
register a RTTI object with the factory (without fourcc code)
Legacy version of Register() which doesn't require a class fourcc code.
This is for compatibility with old Mangalore applications.
void Core::Factory::Register | ( | const Rtti * | rtti, |
const Util::String & | className, | ||
const Util::FourCC & | classFourCC ) |
register a RTTI object with the factory (with class name and class fourcc code)
This registers an Rtti object with the factory and is called from an Rtti object's constructor.
The function will fail with an error message box if a class with an identical class name or fourcc code has already been registered.
NOTE: we cannot use the class name of fourcc from the RTTI object, because it may be that the RTTI object hasn't been initialized yet when this method is called (initialization order of global variables is undefined).
|
private |
|
private |
|
staticprivate |