Elements  5.10
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 <boost/filesystem/path.hpp>
32 
33 #include "ElementsKernel/Export.h"
34 #include "ElementsKernel/Main.h"
35 
36 namespace Elements {
37 
38 // Forward declaration. We don't need the definition right now.
39 enum class ExitCode;
40 
42 
43 public:
44 
45  ELEMENTS_API ExitCode run(int argc, char** argv) noexcept;
46  ELEMENTS_API const boost::filesystem::path& getProgramPath() const;
47  ELEMENTS_API const boost::filesystem::path& getProgramName() const;
48 
49 
50 protected:
51 
52  SimpleProgram() = default;
53  virtual ~SimpleProgram();
54 
55  virtual ExitCode main() = 0;
56  virtual void defineOptions() = 0;
57 
58 private:
59 
60  void setup(int argc, char** argv);
61 
62 private:
63 
66 
67 };
68 
74 } // namespace Elements
75 
87 #define MAIN(ELEMENTS_PROGRAM) \
88  ELEMENTS_API int main(int argc, char* argv[]) \
89  { \
90  auto program = ELEMENTS_PROGRAM();\
91  Elements::ExitCode exit_code = program.run(argc, argv); \
92  return static_cast<Elements::ExitCodeType>(exit_code); \
93  }
94 
95 #endif // ELEMENTSKERNEL_ELEMENTSKERNEL_SIMPLEPROGRAM_H_
96 
ExitCode
Strongly typed exit numbers.
Definition: Exit.h:98
boost::filesystem::path m_program_name
Definition: SimpleProgram.h:64
defines the macros to be used for explicit export of the symbols
Definition of the top macro to create an Elements program.
int main(int argc, char *argv[])
Definition: cutout.c:31
boost::filesystem::path path
Definition: DataSyncUtils.h:38
#define ELEMENTS_API
Dummy definitions for the backward compatibility mode.
Definition: Export.h:74
boost::filesystem::path m_program_path
Definition: SimpleProgram.h:65