Elements 6.3.3
A C++ base framework for the Euclid Software.
Loading...
Searching...
No Matches
Main.h
Go to the documentation of this file.
1
20
25
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#ifndef NO_CONFIG_FILE
53#define CREATE_MANAGER_WITH_ARGS(MANAGER, ELEMENTS_PROGRAM, ...) \
54 Elements::ProgramManager MANAGER { \
55 std::unique_ptr<Elements::Program>{new ELEMENTS_PROGRAM{__VA_ARGS__}}, Elements::Project::versionString(), \
56 Elements::Project::name(), Elements::Project::vcsVersion(), Elements::Module::versionString(), \
57 Elements::Module::name(), Elements::Project::searchDirectories(), log4cpp::Priority::ELEMENTS_DEFAULT_LOGLEVEL \
58 }
59#else
60#define CREATE_MANAGER_WITH_ARGS(MANAGER, ELEMENTS_PROGRAM, ...) \
61 Elements::ProgramManager MANAGER { \
62 std::unique_ptr<Elements::Program>{new ELEMENTS_PROGRAM{__VA_ARGS__}}, Elements::Project::versionString(), \
63 Elements::Project::name(), Elements::Project::vcsVersion(), Elements::Module::versionString(), \
64 Elements::Module::name(), Elements::Project::searchDirectories(), \
65 log4cpp::Priority::ELEMENTS_DEFAULT_LOGLEVEL, true \
66 }
67#endif
68
77#define CREATE_MANAGER(ELEMENTS_PROGRAM_NAME, MANAGER) CREATE_MANAGER_WITH_ARGS(MANAGER, ELEMENTS_PROGRAM_NAME, )
78
97#define MAIN_FOR_WITH_ARGS(ELEMENTS_PROGRAM, ...) \
98 ELEMENTS_UNUSED const auto installed = {std::set_terminate(&Elements::ProgramManager::onTerminate)}; \
99 ELEMENTS_API int main(int argc, char* argv[]) { \
100 CREATE_MANAGER_WITH_ARGS(manager, ELEMENTS_PROGRAM, __VA_ARGS__); \
101 Elements::ExitCode exit_code = manager.run(argc, argv); \
102 return static_cast<Elements::ExitCodeType>(exit_code); \
103 }
104
123#define MAIN_FOR(ELEMENTS_PROGRAM_NAME) MAIN_FOR_WITH_ARGS(ELEMENTS_PROGRAM_NAME, )
124
125#endif // ELEMENTSKERNEL_ELEMENTSKERNEL_MAIN_H_
126
131
define a list of standard exit codes for executables
defines the macros to be used for explicit export of the symbols
Defines tools to describe the current Elmeents module.
Defines tools to describe the current project.
Macro to silence unused variables warnings from the compiler.