Elements 6.3.1
A C++ base framework for the Euclid Software.
Loading...
Searching...
No Matches
ProgramManager.h
Go to the documentation of this file.
1
26#ifndef ELEMENTSKERNEL_ELEMENTSKERNEL_PROGRAMMANAGER_H_
27#define ELEMENTSKERNEL_ELEMENTSKERNEL_PROGRAMMANAGER_H_
28
29#include <memory> // for allocator, unique_ptr
30#include <string> // for string, basic_string
31#include <vector> // for vector
32
33#include <log4cpp/Priority.hh> // for Priority, Priority::DEBUG
34
35#include "ElementsKernel/Environment.h" // for Environment
36#include "ElementsKernel/Export.h" // for ELEMENTS_API
37#include "ElementsKernel/Path.h" // for Item
38#include "ElementsKernel/Program.h" // IWYU pragma: keep
39
40namespace Elements {
41enum class ExitCode : int;
42}
44template <class charT>
46}
47
48namespace Elements {
49
61
62public:
66 explicit ProgramManager(std::unique_ptr<Program> program_ptr, const std::string& parent_project_version = "",
67 const std::string& parent_project_name = "",
68 const std::string& parent_project_vcs_version = "",
69 const std::string& parent_module_version = "", const std::string& parent_module_name = "",
70 const std::vector<std::string>& search_dirs = {},
71 const log4cpp::Priority::Value& elements_loglevel = log4cpp::Priority::DEBUG,
72 bool no_config_file = false);
73
77 virtual ~ProgramManager();
78
88 ExitCode run(int argc, char* argv[]);
89
95 std::string getVersion() const;
96
101 static void onTerminate() noexcept;
102
103private:
110 const Path::Item& getProgramPath() const;
111
118 const Path::Item& getProgramName() const;
119
128 static const Path::Item getDefaultConfigFile(const Path::Item& program_name, const std::string& module_name = "");
129
138 static const Path::Item setProgramName(char* arg0);
139
148 static const Path::Item setProgramPath(char* arg0);
149
155 void setup(int argc, char* argv[]);
156
157 void tearDown(const ExitCode&);
158
166 const Program::VariablesMap getProgramOptions(int argc, char* argv[]);
167
171 void logHeader(std::string program_name) const;
172
176 void logFooter(std::string program_name) const;
177
182 void logAllOptions() const;
183
187 void logTheEnvironment() const;
188
194 void bootstrapEnvironment(char* arg0);
195
202 template <class charT>
204
205private:
212 Program::VariablesMap m_variables_map{};
213
217 Path::Item m_program_name;
218
222 Path::Item m_program_path;
223
231
236
245
251
256
261
269
274
278 log4cpp::Priority::Value m_elements_loglevel;
279
284};
285
286} // namespace Elements
287
288#define ELEMENTSKERNEL_ELEMENTSKERNEL_PROGRAM_MANAGER_IMPL_
289#include "ElementsKernel/_impl/ProgramManager.tpp" // IWYU pragma: export
290#undef ELEMENTSKERNEL_ELEMENTSKERNEL_PROGRAM_MANAGER_IMPL_
291
292#endif // ELEMENTSKERNEL_ELEMENTSKERNEL_PROGRAMMANAGER_H_
293
Defines a class to handle the Environment.
defines the macros to be used for explicit export of the symbols
provide functions to retrieve resources pointed by environment variables
implementation of the templates declared in ElementsKernel/Auxiliary.h
define an abstract class for all Elements program
Python dictionary-like Environment interface.
Definition Environment.h:44
Class for managing all Elements programs.
std::string m_parent_project_version
std::unique_ptr< Program > m_program_ptr
std::vector< std::string > m_search_dirs
void checkCommandLineOptions(const boost::program_options::basic_parsed_options< charT > &cmd_line_options)
check the explicit command line arguments. For the moment, it only checks if the configuration file b...
std::string m_parent_module_version
log4cpp::Priority::Value m_elements_loglevel
std::string m_parent_project_vcs_version
variables_map VariablesMap
Definition Program.h:67
ExitCode
Strongly typed exit numbers.
Definition Exit.h:97
#define ELEMENTS_API
Dummy definitions for the backward compatibility mode.
Definition Export.h:74