Alexandria 2.25.0
SDC-CH common library for the Euclid project
ConfigManager.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2012-2021 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 <boost/program_options.hpp>
26#include <map>
27#include <memory>
28#include <string>
29#include <typeindex>
30
31namespace Euclid {
32namespace 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.
36class Configuration;
37
82
83public:
85 static ConfigManager& getInstance(long id);
86
90 virtual ~ConfigManager() = default;
91
106 template <typename T>
108
129 template <typename T1, typename T2>
131
147 boost::program_options::options_description closeRegistration();
148
169
183 template <typename T>
185
186private:
187 explicit ConfigManager(long id);
188
189 enum class State { REGISTRATION, WAITING_INITIALIZATION, INITIALIZED };
190
191 long m_id;
196
197}; /* End of ConfigManager class */
198
199} /* namespace Configuration */
200} /* namespace Euclid */
201
203
204#endif
Manages a set of configuration classes.
Definition: ConfigManager.h:81
std::unique_ptr< std::type_index > m_root_config
void registerConfiguration()
Registers a Configuration to the manager.
void registerDependency()
Registers a dependency between two configurations.
std::map< std::type_index, std::unique_ptr< Configuration > > m_config_dictionary
T & getConfiguration()
Returns a reference to the requested configuration.
virtual ~ConfigManager()=default
Destructor.
void initialize(const std::map< std::string, boost::program_options::variable_value > &user_values)
Initialize the manager.
std::map< std::type_index, std::set< std::type_index > > m_dependency_map
boost::program_options::options_description closeRegistration()
Terminates the manager registration phase.
static ConfigManager & getInstance(long id)
Returns a reference to the ConfigManager with the given ID.