ASL
Loading...
Searching...
No Matches
Factory< T > Class Template Reference

Detailed Description

template<class T>
class asl::Factory< T >

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.

class Dog : public Animal {...};
...
An Array is a contiguous and resizable array of any type of elements.
Definition Array.h:69
static T * create(const String &name)
Constructs an object given a class name previously registered.
Definition Factory.h:39
#define ASL_FACTORY_REGISTER(Base, Class)
Registers class Class in the factory for class Base for instantiation by name (Class must be a subcla...
Definition Factory.h:100

#include <Factory.h>

Inherits Singleton< Factory< T > >.

Static Public Member Functions

static Tcreate (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< Stringcatalog ()
 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 Public Member Functions inherited from Singleton< Factory< T > >
static Factory< T > * instance ()
 Returns a pointer to an instance of class T, creating it on the first call.
 

The documentation for this class was generated from the following file: