LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
art::BasicSourceOptionsHandler Class Reference

#include "BasicSourceOptionsHandler.h"

Inheritance diagram for art::BasicSourceOptionsHandler:
art::OptionsHandler

Public Member Functions

 BasicSourceOptionsHandler (bpo::options_description &desc)
 
int checkOptions (bpo::variables_map const &vm)
 
int processOptions (bpo::variables_map const &vm, fhicl::intermediate_table &raw_config)
 

Private Member Functions

int doCheckOptions (bpo::variables_map const &vm) override
 
int doProcessOptions (bpo::variables_map const &vm, fhicl::intermediate_table &raw_config) override
 
bool processSourceListArg_ (bpo::variables_map const &vm, std::vector< std::string > &source_list)
 

Detailed Description

Definition at line 14 of file BasicSourceOptionsHandler.h.

Constructor & Destructor Documentation

art::BasicSourceOptionsHandler::BasicSourceOptionsHandler ( bpo::options_description &  desc)
explicit

Definition at line 15 of file BasicSourceOptionsHandler.cc.

References art::add_opt(), and fhicl::detail::atom::value().

17 {
18  bpo::options_description source_options{"Source options"};
19  auto options = source_options.add_options();
20  add_opt(options,
21  "source,s",
22  bpo::value<std::vector<std::string>>()->composing(),
23  "Source data file (multiple OK); precludes -S.");
24  add_opt(options,
25  "source-list,S",
26  bpo::value<std::string>(),
27  "file containing a list of source files to read, one per line; "
28  "precludes -s.");
29  add_opt(options,
30  "estart,e",
31  bpo::value<unsigned long>(),
32  "Event # of first event to process.");
33  add_opt(
34  options, "nevts,n", bpo::value<int>(), "Number of events to process.");
35  add_opt(
36  options, "nskip", bpo::value<unsigned long>(), "Number of events to skip.");
37  desc.add(source_options);
38 }
void add_opt(T &t, Args &&...args)
std::string value(boost::any const &)

Member Function Documentation

int art::OptionsHandler::checkOptions ( bpo::variables_map const &  vm)
inherited

Definition at line 51 of file OptionsHandler.cc.

52 {
53  std::string const thisClass(cet::demangle_symbol(typeid(*this).name()));
54  return exceptionCatcher([&vm, this] { return doCheckOptions(vm); },
55  thisClass + "::doCheckOptions()",
56  89);
57 }
virtual int doCheckOptions(bpo::variables_map const &vm)=0
int art::BasicSourceOptionsHandler::doCheckOptions ( bpo::variables_map const &  vm)
overrideprivatevirtual

Implements art::OptionsHandler.

Definition at line 41 of file BasicSourceOptionsHandler.cc.

42 {
43  return 0;
44 }
int art::BasicSourceOptionsHandler::doProcessOptions ( bpo::variables_map const &  vm,
fhicl::intermediate_table raw_config 
)
overrideprivatevirtual

Implements art::OptionsHandler.

Definition at line 47 of file BasicSourceOptionsHandler.cc.

References processSourceListArg_(), and fhicl::intermediate_table::put().

50 {
51  std::vector<std::string> source_list;
52  if (vm.count("source")) {
53  cet::copy_all(vm["source"].as<std::vector<std::string>>(),
54  std::back_inserter(source_list));
55  }
56  auto have_source_list_file = processSourceListArg_(vm, source_list);
57  // Post-process the config.
58  if (source_list.size() > 0 || have_source_list_file) {
59  // Empty source list file will override non-empty FHiCL spec.
60  raw_config.put("source.fileNames", source_list);
61  }
62  if (vm.count("nevts")) {
63  raw_config.put("source.maxEvents", vm["nevts"].as<int>());
64  }
65  if (vm.count("estart")) {
66  raw_config.put("source.firstEvent", vm["estart"].as<unsigned long>());
67  }
68  if (vm.count("nskip")) {
69  raw_config.put("source.skipEvents", vm["nskip"].as<unsigned long>());
70  }
71  return 0;
72 }
bool put(std::string const &name, std::string const &value, bool in_prolog=false)
bool processSourceListArg_(bpo::variables_map const &vm, std::vector< std::string > &source_list)
int art::OptionsHandler::processOptions ( bpo::variables_map const &  vm,
fhicl::intermediate_table raw_config 
)
inherited

Definition at line 60 of file OptionsHandler.cc.

Referenced by art::run_art_string_config().

62 {
63  std::string const thisClass(cet::demangle_symbol(typeid(*this).name()));
64  return exceptionCatcher(
65  [&, this] { return doProcessOptions(vm, raw_config); },
66  thisClass + "::doProcessOptions()",
67  90);
68 }
virtual int doProcessOptions(bpo::variables_map const &vm, fhicl::intermediate_table &raw_config)=0
bool art::BasicSourceOptionsHandler::processSourceListArg_ ( bpo::variables_map const &  vm,
std::vector< std::string > &  source_list 
)
private

Definition at line 75 of file BasicSourceOptionsHandler.cc.

References art::errors::Configuration, and art::detail::fillSourceList().

Referenced by doProcessOptions().

78 {
79  bool result = !!vm.count("source-list");
80  if (result) {
81  if (source_list.size()) {
83  << "--source-list (-S) and --source (-s) or non-option arguments are "
84  << "incompatible due to ordering ambiguities.\n";
85  }
86  std::ifstream flist(vm["source-list"].as<std::string>().c_str());
87  if (!flist) {
89  << "Specified source-list file \""
90  << vm["source-list"].as<std::string>() << "\" cannot be read.\n";
91  }
92  art::detail::fillSourceList(flist, source_list);
93  }
94  return result;
95 }
void fillSourceList(std::istream &ifs, std::vector< std::string > &source_list)
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66

The documentation for this class was generated from the following files: