Elements  5.12
A C++ base framework for the Euclid Software.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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 <string> // for string
31 #include <memory> // for unique_ptr
32 #include <vector> // for vector
33 
34 #include <boost/program_options/parsers.hpp>
35 #include <log4cpp/Priority.hh>
36 
37 #include "ElementsKernel/Export.h" // ELEMENTS_API
38 #include "ElementsKernel/Exit.h" // For ExitCode
39 #include "ElementsKernel/Program.h"
40 #include "ElementsKernel/Environment.h" // For Environment
41 #include "ElementsKernel/Path.h" // for Path::Item
42 
43 namespace Elements {
44 
56 
57 public:
58 
63  const std::string& parent_project_version = "",
64  const std::string& parent_project_name = "",
65  const std::string& parent_project_vcs_version = "",
66  const std::string& parent_module_version = "",
67  const std::string& parent_module_name = "",
68  const std::vector<std::string>& search_dirs = {},
69  const log4cpp::Priority::Value& elements_loglevel = log4cpp::Priority::DEBUG);
70 
74  virtual ~ProgramManager();
75 
85  ExitCode run(int argc, char* argv[]);
86 
92  std::string getVersion() const;
93 
98  static void onTerminate() noexcept;
99 
100 private:
101 
108  const Path::Item& getProgramPath() const;
109 
116  const Path::Item& getProgramName() const;
117 
126  static const Path::Item getDefaultConfigFile(
127  const Path::Item& program_name,
128  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 
158  void tearDown(const ExitCode&);
159 
167  const Program::VariablesMap getProgramOptions(int argc,
168  char* argv[]);
169 
173  void logHeader(std::string program_name) const;
174 
178  void logFooter(std::string program_name) const;
179 
184  void logAllOptions() const;
185 
189  void logTheEnvironment() const;
190 
196  void bootstrapEnvironment(char* arg0);
197 
204  template<class charT>
205  void checkCommandLineOptions(const boost::program_options::basic_parsed_options<charT>& cmd_line_options);
206 
207 
208 private:
209 
216  Program::VariablesMap m_variables_map {};
217 
222 
227 
235 
240 
249 
255 
260 
265 
273 
278 
282  log4cpp::Priority::Value m_elements_loglevel;
283 };
284 
285 } // namespace Elements
286 
287 #endif // ELEMENTSKERNEL_ELEMENTSKERNEL_PROGRAMMANAGER_H_
288 
ExitCode
Strongly typed exit numbers.
Definition: Exit.h:98
std::string m_parent_project_vcs_version
log4cpp::Priority::Value m_elements_loglevel
std::string m_parent_project_version
std::unique_ptr< Program > m_program_ptr
STL class.
defines the macros to be used for explicit export of the symbols
std::string m_parent_project_name
Class for managing all Elements programs.
std::string m_parent_module_name
std::string m_parent_module_version
std::vector< std::string > m_search_dirs
define an abstract class for all Elements program
#define ELEMENTS_API
Dummy definitions for the backward compatibility mode.
Definition: Export.h:74
boost::filesystem::path Item
Definition: Path.h:61
variables_map VariablesMap
Definition: Program.h:66
STL class.
define a list of standard exit codes for executables
Defines a class to handle the Environment.
provide functions to retrieve resources pointed by environment variables