Elements  5.10
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 <string> // for string
31 #include <memory> // for unique_ptr
32 #include <vector> // for vector
33 
34 #include <boost/filesystem.hpp>
35 #include <boost/program_options.hpp>
36 #include <log4cpp/Priority.hh>
37 
38 #include "ElementsKernel/Export.h" // ELEMENTS_API
39 #include "ElementsKernel/Exit.h" // For ExitCode
40 #include "ElementsKernel/Program.h"
41 #include "ElementsKernel/Environment.h" // For Environment
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 boost::filesystem::path& getProgramPath() const;
109 
116  const boost::filesystem::path& getProgramName() const;
117 
126  static const boost::filesystem::path getDefaultConfigFile(
127  const boost::filesystem::path & program_name,
128  const std::string& module_name = "");
129 
138  static const boost::filesystem::path setProgramName(char* arg0);
139 
148  static const boost::filesystem::path setProgramPath(char* arg0);
149 
155  void setup(int argc, char* argv[]);
156 
157 
158  void tearDown(const ExitCode&);
159 
167  const boost::program_options::variables_map 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  boost::program_options::variables_map 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
boost::filesystem::path m_program_name
std::unique_ptr< Program > m_program_ptr
STL class.
defines the macros to be used for explicit export of the symbols
boost::filesystem::path m_program_path
std::string m_parent_project_name
Class for managing all Elements programs.
std::string m_parent_module_name
boost::filesystem::path path
Definition: DataSyncUtils.h:38
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
STL class.
define a list of standard exit codes for executables
Defines a class to handle the Environment.