Elements  5.8
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/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 
55 
56 public:
57 
62  const std::string& parent_project_version = "",
63  const std::string& parent_project_name = "",
64  const std::string& parent_project_vcs_version = "",
65  const std::string& parent_module_version = "",
66  const std::string& parent_module_name = "",
67  const std::vector<std::string>& search_dirs = {},
68  const log4cpp::Priority::Value& elements_loglevel = log4cpp::Priority::DEBUG);
69 
73  virtual ~ProgramManager();
74 
84  ExitCode run(int argc, char* argv[]);
85 
91  std::string getVersion() const;
92 
97  static void onTerminate() noexcept;
98 
99 private:
100 
107  const boost::filesystem::path& getProgramPath() const;
108 
115  const boost::filesystem::path& getProgramName() const;
116 
125  static const boost::filesystem::path getDefaultConfigFile(
126  const boost::filesystem::path & program_name,
127  const std::string& module_name = "");
128 
137  static const boost::filesystem::path setProgramName(char* arg0);
138 
147  static const boost::filesystem::path setProgramPath(char* arg0);
148 
154  void setup(int argc, char* argv[]);
155 
156 
157  void tearDown(const ExitCode&);
158 
166  const boost::program_options::variables_map getProgramOptions(int argc,
167  char* argv[]);
168 
172  void logHeader(std::string program_name) const;
173 
177  void logFooter(std::string program_name) const;
178 
183  void logAllOptions() const;
184 
188  void logTheEnvironment() const;
189 
195  void bootstrapEnvironment(char* arg0);
196 
203  template<class charT>
204  void checkCommandLineOptions(const boost::program_options::basic_parsed_options<charT>& cmd_line_options);
205 
206 
207 private:
208 
215  boost::program_options::variables_map m_variables_map {};
216 
221 
226 
234 
239 
248 
254 
259 
264 
272 
277 
281  log4cpp::Priority::Value m_elements_loglevel;
282 };
283 
284 } // namespace Elements
285 
286 #endif // ELEMENTSKERNEL_ELEMENTSKERNEL_PROGRAMMANAGER_H_
287 
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:33
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
ExitCode
Strongly typed exit numbers.
Definition: Exit.h:97
STL class.
define a list of standard exit codes for executables
Defines a class to handle the Environment.