Elements  6.0.1
A C++ base framework for the Euclid Software.
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 <map> // for map
30 #include <memory> // for unique_ptr
31 #include <string> // for string
32 #include <vector> // for vector
33 
34 #include <boost/program_options/parsers.hpp>
35 #include <log4cpp/Priority.hh>
36 
37 #include "ElementsKernel/Environment.h" // For Environment
38 #include "ElementsKernel/Exit.h" // For ExitCode
39 #include "ElementsKernel/Export.h" // ELEMENTS_API
40 #include "ElementsKernel/Path.h" // for Path::Item
41 #include "ElementsKernel/Program.h"
42 
43 namespace Elements {
44 
56 
57 public:
61  explicit ProgramManager(std::unique_ptr<Program> program_ptr, const std::string& parent_project_version = "",
62  const std::string& parent_project_name = "",
63  const std::string& parent_project_vcs_version = "",
64  const std::string& parent_module_version = "", const std::string& parent_module_name = "",
65  const std::vector<std::string>& search_dirs = {},
66  const log4cpp::Priority::Value& elements_loglevel = log4cpp::Priority::DEBUG);
67 
71  virtual ~ProgramManager();
72 
82  ExitCode run(int argc, char* argv[]);
83 
89  std::string getVersion() const;
90 
95  static void onTerminate() noexcept;
96 
97 private:
104  const Path::Item& getProgramPath() const;
105 
112  const Path::Item& getProgramName() const;
113 
122  static const Path::Item getDefaultConfigFile(const Path::Item& program_name, const std::string& module_name = "");
123 
132  static const Path::Item setProgramName(char* arg0);
133 
142  static const Path::Item setProgramPath(char* arg0);
143 
149  void setup(int argc, char* argv[]);
150 
151  void tearDown(const ExitCode&);
152 
160  const Program::VariablesMap getProgramOptions(int argc, char* argv[]);
161 
165  void logHeader(std::string program_name) const;
166 
170  void logFooter(std::string program_name) const;
171 
176  void logAllOptions() const;
177 
181  void logTheEnvironment() const;
182 
188  void bootstrapEnvironment(char* arg0);
189 
196  template <class charT>
197  void checkCommandLineOptions(const boost::program_options::basic_parsed_options<charT>& cmd_line_options);
198 
199 private:
206  Program::VariablesMap m_variables_map{};
207 
212 
217 
225 
230 
239 
245 
250 
255 
263 
268 
272  log4cpp::Priority::Value m_elements_loglevel;
273 };
274 
275 } // namespace Elements
276 
277 #endif // ELEMENTSKERNEL_ELEMENTSKERNEL_PROGRAMMANAGER_H_
278 
Defines a class to handle the Environment.
define a list of standard exit codes for executables
defines the macros to be used for explicit export of the symbols
provide functions to retrieve resources pointed by environment variables
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::string m_parent_module_name
std::string m_parent_project_name
std::vector< std::string > m_search_dirs
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:65
ExitCode
Strongly typed exit numbers.
Definition: Exit.h:97
#define ELEMENTS_API
Dummy definitions for the backward compatibility mode.
Definition: Export.h:74
boost::filesystem::path Item
Definition: Path.h:56