NEST  2.6.0,not_revisioned_source_dir@0
Public Types | Public Member Functions | Static Private Member Functions | Private Attributes | List of all members
nest::GenericFactory< BaseT > Class Template Reference

Generic Factory class for objects deriving from a base class BaseT. More...

#include <generic_factory.h>

Public Types

typedef BaseT *(* CreatorFunction )(const DictionaryDatum &d)
 
typedef std::map< Name,
CreatorFunction
AssocMap
 

Public Member Functions

BaseT * create (const Name &name, const DictionaryDatum &d) const
 Factory function. More...
 
template<class T >
bool register_subtype (const Name &name)
 Register a new subtype. More...
 
bool register_subtype (const Name &name, CreatorFunction creator)
 Register a new subtype. More...
 

Static Private Member Functions

template<class T >
static BaseT * new_from_dict_ (const DictionaryDatum &d)
 

Private Attributes

AssocMap associations_
 

Detailed Description

template<class BaseT>
class nest::GenericFactory< BaseT >

Generic Factory class for objects deriving from a base class BaseT.

Keeps a register of subtypes which may be created dynamically. New subtypes may be added by registering either a class (which must have a constructor taking as a parameter a dictionary containing parameters for the mask) or a specialized factory function.

See also
Alexandrescu, A (2001). Modern C++ Design, Addison-Wesley, ch. 8.

Member Typedef Documentation

template<class BaseT>
typedef std::map<Name,CreatorFunction> nest::GenericFactory< BaseT >::AssocMap
template<class BaseT>
typedef BaseT*(* nest::GenericFactory< BaseT >::CreatorFunction)(const DictionaryDatum &d)

Member Function Documentation

template<class BaseT >
BaseT * nest::GenericFactory< BaseT >::create ( const Name name,
const DictionaryDatum d 
) const
inline

Factory function.

Parameters
nameSubtype.
dDictionary containing parameters for this subtype.
Returns
dynamically allocated new object.

References nest::names::d, and Name::toString().

Referenced by nest::TopologyModule::create_mask(), and nest::TopologyModule::create_parameter().

template<class BaseT >
template<class T >
BaseT * nest::GenericFactory< BaseT >::new_from_dict_ ( const DictionaryDatum d)
staticprivate
template<class BaseT >
template<class T >
bool nest::GenericFactory< BaseT >::register_subtype ( const Name name)
inline

Register a new subtype.

The type name must not already exist. The class for the subtype is supplied via the template argument. This class should have a constructor taking a const DictionaryDatum& as parameter.

Parameters
namesubtype name.
Returns
true if subtype was successfully registered.

Referenced by nest::TopologyModule::register_mask(), and nest::TopologyModule::register_parameter().

template<class BaseT >
bool nest::GenericFactory< BaseT >::register_subtype ( const Name name,
CreatorFunction  creator 
)
inline

Register a new subtype.

The type name must not already exist.

Parameters
nameSubtype name.
creatorA factory function creating objects of this subtype from a const DictionaryDatum& containing parameters
Returns
true if mask was successfully registered.

Member Data Documentation

template<class BaseT>
AssocMap nest::GenericFactory< BaseT >::associations_
private

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