allpix::ConfigManager
Module: Managers
Manager responsible for loading and providing access to the main configuration. More…
#include <ConfigManager.hpp>
Public Functions
Name | |
---|---|
ConfigManager(const ConfigManager & ) =delete Copying the manager is not allowed. |
|
ConfigManager & | operator=(const ConfigManager & ) =delete Copying the manager is not allowed. |
ConfigManager(ConfigManager && ) =default Use default move behaviour. |
|
ConfigManager & | operator=(ConfigManager && ) =default Use default move behaviour. |
ConfigManager(std::filesystem::path file_name, std::initializer_list< std::string > global ={}, std::initializer_list< std::string > ignore ={“Ignore”}) Construct the configuration manager. |
|
~ConfigManager() =default Use default destructor. |
|
Configuration & | getGlobalConfiguration() Get the global configuration. |
std::list< Configuration > & | getModuleConfigurations() Get all the module configurations. |
Configuration & | addInstanceConfiguration(const ModuleIdentifier & identifier, const Configuration & config) Add a new module instance configuration and applies instance options. |
const std::list< Configuration > & | getInstanceConfigurations() const Get all the instance configurations. |
void | dropInstanceConfiguration(const ModuleIdentifier & identifier) Drops an instance configuration from instance configuration storage. |
bool | loadModuleOptions(const std::vector< std::string > & options) Load module options and directly apply them to the global configuration and the module configurations. |
std::list< Configuration > & | getDetectorConfigurations() Get all the detector configurations. |
bool | loadDetectorOptions(const std::vector< std::string > & options) Load detector specific options. |
Detailed Description
class allpix::ConfigManager;
Manager responsible for loading and providing access to the main configuration.
The main configuration is the single most important source of configuration. It is split up in:
- Global headers that are combined into a single global (not module specific) configuration
- Ignored headers that are not used at all (mainly useful for debugging)
- All other headers representing all modules that have to be instantiated by the ModuleManager
Configuration sections are always case-sensitive.
Public Functions Documentation
function ConfigManager
ConfigManager(
const ConfigManager &
) =delete
Copying the manager is not allowed.
function operator=
ConfigManager & operator=(
const ConfigManager &
) =delete
Copying the manager is not allowed.
function ConfigManager
ConfigManager(
ConfigManager &&
) =default
Use default move behaviour.
function operator=
ConfigManager & operator=(
ConfigManager &&
) =default
Use default move behaviour.
function ConfigManager
explicit ConfigManager(
std::filesystem::path file_name,
std::initializer_list< std::string > global ={},
std::initializer_list< std::string > ignore ={"Ignore"}
)
Construct the configuration manager.
Parameters:
- file_name Path to the main configuration file
- global List of sections representing the global configuration (excluding the empty header section)
- ignore List of sections that should be ignored
Exceptions:
- ConfigFileUnavailableError If the main configuration file cannot be accessed
function ~ConfigManager
~ConfigManager() =default
Use default destructor.
function getGlobalConfiguration
inline Configuration & getGlobalConfiguration()
Get the global configuration.
Return: Reference to global configuration
The global configuration is the combination of all sections with a global header.
function getModuleConfigurations
inline std::list< Configuration > & getModuleConfigurations()
Get all the module configurations.
Return: Reference to list of module configurations
All special global and ignored sections are not included in the list of module configurations.
function addInstanceConfiguration
Configuration & addInstanceConfiguration(
const ModuleIdentifier & identifier,
const Configuration & config
)
Add a new module instance configuration and applies instance options.
Parameters:
- identifier Identifier for this module instance
- config Instance configuration to store
Return: Reference to stored instance configuration
Warning: A previously stored configuration is directly invalidated if the same unique name is used again
An instance configuration is a specialized configuration for a particular module instance. If a ModuleIdentifier already exists an error is thrown.
function getInstanceConfigurations
inline const std::list< Configuration > & getInstanceConfigurations() const
Get all the instance configurations.
Return: Reference to list of instance configurations
The list of instance configurations can contain configurations with duplicate names, but the instanceconfiguration is guaranteed to have a configuration value ‘identifier’ that contains an unique identifier for every same config name.
function dropInstanceConfiguration
void dropInstanceConfiguration(
const ModuleIdentifier & identifier
)
Drops an instance configuration from instance configuration storage.
Parameters:
- identifier Identifier of the module instance to drop
An instance configuration might be dropped when not used (e.g. it is overwritten by another module instance afterwards) We need to remove it from the instance configuration list to ensure dumping the config actually dumps only the instance configurations that were used.
function loadModuleOptions
bool loadModuleOptions(
const std::vector< std::string > & options
)
Load module options and directly apply them to the global configuration and the module configurations.
Parameters:
- options List of options to load and apply
Return: True if any actual options where applied
Note: Instance configuration options are applied in ConfigManager::addInstanceConfiguration instead
Load all extra options that should be added on top of the configuration in the file. The options loaded here are automatically applied to the module instance when these are added later.
function getDetectorConfigurations
std::list< Configuration > & getDetectorConfigurations()
Get all the detector configurations.
Return: Reference to list of detector configurations
The list of detector configurations is read from the configuration defined in ‘detector_file’
function loadDetectorOptions
bool loadDetectorOptions(
const std::vector< std::string > & options
)
Load detector specific options.
Parameters:
- options List of options to load and apply
Return: True if any actual options where applied
Load all extra options that should be added on top of the detector configuration in the file. The options loaded here are automatically applied to the detector instance when these are added later and will be taken into account when possibly loading customized detector models.
Updated on 2024-12-13 at 08:31:37 +0000