LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
OptionsHandler.h
Go to the documentation of this file.
1 #ifndef art_Framework_Art_OptionsHandler_h
2 #define art_Framework_Art_OptionsHandler_h
3 // Simple interface to allow easy addition of experiment-specific
4 // command-line options and their processing.
5 
6 #include "boost/program_options.hpp"
7 #include "fhiclcpp/fwd.h"
8 
9 namespace bpo = boost::program_options;
10 
11 namespace art {
12 
14  public:
15  virtual ~OptionsHandler() = default;
16 
17  int checkOptions(bpo::variables_map const& vm);
18  int processOptions(bpo::variables_map const& vm,
19  fhicl::intermediate_table& raw_config);
20 
21  private:
22  // Check selected options for consistency (should throw on failure).
23  virtual int doCheckOptions(bpo::variables_map const& vm) = 0;
24  // Act on selected options (should throw on failure).
25  virtual int doProcessOptions(bpo::variables_map const& vm,
26  fhicl::intermediate_table& raw_config) = 0;
27  };
28 
29  // Clang-format has trouble with the 'add_options()()()...()'
30  // pattern. We therefore provide a template to facilitate a better
31  // format.
32  template <typename T, typename... Args>
33  void
34  add_opt(T& t, Args&&... args)
35  {
36  t(std::forward<Args>(args)...);
37  }
38 
39 } // namespace art
40 
41 #endif /* art_Framework_Art_OptionsHandler_h */
42 
43 // Local Variables:
44 // mode: c++
45 // End:
void add_opt(T &t, Args &&...args)
virtual ~OptionsHandler()=default
int processOptions(bpo::variables_map const &vm, fhicl::intermediate_table &raw_config)
virtual int doCheckOptions(bpo::variables_map const &vm)=0
HLT enums.
int checkOptions(bpo::variables_map const &vm)
virtual int doProcessOptions(bpo::variables_map const &vm, fhicl::intermediate_table &raw_config)=0