Classdesc  3.D29
Factory< B, Type > Class Template Reference

#include <factory.h>

Collaboration diagram for Factory< B, Type >:
Collaboration graph

Classes

struct  InvalidType
 

Public Member Functions

template<class T >
void registerType (const Type &t)
 register type T for use with this factory
 
template<class T >
void registerType ()
 convenience method for registering a type.
 
 Factory ()
 
B * create (const Type &t) const
 Create a default constructed object given by the type string.
 
std::vector< string > types () const
 return list of registered types
 

Detailed Description

template<class B, class Type>
class classdesc::Factory< B, Type >

factory template for a class heirarchy. B is the base class, and Type is the type class

Constructor & Destructor Documentation

Factory ( )

Users of this template must define a constructor that registers all the types in the heirarchy.

For example, assuming Foo and Bar are subtypes of FooBase: template <> Factory<Foobase>::Factory() { registerType<Foo>(); registerType<Bar>(); };


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