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::vector< std::shared_ptr< GenericManagingModule< T > > > createAllSelectedManagingModules (SimulationClassBase< T > *sim_pointer, const std::vector< std::string > &list_of_mananging_modules_to_load)
 Only creates instances of managing modules that have been specified by the user. (This allows only having ini files of actually used modules present in the ini_file folder)
 
static std::vector< std::shared_ptr< GenericSubmodule< T > > > createAllSelectedSubmodules (SimulationClassBase< T > *sim_pointer, const std::vector< std::shared_ptr< GenericManagingModule< T > > > &loaded_managing_modules)
 Only creates submodules that are used within the simulation. Iteratively requests the submodule list of the currently loaded modules to create those submodules, if they haven't already been created.
 
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

◆ createAllSelectedManagingModules()

template<typename T >
std::vector< std::shared_ptr< GenericManagingModule< T > > > ModuleFactory< T >::createAllSelectedManagingModules ( SimulationClassBase< T > *  sim_pointer,
const std::vector< std::string > &  list_of_mananging_modules_to_load 
)
static

Only creates instances of managing modules that have been specified by the user. (This allows only having ini files of actually used modules present in the ini_file folder)

Template Parameters
TNumeric type used in the simulation (e.g., float, double).
Parameters
sim_pointerThe pointer to the simulation class.
list_of_mananging_modules_to_loadThe user specified list of managing modules used.
Returns
std::vector<std::shared_ptr<GenericManagingModule<T>>> The created managing modules.

◆ createAllSelectedSubmodules()

template<typename T >
std::vector< std::shared_ptr< GenericSubmodule< T > > > ModuleFactory< T >::createAllSelectedSubmodules ( SimulationClassBase< T > *  sim_pointer,
const std::vector< std::shared_ptr< GenericManagingModule< T > > > &  loaded_managing_modules 
)
static

Only creates submodules that are used within the simulation. Iteratively requests the submodule list of the currently loaded modules to create those submodules, if they haven't already been created.

Template Parameters
TT Numeric type used in the simulation (e.g., float, double).
Parameters
sim_pointerThe pointer to the simulation class.
loaded_managing_modulesThe loaded managing modules.
Returns
std::vector<std::shared_ptr<GenericSubmodule<T>>> The created submodules.

◆ 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: