Alexandria  2.14.1
Please provide a description of the project.
ConfigManager.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2020 Euclid Science Ground Segment
3  *
4  * This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General
5  * Public License as published by the Free Software Foundation; either version 3.0 of the License, or (at your option)
6  * any later version.
7  *
8  * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
9  * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
10  * details.
11  *
12  * You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to
13  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
14  */
15 
22 #ifndef _CONFIGURATION_CONFIGMANAGER_H
23 #define _CONFIGURATION_CONFIGMANAGER_H
24 
25 #include <map>
26 #include <string>
27 #include <memory>
28 #include <typeindex>
29 #include <boost/program_options.hpp>
30 
31 namespace Euclid {
32 namespace Configuration {
33 
34 // Forward definition of the Configuration class. It is included in the .icpp
35 // file. This is done to break the include circle.
36 class Configuration;
37 
82 
83 public:
84 
86  static ConfigManager& getInstance(long id);
87 
91  virtual ~ConfigManager() = default;
92 
107  template <typename T>
108  void registerConfiguration();
109 
130  template <typename T1, typename T2>
131  void registerDependency();
132 
148  boost::program_options::options_description closeRegistration();
149 
150 
171 
185  template <typename T>
186  T& getConfiguration();
187 
188 private:
189 
190  ConfigManager(long id);
191 
192  enum class State {
194  };
195 
196  long m_id;
201 
202 }; /* End of ConfigManager class */
203 
204 } /* namespace Configuration */
205 } /* namespace Euclid */
206 
208 
209 #endif
Euclid::Configuration::ConfigManager::registerConfiguration
void registerConfiguration()
Registers a Configuration to the manager.
Euclid::Configuration::ConfigManager
Manages a set of configuration classes.
Definition: ConfigManager.h:81
Euclid::Configuration::ConfigManager::State::REGISTRATION
@ REGISTRATION
Euclid::Configuration::ConfigManager::initialize
void initialize(const std::map< std::string, boost::program_options::variable_value > &user_values)
Initialize the manager.
Definition: ConfigManager.cpp:157
Euclid::Configuration::ConfigManager::closeRegistration
boost::program_options::options_description closeRegistration()
Terminates the manager registration phase.
Definition: ConfigManager.cpp:94
Euclid::Configuration::ConfigManager::State
State
Definition: ConfigManager.h:192
Euclid::Configuration::ConfigManager::getConfiguration
T & getConfiguration()
Returns a reference to the requested configuration.
Euclid::Configuration::ConfigManager::m_config_dictionary
std::map< std::type_index, std::unique_ptr< Configuration > > m_config_dictionary
Definition: ConfigManager.h:199
ConfigManager.icpp
Euclid::Configuration::ConfigManager::m_dependency_map
std::map< std::type_index, std::set< std::type_index > > m_dependency_map
Definition: ConfigManager.h:200
Euclid::Configuration::ConfigManager::m_id
long m_id
Definition: ConfigManager.h:196
Euclid::Configuration::ConfigManager::ConfigManager
ConfigManager(long id)
Definition: ConfigManager.cpp:43
std::map
STL class.
Euclid::Configuration::ConfigManager::State::WAITING_INITIALIZATION
@ WAITING_INITIALIZATION
Euclid::Configuration::ConfigManager::m_state
State m_state
Definition: ConfigManager.h:197
Euclid::Configuration::ConfigManager::State::INITIALIZED
@ INITIALIZED
Euclid::Configuration::ConfigManager::~ConfigManager
virtual ~ConfigManager()=default
Destructor.
Euclid::Configuration::ConfigManager::m_root_config
std::unique_ptr< std::type_index > m_root_config
Definition: ConfigManager.h:198
std::unique_ptr< std::type_index >
Euclid
Definition: InstOrRefHolder.h:29
Euclid::Configuration::ConfigManager::getInstance
static ConfigManager & getInstance(long id)
Returns a reference to the ConfigManager with the given ID.
Definition: ConfigManager.cpp:34
Euclid::Configuration::ConfigManager::registerDependency
void registerDependency()
Registers a dependency between two configurations.