Alexandria  2.16
Please provide a description of the project.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Configuration.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_CONFIGURATION_H
23 #define _CONFIGURATION_CONFIGURATION_H
24 
25 #include <vector>
26 #include <set>
27 #include <map>
28 #include <string>
29 #include <typeindex>
30 #include <boost/program_options.hpp>
31 
32 namespace Euclid {
33 namespace Configuration {
34 
46 
47 public:
48 
50  enum class State {
58  FINAL
59  };
60 
63 
65  explicit Configuration(long manager_id);
66 
70  virtual ~Configuration() = default;
71 
85 
99  virtual void preInitialize(const UserValues& args);
100 
114  virtual void initialize(const UserValues& args);
115 
130  virtual void postInitialize(const UserValues& args);
131 
134 
137 
139  State getCurrentState() const;
140 
141 protected:
142 
151  template <typename T>
152  void declareDependency();
153 
165  template <typename T>
166  T& getDependency();
167 
168  template <typename T>
169  const T& getDependency() const;
170 
171 private:
172 
176 
177 }; /* End of Configuration class */
178 
179 } /* namespace Configuration */
180 } /* namespace Euclid */
181 
183 
184 #endif
Configuration(long manager_id)
Constructs a new Configuration instance.
Superclass of all configuration classes.
Definition: Configuration.h:45
void declareDependency()
Declares a Configuration as dependency.
State & getCurrentState()
Returns the current state of the configuration.
STL class.
virtual std::map< std::string, OptionDescriptionList > getProgramOptions()
Returns the program options defined by a specific configuration.
virtual void preInitialize(const UserValues &args)
Method which is called before the initialization phase.
virtual void initialize(const UserValues &args)
Method which is called during the initialization phase.
The postInitialize() method has been called.
T & getDependency()
Returns a dependency.
The preInitialize() method has been called and waits for initialization.
std::set< std::type_index > m_dependencies
STL class.
const std::set< std::type_index > & getDependencies()
Returns the dependencies of the configuration.
virtual ~Configuration()=default
Destructor.
The initialize() method has been called.
State
Defines the different states the configuration object can be in.
Definition: Configuration.h:50
The object has just been constructed.
virtual void postInitialize(const UserValues &args)
Method which is called after the initialization phase.