ASL
|
A Factory allows creating objects given a class name as a String.
They are used through pointers to their base class and through virtual functions. A Factory is created for a given base class, and subclasses must be registered with ASL_FACTORY_REGISTER()
before use.
#include <Factory.h>
Inherits Singleton< Factory< T > >.
Static Public Member Functions | |
static T * | create (const String &name) |
Constructs an object given a class name previously registered. | |
static int | add (const String &className, T *(*f)()) |
Registers a class given a function that constructs and returns a new object. | |
static Array< String > | catalog () |
Returns a list of the class names already registered. | |
static bool | has (const String &clas) |
Returns true if the given class name is registered. | |
static int | setClassInfo (const String &clas, const Dic<> &info) |
Associates an information string with a registered class. | |
static const Dic | classInfo (const String &clas) |
Returns the information associated with a class. | |
![]() | |
static Factory< T > * | instance () |
Returns a pointer to an instance of class T, creating it on the first call. | |