Elements  6.2
A C++ base framework for the Euclid Software.
Main.h
Go to the documentation of this file.
1 
26 #ifndef ELEMENTSKERNEL_ELEMENTSKERNEL_MAIN_H_
27 #define ELEMENTSKERNEL_ELEMENTSKERNEL_MAIN_H_
28 
29 #include <exception> // for set_terminate
30 #include <log4cpp/Priority.hh>
31 #include <memory> // for unique_ptr
32 
33 #include "ElementsKernel/Exit.h" // for ExitCode
34 #include "ElementsKernel/Export.h" // for ELEMENTS_API
35 #include "ElementsKernel/Module.h" // for Module
36 #include "ElementsKernel/ProgramManager.h" // for ProgramManager
37 #include "ElementsKernel/Project.h" // for Project
38 #include "ElementsKernel/Unused.h" // for ELEMENTS_UNUSED
39 
40 #ifndef ELEMENTS_DEFAULT_LOGLEVEL
41 #define ELEMENTS_DEFAULT_LOGLEVEL DEBUG
42 #endif
43 
52 #define CREATE_MANAGER_WITH_ARGS(MANAGER, ELEMENTS_PROGRAM, ...) \
53  Elements::ProgramManager MANAGER { \
54  std::unique_ptr<Elements::Program>{new ELEMENTS_PROGRAM{__VA_ARGS__}}, Elements::Project::versionString(), \
55  Elements::Project::name(), Elements::Project::vcsVersion(), Elements::Module::versionString(), \
56  Elements::Module::name(), Elements::Project::searchDirectories(), log4cpp::Priority::ELEMENTS_DEFAULT_LOGLEVEL \
57  }
58 
67 #define CREATE_MANAGER(ELEMENTS_PROGRAM_NAME, MANAGER) CREATE_MANAGER_WITH_ARGS(MANAGER, ELEMENTS_PROGRAM_NAME, )
68 
87 #define MAIN_FOR_WITH_ARGS(ELEMENTS_PROGRAM, ...) \
88  ELEMENTS_UNUSED const auto installed = {std::set_terminate(&Elements::ProgramManager::onTerminate)}; \
89  ELEMENTS_API int main(int argc, char* argv[]) { \
90  CREATE_MANAGER_WITH_ARGS(manager, ELEMENTS_PROGRAM, __VA_ARGS__); \
91  Elements::ExitCode exit_code = manager.run(argc, argv); \
92  return static_cast<Elements::ExitCodeType>(exit_code); \
93  }
94 
113 #define MAIN_FOR(ELEMENTS_PROGRAM_NAME) MAIN_FOR_WITH_ARGS(ELEMENTS_PROGRAM_NAME, )
114 
115 #endif // ELEMENTSKERNEL_ELEMENTSKERNEL_MAIN_H_
116 
Export.h
defines the macros to be used for explicit export of the symbols
Project.h
Defines tools to describe the current project.
Module.h
Defines tools to describe the current Elmeents module.
Exit.h
define a list of standard exit codes for executables
ProgramManager.h
Unused.h
Macro to silence unused variables warnings from the compiler.