Elements 6.3.1
A C++ base framework for the Euclid Software.
Loading...
Searching...
No Matches
SimpleProgram.h
Go to the documentation of this file.
1
28#ifndef ELEMENTSKERNEL_ELEMENTSKERNEL_SIMPLE_PROGRAM_H_
29#define ELEMENTSKERNEL_ELEMENTSKERNEL_SIMPLE_PROGRAM_H_
30
31#include "ElementsKernel/Export.h" // for ELEMENTS_API
32#include "ElementsKernel/Logging.h" // for Logging
33#include "ElementsKernel/Path.h" // for Item
34
35namespace Elements {
36enum class ExitCode;
37}
38
39namespace Elements {
40
42
43public:
46
47 ExitCode run(int argc, char** argv) noexcept;
48 const Path::Item& getProgramPath() const;
49 const Path::Item& getProgramName() const;
50
51protected:
52 SimpleProgram() = default;
53 virtual ~SimpleProgram();
54
55 virtual ExitCode main() = 0;
56 virtual void defineOptions() = 0;
57
58private:
59 void setup(int argc, char** argv);
60
61private:
62 Path::Item m_program_name;
63 Path::Item m_program_path;
64};
65
70} // namespace Elements
71
83#define MAIN(ELEMENTS_PROGRAM) \
84 ELEMENTS_API int main(int argc, char* argv[]) { \
85 auto program = ELEMENTS_PROGRAM(); \
86 Elements::ExitCode exit_code = program.run(argc, argv); \
87 return static_cast<Elements::ExitCodeType>(exit_code); \
88 }
89
90#endif // ELEMENTSKERNEL_ELEMENTSKERNEL_SIMPLE_PROGRAM_H_
91
defines the macros to be used for explicit export of the symbols
Logging facility.
provide functions to retrieve resources pointed by environment variables
Logging API of the Elements framework.
Definition Logging.h:93
virtual ExitCode main()=0
virtual void defineOptions()=0
ExitCode
Strongly typed exit numbers.
Definition Exit.h:97
#define ELEMENTS_API
Dummy definitions for the backward compatibility mode.
Definition Export.h:74