NEST main@caf0ae8
 
Loading...
Searching...
No Matches
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 Dictionary &d)
 
typedef std::map< std::string, CreatorFunction > AssocMap
 

Public Member Functions

BaseT * create (const std::string &name, const Dictionary &d) const
 Factory function.
 
template<class T >
bool register_subtype (const std::string &name)
 Register a new subtype.
 
bool register_subtype (const std::string &name, CreatorFunction creator)
 Register a new subtype.
 

Static Private Member Functions

template<class T >
static BaseT * new_from_dict_ (const Dictionary &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

◆ AssocMap

template<class BaseT >
typedef std::map< std::string, CreatorFunction > nest::GenericFactory< BaseT >::AssocMap

◆ CreatorFunction

template<class BaseT >
typedef BaseT *(* nest::GenericFactory< BaseT >::CreatorFunction) (const Dictionary &d)

Member Function Documentation

◆ create()

template<class BaseT >
BaseT * nest::GenericFactory< BaseT >::create ( const std::string &  name,
const Dictionary &  d 
) const
inline

Factory function.

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

◆ new_from_dict_()

template<class BaseT >
template<class T >
BaseT * nest::GenericFactory< BaseT >::new_from_dict_ ( const Dictionary &  d)
staticprivate

◆ register_subtype() [1/2]

template<class BaseT >
template<class T >
bool nest::GenericFactory< BaseT >::register_subtype ( const std::string &  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 Dictionary& as parameter.

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

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

Here is the caller graph for this function:

◆ register_subtype() [2/2]

template<class BaseT >
bool nest::GenericFactory< BaseT >::register_subtype ( const std::string &  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 Dictionary& containing parameters
Returns
true if mask was successfully registered.

Member Data Documentation

◆ associations_

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

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