MoCSI API Reference
Loading...
Searching...
No Matches
Public Member Functions | List of all members
ChainManager< ModuleType > Class Template Reference

Template generalized ChainManager. It stores pointers to the modules and runs their exec-function on request. It can store different chains that can be run via passing the name of the chain to the runChain function or specific modules within a chain can be specified via the runSingleModuleInChain function. More...

#include <ChainManager.h>

Collaboration diagram for ChainManager< ModuleType >:
Collaboration graph

Public Member Functions

 ChainManager ()
 Constructor of the chain manager without arguments. Does not initialize chains, so the have to be added manually!
 
 ChainManager (std::string_view chain_type)
 Constructor of the chain manager with possibility to specify chain type. Option(s): "global". Initializes the ChainManager with the specified chains belonging to predefined chain types.
 
void insertModule (std::string_view key, const std::shared_ptr< ModuleType > &module)
 Insert modules into chains. Generates a new chain, if the chain key does not yet exist.
 
void runChain (std::string_view key)
 Runs the exec-functions of each module within the specified chain (if existing).
 
void runSingleModuleInChain (std::string_view chain_key, std::string_view module_key)
 Runs the exec-function of a singular specified module within a specified chain (if existing).
 
void autoLoader (const ModuleList &all_modules)
 Inserts all modules derived from a module type into the chain in the load-order. Only used for modules derived from GenericManagingModules, as only they support auto load functionality.
 
void autoLoader (const ModuleList &all_modules, const std::vector< std::string > &modules_to_load)
 Inserts only user specified modules derived from a module type into the chain in the load-order. Only used for modules derived from GenericManagingModules, as only they support auto load functionality.
 
std::vector< std::string > getChainNames () const
 Getter function for the chain names.
 
std::unordered_set< std::string > getManagingModuleNames () const
 Function that returns the names of the requested/loaded managing modules.
 
void resolveDependencies ()
 Guarantees that the module order is correct to ensure all dependencies are met. Throws a DependencyError, if it detecs missing or circular dependencies. Important: Only call if you know what you are doing.
 

Detailed Description

template<typename ModuleType>
class ChainManager< ModuleType >

Template generalized ChainManager. It stores pointers to the modules and runs their exec-function on request. It can store different chains that can be run via passing the name of the chain to the runChain function or specific modules within a chain can be specified via the runSingleModuleInChain function.

Constructor & Destructor Documentation

◆ ChainManager() [1/2]

Constructor of the chain manager without arguments. Does not initialize chains, so the have to be added manually!

◆ ChainManager() [2/2]

template<typename ModuleType >
ChainManager< ModuleType >::ChainManager ( std::string_view  chain_type)

Constructor of the chain manager with possibility to specify chain type. Option(s): "global". Initializes the ChainManager with the specified chains belonging to predefined chain types.

Member Function Documentation

◆ autoLoader() [1/2]

template<typename ModuleType >
void ChainManager< ModuleType >::autoLoader ( const ModuleList &  all_modules)

Inserts all modules derived from a module type into the chain in the load-order. Only used for modules derived from GenericManagingModules, as only they support auto load functionality.

Parameters
all_modulesA vector containing pointers to all loaded modules.

◆ autoLoader() [2/2]

template<typename ModuleType >
void ChainManager< ModuleType >::autoLoader ( const ModuleList &  all_modules,
const std::vector< std::string > &  modules_to_load 
)

Inserts only user specified modules derived from a module type into the chain in the load-order. Only used for modules derived from GenericManagingModules, as only they support auto load functionality.

Parameters
all_modulesA vector containing pointers to all loaded modules.
modules_to_loadA user provided list of managing modules the user would like to load.

◆ getChainNames()

template<typename ModuleType >
std::vector< std::string > ChainManager< ModuleType >::getChainNames ( ) const

Getter function for the chain names.

◆ getManagingModuleNames()

template<typename ModuleType >
std::unordered_set< std::string > ChainManager< ModuleType >::getManagingModuleNames ( ) const

Function that returns the names of the requested/loaded managing modules.

Template Parameters
ModuleType
Returns
std::vector<std::string> containing all the names of the requested managing modules.

◆ insertModule()

template<typename ModuleType >
void ChainManager< ModuleType >::insertModule ( std::string_view  key,
const std::shared_ptr< ModuleType > &  module 
)

Insert modules into chains. Generates a new chain, if the chain key does not yet exist.

Parameters
keyThe chain name to insert the module into.
moduleThe pointer to the module to be inserted.

◆ resolveDependencies()

template<typename ModuleType >
void ChainManager< ModuleType >::resolveDependencies ( )

Guarantees that the module order is correct to ensure all dependencies are met. Throws a DependencyError, if it detecs missing or circular dependencies. Important: Only call if you know what you are doing.

◆ runChain()

template<typename ModuleType >
void ChainManager< ModuleType >::runChain ( std::string_view  key)

Runs the exec-functions of each module within the specified chain (if existing).

Parameters
keyThe name of the chain that will be executed

◆ runSingleModuleInChain()

template<typename ModuleType >
void ChainManager< ModuleType >::runSingleModuleInChain ( std::string_view  chain_key,
std::string_view  module_key 
)

Runs the exec-function of a singular specified module within a specified chain (if existing).

Parameters
chain_keyThe name of the chain containing the module that should be executed.
module_keyThe name of the module to be executed.

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