Alexandria 2.25.0
SDC-CH common library for the Euclid project
Configuration.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_CONFIGURATION_H
23#define _CONFIGURATION_CONFIGURATION_H
24
25#include <boost/program_options.hpp>
26#include <map>
27#include <set>
28#include <string>
29#include <typeindex>
30#include <vector>
31
32namespace Euclid {
33namespace Configuration {
34
46
47public:
49 enum class State {
51 CONSTRUCTED,
53 PRE_INITIALIZED,
55 INITIALIZED,
57 FINAL
58 };
59
62
64 explicit Configuration(long manager_id);
65
69 virtual ~Configuration() = default;
70
84
98 virtual void preInitialize(const UserValues& args);
99
113 virtual void initialize(const UserValues& args);
114
129 virtual void postInitialize(const UserValues& args);
130
133
136
138 State getCurrentState() const;
139
140protected:
149 template <typename T>
151
163 template <typename T>
165
166 template <typename T>
167 const T& getDependency() const;
168
169private:
173
174}; /* End of Configuration class */
175
176} /* namespace Configuration */
177} /* namespace Euclid */
178
180
181#endif
Superclass of all configuration classes.
Definition: Configuration.h:45
void declareDependency()
Declares a Configuration as dependency.
virtual void initialize(const UserValues &args)
Method which is called during the initialization phase.
Configuration(long manager_id)
Constructs a new Configuration instance.
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.
Definition: Configuration.h:49
@ 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.