Main Page | Modules | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

Teem::Registrar< T, IdT, ArgT, void > Class Template Reference
[Utilities]

#include <Registrar.h>

List of all members.


Detailed Description

template<typename T, typename IdT, typename ArgT>
class Teem::Registrar< T, IdT, ArgT, void >

A Registrar for classes with one parameter constructors.

Usage

A, is a class; B, C are its subclasses

Registrar<A, std::string, int> reg;

reg.registerItem<B>("you");
reg.registerItem<C>("yeah");

A* a1 = reg.createItem("you", 0);
A* a2 = reg.createItem("yeah", 0);


Public Member Functions

template<typename Sub>
void registerItem (const IdT &id)
 Register a class by storing a pointer to its constructor.
T * createItem (const IdT &id, ArgT arg)
 Create an instance of a registered class and pass arg to its constructor.
void dump (std::ostream &stream)
 Print the list of registered classes to stream.

Protected Types

typedef T *(* CreatorFunc )(ArgT)
 Pointer to constructor of class T.

Static Protected Member Functions

template<typename Sub>
static T * Creator (ArgT arg)
 Create a new class of type Sub with argument arg.

Protected Attributes

std::map< IdT, CreatorFuncmItems
 registered constructors


The documentation for this class was generated from the following file:
Generated on Mon Oct 24 17:38:29 2005 for Teem by  doxygen 1.4.2