LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
artapp.cc
Go to the documentation of this file.
2 
10 #include "cetlib/filepath_maker.h"
11 
12 #include "boost/filesystem.hpp"
13 #include "boost/program_options.hpp"
14 
15 #include <iostream>
16 #include <memory>
17 #include <string>
18 
19 namespace bpo = boost::program_options;
20 
21 #define ART_RETHROW_DEFAULT 0
22 
23 int artapp(int argc, char* argv[])
24 {
25  // Configuration file lookup policy.
26  char const* fhicl_env = getenv("FHICL_FILE_PATH");
27  std::string search_path;
28  if (fhicl_env == nullptr) {
29  std::cerr << "Expected environment variable FHICL_FILE_PATH is "
30  << "missing or empty: using \".\"\n";
31  search_path = ".";
32  }
33  else {
34  search_path = std::string{fhicl_env};
35  }
36  cet::filepath_first_absolute_or_lookup_with_dot lookupPolicy{search_path};
37  // Empty options_description.
38  bpo::options_description all_desc;
39  // Create and store options handlers.
40  art::OptionsHandlers handlers;
41  handlers.reserve(5); // -ish.
42  // Add new handlers here. Do *not* add a BasicOptionsHandler: it will
43  // be done for you.
44  handlers.emplace_back(new art::BasicSourceOptionsHandler{all_desc});
45  handlers.emplace_back(new art::BasicOutputOptionsHandler{all_desc});
46  handlers.emplace_back(new art::ProcessingOptionsHandler{all_desc, ART_RETHROW_DEFAULT});
47  handlers.emplace_back(new art::DebugOptionsHandler{all_desc,
48  boost::filesystem::path(argv[0]).filename().native()});
49 
50  handlers.emplace_back(new art::FileCatalogOptionsHandler{all_desc});
51  return art::run_art(argc, argv, all_desc, lookupPolicy, std::move(handlers));
52 }
53 
54 int artapp_string_config(std::string const& config_string)
55 {
56  return art::run_art_string_config(config_string);
57 }
58 
59 // Local Variables:
60 // mode: c++
61 // End:
int artapp_string_config(std::string const &config_string)
Definition: artapp.cc:54
int run_art(int argc, char **argv, bpo::options_description &in_desc, cet::filepath_maker &lookupPolicy, OptionsHandlers &&handlers)
Definition: run_art.cc:123
int run_art_string_config(std::string const &config_string)
Definition: run_art.cc:210
#define ART_RETHROW_DEFAULT
Definition: artapp.cc:21
std::vector< std::unique_ptr< art::OptionsHandler >> OptionsHandlers
int artapp(int argc, char *argv[])
Definition: artapp.cc:23