Elements  6.2
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  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 
47 protected:
48  SimpleProgram() = default;
49  virtual ~SimpleProgram();
50 
51  virtual ExitCode main() = 0;
52  virtual void defineOptions() = 0;
53 
54 private:
55  void setup(int argc, char** argv);
56 
57 private:
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 
Elements::Kernel::Path::Item
boost::filesystem::path Item
Definition: Path.h:56
Export.h
defines the macros to be used for explicit export of the symbols
Path.h
provide functions to retrieve resources pointed by environment variables
main
int main(int argc, char *argv[])
Definition: cutout.c:31
Elements::SimpleProgram::m_program_path
Path::Item m_program_path
Definition: SimpleProgram.h:59
Elements::ExitCode
ExitCode
Strongly typed exit numbers.
Definition: Exit.h:97
ELEMENTS_API
#define ELEMENTS_API
Dummy definitions for the backward compatibility mode.
Definition: Export.h:74
Elements::SimpleProgram
Definition: SimpleProgram.h:40
Elements::SimpleProgram::m_program_name
Path::Item m_program_name
Definition: SimpleProgram.h:58
Main.h
Definition of the top macro to create an Elements program.
Elements
Definition: callBackExample.h:35