23#ifndef GENERIC_FACTORY_H
24#define GENERIC_FACTORY_H
50template <
class BaseT >
54 typedef BaseT* ( *CreatorFunction )(
const Dictionary& d );
55 typedef std::map< std::string, CreatorFunction >
AssocMap;
94template <
class BaseT >
98 typename AssocMap::const_iterator i = associations_.find( name );
99 if ( i != associations_.end() )
101 return ( i->second )( d );
106template <
class BaseT >
111 return register_subtype( name, new_from_dict_< T > );
114template <
class BaseT >
118 return associations_.insert( std::pair< std::string, CreatorFunction >( name, creator ) ).second;
121template <
class BaseT >
Dictionary class for interface to Python and C++ API.
Definition dictionary.h:213
Generic Factory class for objects deriving from a base class BaseT.
Definition generic_factory.h:52
BaseT * create(const std::string &name, const Dictionary &d) const
Factory function.
Definition generic_factory.h:96
AssocMap associations_
Definition generic_factory.h:91
BaseT *(* CreatorFunction)(const Dictionary &d)
Definition generic_factory.h:54
static BaseT * new_from_dict_(const Dictionary &d)
Definition generic_factory.h:124
std::map< std::string, CreatorFunction > AssocMap
Definition generic_factory.h:55
bool register_subtype(const std::string &name)
Register a new subtype.
Definition generic_factory.h:109
Definition exceptions.h:1775
Namespace for the NEST simulation kernel.
Definition beta_normalization_factor.h:33