GooFit  v2.1.3
Application.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <csignal>
4 
5 #include <CLI/CLI.hpp>
6 
7 #include <goofit/Color.h>
8 #include <goofit/Error.h>
9 #include <goofit/Log.h>
10 
11 #define GOOFIT_PARSE(app, ...) \
12  try { \
13  app.run(); \
14  } catch(const GooFit::ParseError &e) { \
15  return app.exit(e); \
16  }
17 
18 namespace GooFit {
19 
21 void signal_handler(int s);
22 
23 // Importing into the GooFit namespace the main classes from CLI11
24 using CLI::App;
25 using CLI::ExistingDirectory;
26 using CLI::ExistingFile;
27 using CLI::ExitCodes;
28 using CLI::FileError;
29 using CLI::NonexistentPath;
30 using CLI::Option;
31 using CLI::ParseError;
32 using CLI::Success;
33 
37 void print_splash();
38 
40 void print_goofit_info(int gpuDev_ = 0);
41 
42 class Application : public CLI::App {
43  protected:
44  int gpuDev_ = 0;
45  bool show_gpus_;
46  bool quiet_;
47  bool splash_;
48  int argc_;
49  char **argv_;
50 
52  struct sigaction sigIntHandler;
53 
54  public:
56  Application(std::string discription, int argc, char **argv);
57 
59  Application(int argc, char **argv)
60  : Application("", argc, argv) {}
61 
63  int get_device() const { return gpuDev_; }
64 
66  void run() { parse(argc_, argv_); }
67 
69  void pre_callback() override;
70 
72  int exit(const CLI::Error &e);
73 
76  void set_device() const;
77 
79  ~Application() override;
80 
83  std::string get_filename(const std::string &input_str, std::string base = "") const;
84 };
85 } // namespace GooFit
void run()
simple run since argc and argv are stored
Definition: Application.h:66
void set_device() const
void signal_handler(int s)
will call the correct exit func, no unwinding of the stack though
Definition: Application.cpp:25
~Application() override
Cleanup MPI if needed.
void print_splash()
Definition: Application.cpp:31
void print_goofit_info(int gpuDev_=0)
Print out information about GooFit.
Definition: Application.cpp:74
struct sigaction sigIntHandler
Handle control-c codes.
Definition: Application.h:52
Application(int argc, char **argv)
Shortcut for the lazy.
Definition: Application.h:59
int exit(const CLI::Error &e)
Exit.
void pre_callback() override
Gets called in parse.
Application(std::string discription, int argc, char **argv)
Make a new Application.
int get_device() const
Get the set GPU device.
Definition: Application.h:63
std::string get_filename(const std::string &input_str, std::string base="") const