Elements  5.12.0
A C++ base framework for the Euclid Software.
SimpleProgram.h
Go to the documentation of this file.
1 
28 #ifndef ELEMENTSKERNEL_ELEMENTSKERNEL_SIMPLEPROGRAM_H_
29 #define ELEMENTSKERNEL_ELEMENTSKERNEL_SIMPLEPROGRAM_H_
30 
31 #include "ElementsKernel/Export.h"
32 #include "ElementsKernel/Main.h"
33 #include "ElementsKernel/Path.h"
34 
35 namespace Elements {
36 
37 // Forward declaration. We don't need the definition right now.
38 enum class ExitCode;
39 
41 
42 public:
43 
44  ELEMENTS_API ExitCode run(int argc, char** argv) noexcept;
45  ELEMENTS_API const Path::Item& getProgramPath() const;
46  ELEMENTS_API const Path::Item& getProgramName() const;
47 
48 
49 protected:
50 
51  SimpleProgram() = default;
52  virtual ~SimpleProgram();
53 
54  virtual ExitCode main() = 0;
55  virtual void defineOptions() = 0;
56 
57 private:
58 
59  void setup(int argc, char** argv);
60 
61 private:
62 
65 
66 };
67 
73 } // namespace Elements
74 
86 #define MAIN(ELEMENTS_PROGRAM) \
87  ELEMENTS_API int main(int argc, char* argv[]) \
88  { \
89  auto program = ELEMENTS_PROGRAM();\
90  Elements::ExitCode exit_code = program.run(argc, argv); \
91  return static_cast<Elements::ExitCodeType>(exit_code); \
92  }
93 
94 #endif // ELEMENTSKERNEL_ELEMENTSKERNEL_SIMPLEPROGRAM_H_
95 
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:98
#define ELEMENTS_API
Dummy definitions for the backward compatibility mode.
Definition: Export.h:74
boost::filesystem::path Item
Definition: Path.h:61