Alexandria 2.31.0
SDC-CH common library for the Euclid project
Loading...
Searching...
No Matches
Configuration.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2012-2022 Euclid Science Ground Segment
3 *
4 * This library is free software; you can redistribute it and/or modify it under
5 * the terms of the GNU Lesser General Public License as published by the Free
6 * Software Foundation; either version 3.0 of the License, or (at your option)
7 * any later version.
8 *
9 * This library is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12 * details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this library; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
25#ifndef _CONFIGURATION_CONFIGURATION_H
26#define _CONFIGURATION_CONFIGURATION_H
27
28#include <boost/program_options/options_description.hpp>
29#include <boost/program_options/variables_map.hpp>
30#include <map>
31#include <string>
32#include <typeindex>
33#include <vector>
34
35namespace Euclid {
36namespace Configuration {
37
49
50public:
52 enum class State {
60 FINAL
61 };
62
65
67 explicit Configuration(long manager_id);
68
72 virtual ~Configuration() = default;
73
87
101 virtual void preInitialize(const UserValues& args);
102
116 virtual void initialize(const UserValues& args);
117
132 virtual void postInitialize(const UserValues& args);
133
136
139
141 State getCurrentState() const;
142
143protected:
152 template <typename T>
154
166 template <typename T>
168
169 template <typename T>
170 const T& getDependency() const;
171
172private:
176
177}; /* End of Configuration class */
178
179} /* namespace Configuration */
180} /* namespace Euclid */
181
183
184#endif
Superclass of all configuration classes.
void declareDependency()
Declares a Configuration as dependency.
virtual void initialize(const UserValues &args)
Method which is called during the initialization phase.
std::set< std::type_index > m_dependencies
virtual void preInitialize(const UserValues &args)
Method which is called before the initialization phase.
State & getCurrentState()
Returns the current state of the configuration.
State
Defines the different states the configuration object can be in.
@ FINAL
The postInitialize() method has been called.
@ PRE_INITIALIZED
The preInitialize() method has been called and waits for initialization.
@ INITIALIZED
The initialize() method has been called.
@ CONSTRUCTED
The object has just been constructed.
T & getDependency()
Returns a dependency.
virtual std::map< std::string, OptionDescriptionList > getProgramOptions()
Returns the program options defined by a specific configuration.
const std::set< std::type_index > & getDependencies()
Returns the dependencies of the configuration.
virtual void postInitialize(const UserValues &args)
Method which is called after the initialization phase.
virtual ~Configuration()=default
Destructor.