Claw  1.7.3
Classes | Public Member Functions | List of all members
claw::pattern::factory< BaseClass, IdentifierType > Class Template Reference

The design pattern of the factory allow to dynamically instanciate classes of various types given an identifier of this type. More...

#include <factory.hpp>

Classes

class  class_creator
 A class creator is an object that allocate a given type.
class  class_creator_base
 A class creator is an object that allocate a given type. This is the base class for all class creators.

Public Member Functions

 ~factory ()
 Destructor.
template<typename T >
bool register_type (const identifier_type &id)
 Register a type in the factory.
base_class * create (const identifier_type &id) const
 Create a new instance.
bool is_known_type (const identifier_type &id) const
 Tell in a type with a given id is known by the factory.

Detailed Description

template<typename BaseClass, typename IdentifierType>
class claw::pattern::factory< BaseClass, IdentifierType >

The design pattern of the factory allow to dynamically instanciate classes of various types given an identifier of this type.

Template parameters:

Type requirements:

Definition at line 77 of file factory.hpp.

Member Function Documentation

template<typename BaseClass , typename IdentifierType >
claw::pattern::factory< BaseClass, IdentifierType >::base_class * claw::pattern::factory< BaseClass, IdentifierType >::create ( const identifier_type &  id) const

Create a new instance.

Parameters
idThe identifier of the type to instanciate.
Returns
A pointer to the newly created instance.

Definition at line 110 of file factory.tpp.

template<typename BaseClass , typename IdentifierType >
bool claw::pattern::factory< BaseClass, IdentifierType >::is_known_type ( const identifier_type &  id) const

Tell in a type with a given id is known by the factory.

Parameters
idThe identifier of the type to check.

Definition at line 127 of file factory.tpp.

template<typename BaseClass , typename IdentifierType >
template<typename T >
bool claw::pattern::factory< BaseClass, IdentifierType >::register_type ( const identifier_type &  id)

Register a type in the factory.

Parameters
idThe identifier to which the type is associated.
Returns
true if successful.

Template parameters:

  • T The type to register.

Definition at line 88 of file factory.tpp.


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