LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
art::BasicOutputOptionsHandler Class Reference

#include "BasicOutputOptionsHandler.h"

Inheritance diagram for art::BasicOutputOptionsHandler:
art::OptionsHandler

Public Member Functions

 BasicOutputOptionsHandler (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
 

Private Attributes

std::string tmpDir_ {}
 

Detailed Description

Definition at line 12 of file BasicOutputOptionsHandler.h.

Constructor & Destructor Documentation

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

Definition at line 28 of file BasicOutputOptionsHandler.cc.

30 {
31  bpo::options_description output_options{"Output options"};
32  // clang-format off
33  output_options.add_options()
34  ("TFileName,T", bpo::value<std::string>(), "File name for TFileService.")
35  ("tmpdir",
36  bpo::value<std::string>(&tmpDir_),
37  "Temporary directory for in-progress output files (defaults to directory "
38  "of specified output file names).")
39  ("tmpDir", bpo::value<std::string>(&tmpDir_), "Synonym for --tmpdir.")
40  ("output,o",
41  bpo::value<stringvec>()->composing(),
42  "Event output stream file (optionally specify stream with "
43  "stream-label:fileName in which case multiples are OK).")
44  ("no-output", "Disable all output streams.");
45  // clang-format on
46  desc.add(output_options);
47 }

Member Function Documentation

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

Definition at line 51 of file OptionsHandler.cc.

References art::OptionsHandler::doCheckOptions().

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::BasicOutputOptionsHandler::doProcessOptions ( bpo::variables_map const &  vm,
fhicl::intermediate_table raw_config 
)
overrideprivatevirtual

Implements art::OptionsHandler.

Definition at line 226 of file BasicOutputOptionsHandler.cc.

References util::empty(), art::detail::exists_outside_prolog(), art::detail::fhicl_key(), fhicl::intermediate_table::get(), art::detail::module_type(), fhicl::intermediate_table::put(), and art::detail::supports_key().

229 {
230  // TFileService output.
231  if (vm.count("TFileName") == 1) {
232  std::string tFileName(vm["TFileName"].as<std::string>());
233  std::string const& key{"services.TFileService"};
234  if (tFileName.empty() && detail::exists_outside_prolog(raw_config, key) &&
235  raw_config.get<table_t const&>(key).empty()) {
236  tFileName = "hist.root";
237  }
238  if (!tFileName.empty()) {
239  raw_config.put(key + ".fileName", tFileName);
240  }
241  }
242  // Output stream options.
243  processFileOutputOptions(vm, raw_config);
244  // tmpDir option for TFileService and output streams.
245  if (!tmpDir_.empty()) {
246  std::string const& tfile_key = fhicl_key("services", "TFileService");
247  if (detail::exists_outside_prolog(raw_config, tfile_key)) {
248  auto has_tmpDir [[maybe_unused]] =
249  detail::supports_key(Suffixes::service(), "TFileService", "tmpDir");
250  assert(has_tmpDir); // Should never happen.
251  raw_config.put(fhicl_key(tfile_key, "tmpDir"), tmpDir_);
252  }
253 
254  // Inject tmpDir for output modules that support the 'tmpDir' parameter.
255  std::string const outputs_stem{"outputs"};
256  if (detail::exists_outside_prolog(raw_config, outputs_stem)) {
257  auto const& table = raw_config.get<table_t const&>(outputs_stem);
258  for (auto const& output : table) {
259  auto const& module_label = fhicl_key(outputs_stem, output.first);
260  auto const& module_type = fhicl_key(module_label, "module_type");
261  if (!detail::exists_outside_prolog(raw_config, module_type))
262  continue;
263 
264  auto const& spec = raw_config.get<std::string>(module_type);
265  if (!detail::supports_key(Suffixes::module(), spec, "tmpDir"))
266  continue;
267 
268  raw_config.put(fhicl_key(module_label, "tmpDir"), tmpDir_);
269  }
270  }
271  }
272 
273  return 0;
274 }
bool exists_outside_prolog(fhicl::intermediate_table const &config, std::string const &key)
bool supports_key(std::string const &suffix, std::string const &spec, std::string const &key)
ModuleType module_type(std::string const &full_key)
std::enable_if_t< std::is_convertible_v< T, std::string >, std::string > fhicl_key(T const &name)
Definition: fhicl_key.h:12
bool put(std::string const &name, std::string const &value, bool in_prolog=false)
T get(std::string const &name)
static std::string const & service()
static std::string const & module()
decltype(auto) constexpr empty(T &&obj)
ADL-aware version of std::empty.
Definition: StdUtils.h:109
int art::OptionsHandler::processOptions ( bpo::variables_map const &  vm,
fhicl::intermediate_table raw_config 
)
inherited

Definition at line 60 of file OptionsHandler.cc.

References art::OptionsHandler::doProcessOptions().

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

Member Data Documentation

std::string art::BasicOutputOptionsHandler::tmpDir_ {}
private

Definition at line 23 of file BasicOutputOptionsHandler.h.


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