Commit 2044c637 authored by Simon Spannagel's avatar Simon Spannagel
Browse files

Module: make ConfigManager available

parent 2c9d2b15
......@@ -82,3 +82,17 @@ bool Module::has_detector(std::string name) {
Configuration& Module::get_configuration() {
return m_config;
}
/**
* @throws InvalidModuleActionException If this method is called from the constructor or destructor
* @warning This function technically allows to write to the configurations of other modules, but this should never be done
*/
ConfigManager* Module::getConfigManager() {
if(conf_manager_ == nullptr) {
throw InvalidModuleActionException("Cannot access the config manager in constructor or destructor.");
};
return conf_manager_;
}
void Module::set_config_manager(ConfigManager* conf_manager) {
conf_manager_ = conf_manager;
}
......@@ -13,7 +13,7 @@
#include "ModuleIdentifier.hpp"
#include "core/clipboard/Clipboard.hpp"
#include "core/config/Configuration.hpp"
#include "core/config/ConfigManager.hpp"
#include "core/detector/Detector.hpp"
#include "exceptions.h"
......@@ -116,6 +116,12 @@ namespace corryvreckan {
*/
virtual void finalise(){};
/**
* @brief Get the config manager object to allow to read the global and other module configurations
* @return Pointer to the config manager
*/
ConfigManager* getConfigManager();
/**
* @brief Get ROOT directory which should be used to output histograms et cetera
* @return ROOT directory for storage
......@@ -176,6 +182,13 @@ namespace corryvreckan {
ModuleIdentifier get_identifier() const;
ModuleIdentifier identifier_;
/**
* @brief Set the link to the config manager
* @param conf_manager ConfigManager holding all relevant configurations
*/
void set_config_manager(ConfigManager* config);
ConfigManager* conf_manager_{nullptr};
/**
* @brief Set the output ROOT directory for this module
* @param directory ROOT directory for storage
......
......@@ -589,6 +589,9 @@ void ModuleManager::initialiseAll() {
// Loop over all modules and initialise them
LOG(STATUS) << "=================| Initialising modules |==================";
for(auto& module : m_modules) {
// Pass the config manager to this instance
module->set_config_manager(conf_manager_);
// Create main ROOT directory for this module class if it does not exists yet
LOG(TRACE) << "Creating and accessing ROOT directory";
std::string module_name = module->getConfig().getName();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment