Elements 6.1.2
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_SIMPLEPROGRAM_H_
29#define ELEMENTSKERNEL_ELEMENTSKERNEL_SIMPLEPROGRAM_H_
30
32#include "ElementsKernel/Main.h"
33#include "ElementsKernel/Path.h"
34
35namespace Elements {
36
37// Forward declaration. We don't need the definition right now.
38enum class ExitCode;
39
41
42public:
43 ELEMENTS_API ExitCode run(int argc, char** argv) noexcept;
44 ELEMENTS_API const Path::Item& getProgramPath() const;
45 ELEMENTS_API const Path::Item& getProgramName() const;
46
47protected:
48 SimpleProgram() = default;
49 virtual ~SimpleProgram();
50
51 virtual ExitCode main() = 0;
52 virtual void defineOptions() = 0;
53
54private:
55 void setup(int argc, char** argv);
56
57private:
58 Path::Item m_program_name;
59 Path::Item m_program_path;
60};
61
66} // namespace Elements
67
79#define MAIN(ELEMENTS_PROGRAM) \
80 ELEMENTS_API int main(int argc, char* argv[]) { \
81 auto program = ELEMENTS_PROGRAM(); \
82 Elements::ExitCode exit_code = program.run(argc, argv); \
83 return static_cast<Elements::ExitCodeType>(exit_code); \
84 }
85
86#endif // ELEMENTSKERNEL_ELEMENTSKERNEL_SIMPLEPROGRAM_H_
87
defines the macros to be used for explicit export of the symbols
Definition of the top macro to create an Elements program.
provide functions to retrieve resources pointed by environment variables
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