The Nebula Device 3: Core::Factory Class Reference

The Nebula Device 3

Core::Factory Class Reference

#include <factory.h>


Detailed Description

Provides the central object factory mechanism for Nebula3. Classes which are derived from RefCounted register themselves automatically to the central Factory object through the DeclareClass and ImplementClass macros.

(C) 2005 Radon Labs GmbH

Public Member Functions

void Register (const Rtti *rtti, const Util::String &className, const Util::FourCC &classFourCC)
 register a RTTI object with the factory
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 RttiGetClassRtti (const Util::String &className) const
 get class rtti object by name
const RttiGetClassRtti (const Util::FourCC &classFourCC) const
 get class rtti object by fourcc code
RefCountedCreate (const Util::String &className) const
 create an object by class name
RefCountedCreate (const Util::FourCC classFourCC) const
 create an object by FourCC code

Static Public Member Functions

static FactoryInstance ()
 get pointer to singleton instance (cannot use singleton.h!)
static void Destroy ()
 static instance destruction method

Member Function Documentation

Factory * Core::Factory::Instance (  )  [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::Destroy (  )  [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.

void Core::Factory::Register ( const Rtti rtti,
const Util::String className,
const Util::FourCC classFourCC 
)

register a RTTI object with the factory

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).

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.

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.

RefCounted * Core::Factory::Create ( const Util::String className  )  const

create an object by class name

Create an object by class name.

RefCounted * Core::Factory::Create ( const Util::FourCC  classFourCC  )  const

create an object by FourCC code

Create an object by FourCC code.