MoCSI API Reference
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | List of all members
ModuleFactory< T > Class Template Reference

Class to register and generate every module compiled into the executable. Has static auto-registry functionality, but still requires the modules to be forward-declared in the corresponding .cpp file, for they are templates and would not be instantiated by the compiler, if not declared there :/. More...

#include <ModuleFactory.h>

Collaboration diagram for ModuleFactory< T >:
Collaboration graph

Public Types

using creation_method = std::shared_ptr< GenericManagingModule< T > >(*)(SimulationClassBase< T > *sim)
 
using creation_method_submodules = std::shared_ptr< GenericSubmodule< T > >(*)(SimulationClassBase< T > *sim)
 

Public Member Functions

 ModuleFactory ()=delete
 

Static Public Member Functions

static constexpr bool registerModule (std::string name, creation_method module) noexcept
 Function that adds a module to the module registry map.
 
static constexpr bool registerModule (std::string name, creation_method_submodules module) noexcept
 Function that adds a submodule to the submodule registry map.
 
static std::shared_ptr< GenericManagingModule< T > > create (const std::string &name, SimulationClassBase< T > *sim)
 Creates a module, if a module with the corresponding name has been registered.
 
static std::vector< std::shared_ptr< GenericManagingModule< T > > > createAllManagingModules (SimulationClassBase< T > *sim_pointer)
 Creates every module in the module registry.
 
static std::vector< std::shared_ptr< GenericSubmodule< T > > > createAllSubmodules (SimulationClassBase< T > *sim_pointer)
 Creates every submodule in the submodule registry.
 
static std::shared_ptr< GenericSubmodule< T > > createSubmodule (const std::string &name, SimulationClassBase< T > *sim)
 Creates a submodule, if a submodule with the corresponding name has been registered.
 

Detailed Description

template<typename T>
class ModuleFactory< T >

Class to register and generate every module compiled into the executable. Has static auto-registry functionality, but still requires the modules to be forward-declared in the corresponding .cpp file, for they are templates and would not be instantiated by the compiler, if not declared there :/.

Member Typedef Documentation

◆ creation_method

template<typename T >
using ModuleFactory< T >::creation_method = std::shared_ptr<GenericManagingModule<T> > (*)(SimulationClassBase<T>* sim)

◆ creation_method_submodules

template<typename T >
using ModuleFactory< T >::creation_method_submodules = std::shared_ptr<GenericSubmodule<T> > (*)(SimulationClassBase<T>* sim)

Constructor & Destructor Documentation

◆ ModuleFactory()

template<typename T >
ModuleFactory< T >::ModuleFactory ( )
delete

Member Function Documentation

◆ create()

template<typename T >
std::shared_ptr< GenericManagingModule< T > > ModuleFactory< T >::create ( const std::string &  name,
SimulationClassBase< T > *  sim 
)
static

Creates a module, if a module with the corresponding name has been registered.

Parameters
nameThe name of the module to be created.

◆ createAllManagingModules()

template<typename T >
std::vector< std::shared_ptr< GenericManagingModule< T > > > ModuleFactory< T >::createAllManagingModules ( SimulationClassBase< T > *  sim_pointer)
static

Creates every module in the module registry.

Parameters
sim_pointerThe pointer to the sim class to be automatically set in the modules

◆ createAllSubmodules()

template<typename T >
std::vector< std::shared_ptr< GenericSubmodule< T > > > ModuleFactory< T >::createAllSubmodules ( SimulationClassBase< T > *  sim_pointer)
static

Creates every submodule in the submodule registry.

Parameters
sim_pointerThe pointer to the sim class to be automatically set in the submodules

◆ createSubmodule()

template<typename T >
std::shared_ptr< GenericSubmodule< T > > ModuleFactory< T >::createSubmodule ( const std::string &  name,
SimulationClassBase< T > *  sim 
)
static

Creates a submodule, if a submodule with the corresponding name has been registered.

Parameters
nameThe name of the module to be created.

◆ registerModule() [1/2]

template<typename T >
bool constexpr ModuleFactory< T >::registerModule ( std::string  name,
creation_method  module 
)
staticconstexprnoexcept

Function that adds a module to the module registry map.

Parameters
nameThe name of the module under which it will be added to the map
moduleA pointer to a function that creates the module, supplied by the module themself.

◆ registerModule() [2/2]

template<typename T >
bool constexpr ModuleFactory< T >::registerModule ( std::string  name,
creation_method_submodules  module 
)
staticconstexprnoexcept

Function that adds a submodule to the submodule registry map.

Parameters
nameThe name of the module under which it will be added to the map
moduleA pointer to a function that creates the module, supplied by the module themself.

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