netxsimdg
Loading...
Searching...
No Matches
Nextsim::ConfiguredModule Class Reference

A helper class to automatically load modules based on the configuration. More...

#include <ConfiguredModule.hpp>

Collaboration diagram for Nextsim::ConfiguredModule:
Collaboration graph

Public Types

typedef std::function< void(const std::string &)> fn
 
typedef std::function< std::string()> ofn
 
typedef std::map< const std::string, std::pair< fn, ofn > > map
 

Static Public Member Functions

static void parseConfigurator ()
 Parse the configuration for all of the modules defined in ModuleLoader.
 
static void setConfiguredModules (const map &ls)
 
static void configureModule (const std::string &mod, const fn &setter, const ofn &getter)
 
static std::string getModuleConfiguration (const std::string &interface)
 
static ConfigMap getAllModuleConfigurations ()
 
static std::string addPrefix (const std::string &moduleName)
 Transforms a module name into a configuration option name.
 

Static Public Attributes

static const std::string MODULE_PREFIX = "Modules"
 The configuration options section name for modules.
 

Detailed Description

A helper class to automatically load modules based on the configuration.

Definition at line 25 of file ConfiguredModule.hpp.

Member Typedef Documentation

◆ fn

std::function<void(const std::string&)> Nextsim::ConfiguredModule::fn

Definition at line 27 of file ConfiguredModule.hpp.

◆ map

std::map<const std::string, std::pair<fn, ofn> > Nextsim::ConfiguredModule::map

Definition at line 29 of file ConfiguredModule.hpp.

◆ ofn

std::function<std::string()> Nextsim::ConfiguredModule::ofn

Definition at line 28 of file ConfiguredModule.hpp.

Member Function Documentation

◆ addPrefix()

std::string Nextsim::ConfiguredModule::addPrefix ( const std::string & moduleName)
static

Transforms a module name into a configuration option name.

Parameters
moduleNameThe module name to be prefixed.

Definition at line 47 of file ConfiguredModule.cpp.

Here is the caller graph for this function:

◆ configureModule()

void Nextsim::ConfiguredModule::configureModule ( const std::string & mod,
const fn & setter,
const ofn & getter )
static

Adds the name of a module to the list to be configured

Parameters
modthe name of the class to be configured.
setterthe void(std::string) function to set the implementation.
getterthe std::string() function to get the implementation.

Definition at line 58 of file ConfiguredModule.cpp.

◆ getAllModuleConfigurations()

ConfigMap Nextsim::ConfiguredModule::getAllModuleConfigurations ( )
static

Returns a map from interface name to implementation name for all modules configured in this class.

Definition at line 68 of file ConfiguredModule.cpp.

Here is the call graph for this function:

◆ getModuleConfiguration()

std::string Nextsim::ConfiguredModule::getModuleConfiguration ( const std::string & interface)
static

Gets the implementation name for a named module. Returns an empty string if there is no such module.

Parameters
interfacethe name of the module to be checked.

Definition at line 63 of file ConfiguredModule.cpp.

◆ parseConfigurator()

void Nextsim::ConfiguredModule::parseConfigurator ( )
static

Parse the configuration for all of the modules defined in ModuleLoader.

Definition at line 22 of file ConfiguredModule.cpp.

Here is the call graph for this function:

◆ setConfiguredModules()

void Nextsim::ConfiguredModule::setConfiguredModules ( const map & ls)
static

Sets the names of all the modules to be configured

Parameters
lsa map of Module names and the locations of implementation setter and getter functions.

Definition at line 52 of file ConfiguredModule.cpp.

Member Data Documentation

◆ MODULE_PREFIX

const std::string Nextsim::ConfiguredModule::MODULE_PREFIX = "Modules"
static

The configuration options section name for modules.

Definition at line 73 of file ConfiguredModule.hpp.


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