cepgen is hosted by Hepforge, IPPP Durham
CepGen 1.2.3
A generic central exclusive processes event generator
Loading...
Searching...
No Matches

A generic factory to build modules. More...

#include <CepGen/Modules/ModuleFactory.h>

Public Types

typedef std::unique_ptr< T >(* Builder) (const ParametersList &)
 Constructor type for a module.
 

Public Member Functions

 ModuleFactory (const ModuleFactory &)=delete
 Disabled copy constructor.
 
virtual ~ModuleFactory ()=default
 Default destructor.
 
void operator= (const ModuleFactory &)=delete
 Disabled assignment operator.
 
const std::string & description () const
 Describe the modules factory.
 
template<typename U >
void registerModule (const std::string &name, const ParametersList &def_params=ParametersList())
 Register a named module in the database.
 
std::unique_ptr< T > build (const ParametersList &) const
 Build one instance of a named module.
 
std::unique_ptr< T > build (const std::string &name, const ParametersList &params=ParametersList()) const
 Build one instance of a named module.
 
std::unique_ptr< T > build (int index, const ParametersList &params=ParametersList()) const
 Build one instance of a named module.
 
std::string describe (const std::string &name) const
 Describe one named module Describe the parameters of one named module.
 
ParametersDescription describeParameters (const ParametersList &) const
 
ParametersDescription describeParameters (const std::string &name, const ParametersList &params=ParametersList()) const
 Describe the parameters of one named module.
 
ParametersDescription describeParameters (int index, const ParametersList &params=ParametersList()) const
 Describe the parameters of one named module.
 
std::vector< std::string > modules () const
 List of modules registred in the database.
 
bool empty () const
 Is the database empty?
 
size_t size () const
 Number of modules registered in the database.
 
const std::unordered_map< int, std::string > & indices () const
 
bool has (const std::string &name) const
 Check if a named module is registered.
 
 ModuleFactory (const std::string &desc)
 
std::vector< std::string > modules () const
 
std::unique_ptr< MadGraphProcessbuild (const std::string &mod_name, const ParametersList &params) const
 

Protected Member Functions

 ModuleFactory (const std::string &)
 Hidden default constructor for singleton operations.
 

Protected Attributes

std::unordered_map< int, std::string > indices_
 Index-to-map association map.
 

Detailed Description

template<typename T>
class cepgen::ModuleFactory< T >
Template Parameters
TBase class to build

Definition at line 48 of file ModuleFactory.h.

Member Typedef Documentation

◆ Builder

template<typename T >
typedef std::unique_ptr< T >(* Builder) (const ParametersList &)

Definition at line 87 of file ModuleFactory.h.

Constructor & Destructor Documentation

◆ ModuleFactory() [1/3]

template<typename T >
ModuleFactory ( const ModuleFactory< T > &  )
delete

◆ ~ModuleFactory()

template<typename T >
virtual ~ModuleFactory ( )
virtualdefault

◆ ModuleFactory() [2/3]

template<typename T >
ModuleFactory ( const std::string &  descr)
explicitprotected

Definition at line 27 of file ModuleFactory.cpp.

◆ ModuleFactory() [3/3]

ModuleFactory ( const std::string &  desc)

Definition at line 27 of file MadGraphProcessFactory.cpp.

Member Function Documentation

◆ build() [1/4]

template<typename T >
std::unique_ptr< T > build ( const ParametersList params) const
Parameters
[in]paramsList of parameters to be invoked by the constructor

Definition at line 30 of file ModuleFactory.cpp.

◆ build() [2/4]

std::unique_ptr< MadGraphProcess > build ( const std::string &  mod_name,
const ParametersList params 
) const

Definition at line 38 of file MadGraphProcessFactory.cpp.

◆ build() [3/4]

template<typename T >
std::unique_ptr< T > build ( const std::string &  name,
const ParametersList params = ParametersList() 
) const
Parameters
[in]nameModule name to retrieve
[in]paramsList of parameters to be invoked by the constructor

Definition at line 52 of file ModuleFactory.cpp.

◆ build() [4/4]

template<typename T >
std::unique_ptr< T > build ( int  index,
const ParametersList params = ParametersList() 
) const
Parameters
[in]indexModule index (if found) to retrieve
[in]paramsList of parameters to be invoked by the constructor

Definition at line 66 of file ModuleFactory.cpp.

◆ describe()

template<typename T >
std::string describe ( const std::string &  name) const
Parameters
[in]paramsParameters (incl. the name) to steer the description

Definition at line 78 of file ModuleFactory.cpp.

◆ describeParameters() [1/3]

template<typename T >
ParametersDescription describeParameters ( const ParametersList params) const

Definition at line 83 of file ModuleFactory.cpp.

◆ describeParameters() [2/3]

template<typename T >
ParametersDescription describeParameters ( const std::string &  name,
const ParametersList params = ParametersList() 
) const
Parameters
[in]nameName of the module to describe
[in]paramsAdditional parameters to steer the description

Definition at line 97 of file ModuleFactory.cpp.

◆ describeParameters() [3/3]

template<typename T >
ParametersDescription describeParameters ( int  index,
const ParametersList params = ParametersList() 
) const
Parameters
[in]indexIndex of the module to describe
[in]paramsAdditional parameters to steer the description

Definition at line 112 of file ModuleFactory.cpp.

◆ description()

template<typename T >
const std::string & description ( ) const

Definition at line 54 of file ModuleFactory.h.

◆ empty()

template<typename T >
bool empty ( ) const

Definition at line 104 of file ModuleFactory.h.

◆ has()

template<typename T >
bool has ( const std::string &  name) const

Definition at line 109 of file ModuleFactory.h.

◆ indices()

template<typename T >
const std::unordered_map< int, std::string > & indices ( ) const

Definition at line 106 of file ModuleFactory.h.

◆ modules() [1/2]

template<typename T >
std::vector< std::string > modules

Definition at line 124 of file ModuleFactory.cpp.

◆ modules() [2/2]

std::vector< std::string > modules ( ) const

Definition at line 30 of file MadGraphProcessFactory.cpp.

◆ operator=()

template<typename T >
void operator= ( const ModuleFactory< T > &  )
delete

◆ registerModule()

template<typename T >
template<typename U >
void registerModule ( const std::string &  name,
const ParametersList def_params = ParametersList() 
)
Template Parameters
UClass to register (inherited from T base class)

Definition at line 59 of file ModuleFactory.h.

◆ size()

template<typename T >
size_t size ( ) const

List of index-to-string associations in the database

Definition at line 105 of file ModuleFactory.h.

Member Data Documentation

◆ indices_

template<typename T >
std::unordered_map<int, std::string> indices_
protected

Definition at line 124 of file ModuleFactory.h.