Elements  6.2
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 
Elements::Kernel::Path::Item
boost::filesystem::path Item
Definition: Path.h:56
Export.h
defines the macros to be used for explicit export of the symbols
Elements::ProgramManager::m_program_ptr
std::unique_ptr< Program > m_program_ptr
Definition: ProgramManager.h:224
std::string
STL class.
Elements::ProgramManager::m_env
Environment m_env
Definition: ProgramManager.h:267
Path.h
provide functions to retrieve resources pointed by environment variables
std::vector< std::string >
Elements::Program::VariablesMap
variables_map VariablesMap
Definition: Program.h:65
Elements::ProgramManager
Class for managing all Elements programs.
Definition: ProgramManager.h:55
Exit.h
define a list of standard exit codes for executables
Elements::ProgramManager::m_parent_project_version
std::string m_parent_project_version
Definition: ProgramManager.h:229
Elements::ProgramManager::m_parent_project_name
std::string m_parent_project_name
Definition: ProgramManager.h:238
Elements::ExitCode
ExitCode
Strongly typed exit numbers.
Definition: Exit.h:97
Elements::ProgramManager::m_program_path
Path::Item m_program_path
Definition: ProgramManager.h:216
ELEMENTS_API
#define ELEMENTS_API
Dummy definitions for the backward compatibility mode.
Definition: Export.h:74
Elements::ProgramManager::m_program_name
Path::Item m_program_name
Definition: ProgramManager.h:211
Elements::ProgramManager::m_search_dirs
std::vector< std::string > m_search_dirs
Definition: ProgramManager.h:262
Elements::ProgramManager::m_parent_module_name
std::string m_parent_module_name
Definition: ProgramManager.h:254
Elements::ProgramManager::m_parent_module_version
std::string m_parent_module_version
Definition: ProgramManager.h:249
Environment.h
Defines a class to handle the Environment.
Elements::Environment
Python dictionary-like Environment interface.
Definition: Environment.h:44
Program.h
define an abstract class for all Elements program
std::unique_ptr
STL class.
Elements::ProgramManager::m_elements_loglevel
log4cpp::Priority::Value m_elements_loglevel
Definition: ProgramManager.h:272
Elements::ProgramManager::m_parent_project_vcs_version
std::string m_parent_project_vcs_version
Definition: ProgramManager.h:244
Elements
Definition: callBackExample.h:35