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

#include "ConsumesInfo.h"

Public Types

using consumables_t = std::map< std::string const, std::array< std::vector< ProductInfo >, NumBranchTypes >>
 

Public Member Functions

 ~ConsumesInfo ()
 
 ConsumesInfo (ConsumesInfo const &)=delete
 
 ConsumesInfo (ConsumesInfo &&)=delete
 
ConsumesInfooperator= (ConsumesInfo const &)=delete
 
ConsumesInfooperator= (ConsumesInfo &&)=delete
 
void setRequireConsumes (bool const)
 
consumables_t::mapped_type const & consumables (std::string const &module_label) const
 
void collectConsumes (std::string const &module_label, consumables_t::mapped_type const &consumables)
 
void validateConsumedProduct (BranchType const, ModuleDescription const &, ProductInfo const &productInfo)
 
void showMissingConsumes () const
 

Static Public Member Functions

static ConsumesInfoinstance ()
 
static std::string assemble_consumes_statement (BranchType const, ProductInfo const &)
 
static std::string module_context (ModuleDescription const &)
 

Private Member Functions

 ConsumesInfo ()
 

Private Attributes

std::recursive_mutex mutex_ {}
 
std::atomic< bool > requireConsumes_
 
consumables_t consumables_
 
std::map< std::string const, std::array< std::set< ProductInfo >, NumBranchTypes > > missingConsumes_
 

Detailed Description

Definition at line 88 of file ConsumesInfo.h.

Member Typedef Documentation

using art::ConsumesInfo::consumables_t = std::map<std::string const, std::array<std::vector<ProductInfo>, NumBranchTypes>>

Definition at line 107 of file ConsumesInfo.h.

Constructor & Destructor Documentation

art::ConsumesInfo::~ConsumesInfo ( )
default
art::ConsumesInfo::ConsumesInfo ( ConsumesInfo const &  )
delete
art::ConsumesInfo::ConsumesInfo ( ConsumesInfo &&  )
delete
art::ConsumesInfo::ConsumesInfo ( )
private

Definition at line 21 of file ConsumesInfo.cc.

Referenced by consumables().

22  {
23  requireConsumes_ = false;
24  }
std::atomic< bool > requireConsumes_
Definition: ConsumesInfo.h:131

Member Function Documentation

string art::ConsumesInfo::assemble_consumes_statement ( BranchType const  bt,
ProductInfo const &  pi 
)
static

Definition at line 34 of file ConsumesInfo.cc.

References art::BranchTypeToString(), and art::InEvent.

36  {
37  string result;
38  // Create "consumes" prefix
39  switch (pi.consumableType) {
41  result += "consumes";
42  break;
44  result += "consumesView";
45  break;
47  result += "consumesMany";
48  break;
49  }
50  // .. now time for the template arguments
51  result += '<';
52  result += pi.typeID.className();
53  if (bt != InEvent) {
54  result += ", In";
55  result += BranchTypeToString(bt);
56  }
57  result += '>';
58  // Form "(...);" string with appropriate arguments.
59  result += '(';
60  // Early bail out for consumesMany.
61  if (pi.consumableType == ProductInfo::ConsumableType::Many) {
62  result += ");";
63  return result;
64  }
65  result += '"';
66  result += pi.label;
67  // If the process name is non-empty, then all InputTag fields are
68  // required (e.g.):
69  // "myLabel::myProcess"
70  // "myLabel::myInstance::myProcess"
71  if (!pi.process.name().empty()) {
72  result += ':';
73  result += pi.instance;
74  result += ':';
75  result += pi.process.name();
76  } else if (!pi.instance.empty()) {
77  result += ':';
78  result += pi.instance;
79  }
80  result += "\");";
81  return result;
82  }
std::string const & BranchTypeToString(BranchType const bt)
Definition: BranchType.cc:65
constexpr T pi()
Returns the constant pi (up to 35 decimal digits of precision)
void art::ConsumesInfo::collectConsumes ( std::string const &  module_label,
consumables_t::mapped_type const &  consumables 
)

Definition at line 102 of file ConsumesInfo.cc.

Referenced by consumables(), and art::PathManager::makeModules_().

105  {
106  std::lock_guard sentry{mutex_};
107  consumables_.emplace(module_label, consumables);
108  }
consumables_t::mapped_type const & consumables(std::string const &module_label) const
Definition: ConsumesInfo.h:110
consumables_t consumables_
Definition: ConsumesInfo.h:137
std::recursive_mutex mutex_
Definition: ConsumesInfo.h:129
consumables_t::mapped_type const& art::ConsumesInfo::consumables ( std::string const &  module_label) const
inline

Definition at line 110 of file ConsumesInfo.h.

References collectConsumes(), consumables_, ConsumesInfo(), showMissingConsumes(), and validateConsumedProduct().

Referenced by art::PathManager::fillModuleOnlyDeps_().

111  {
112  return consumables_.at(module_label);
113  }
consumables_t consumables_
Definition: ConsumesInfo.h:137
string art::ConsumesInfo::module_context ( ModuleDescription const &  md)
static

Definition at line 85 of file ConsumesInfo.cc.

References art::ModuleDescription::moduleLabel(), and art::ModuleDescription::moduleName().

86  {
87  string result{"module label: '"};
88  result += md.moduleLabel();
89  result += "' of class type '";
90  result += md.moduleName();
91  result += '\'';
92  return result;
93  }
ConsumesInfo& art::ConsumesInfo::operator= ( ConsumesInfo const &  )
delete
ConsumesInfo& art::ConsumesInfo::operator= ( ConsumesInfo &&  )
delete
void art::ConsumesInfo::setRequireConsumes ( bool const  val)

Definition at line 96 of file ConsumesInfo.cc.

Referenced by art::EventProcessor::EventProcessor().

97  {
98  requireConsumes_ = val;
99  }
std::atomic< bool > requireConsumes_
Definition: ConsumesInfo.h:131
void art::ConsumesInfo::showMissingConsumes ( ) const

Definition at line 134 of file ConsumesInfo.cc.

References util::pi().

Referenced by consumables(), and art::EventProcessor::endJob().

135  {
136  std::lock_guard sentry{mutex_};
137  for (auto const& [modLabel, arySetPI] : missingConsumes_) {
138  constexpr cet::HorizontalRule rule{60};
139  mf::LogPrint log{"MTdiagnostics"};
140  log << '\n'
141  << rule('=') << '\n'
142  << "The following consumes (or mayConsume) statements are missing "
143  "from\n"
144  << "module label: " << modLabel << '\n'
145  << rule('-') << '\n';
146  size_t i = 0;
147  for (auto const& setPI : arySetPI) {
148  for (auto const& pi : setPI) {
149  log << " "
150  << assemble_consumes_statement(static_cast<BranchType>(i), pi)
151  << '\n';
152  }
153  ++i;
154  }
155  log << rule('=');
156  }
157  }
std::map< std::string const, std::array< std::set< ProductInfo >, NumBranchTypes > > missingConsumes_
Definition: ConsumesInfo.h:142
std::recursive_mutex mutex_
Definition: ConsumesInfo.h:129
static std::string assemble_consumes_statement(BranchType const, ProductInfo const &)
Definition: ConsumesInfo.cc:34
constexpr T pi()
Returns the constant pi (up to 35 decimal digits of precision)
void art::ConsumesInfo::validateConsumedProduct ( BranchType const  bt,
ModuleDescription const &  md,
ProductInfo const &  productInfo 
)

Definition at line 111 of file ConsumesInfo.cc.

References art::ModuleDescription::moduleLabel(), and art::errors::ProductRegistrationFailure.

Referenced by consumables(), art::ProductRetriever::getByLabel_(), art::ProductRetriever::getContainerForView_(), and art::ProductRetriever::getMany_().

114  {
115 
116  std::lock_guard sentry{mutex_};
117  if (cet::binary_search_all(consumables_[md.moduleLabel()][bt],
118  productInfo)) {
119  // Found it, everything is ok.
120  return;
121  }
122  if (requireConsumes_.load()) {
124  "Consumer: an error occurred during validation of a "
125  "retrieved product\n\n")
126  << "The following consumes (or mayConsume) statement is missing from\n"
127  << module_context(md) << ":\n\n"
128  << " " << assemble_consumes_statement(bt, productInfo) << "\n\n";
129  }
130  missingConsumes_[md.moduleLabel()][bt].insert(productInfo);
131  }
std::map< std::string const, std::array< std::set< ProductInfo >, NumBranchTypes > > missingConsumes_
Definition: ConsumesInfo.h:142
consumables_t consumables_
Definition: ConsumesInfo.h:137
std::recursive_mutex mutex_
Definition: ConsumesInfo.h:129
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
static std::string assemble_consumes_statement(BranchType const, ProductInfo const &)
Definition: ConsumesInfo.cc:34
static std::string module_context(ModuleDescription const &)
Definition: ConsumesInfo.cc:85
std::atomic< bool > requireConsumes_
Definition: ConsumesInfo.h:131

Member Data Documentation

consumables_t art::ConsumesInfo::consumables_
private

Definition at line 137 of file ConsumesInfo.h.

Referenced by consumables().

std::map<std::string const, std::array<std::set<ProductInfo>, NumBranchTypes> > art::ConsumesInfo::missingConsumes_
private

Definition at line 142 of file ConsumesInfo.h.

std::recursive_mutex art::ConsumesInfo::mutex_ {}
mutableprivate

Definition at line 129 of file ConsumesInfo.h.

std::atomic<bool> art::ConsumesInfo::requireConsumes_
private

Definition at line 131 of file ConsumesInfo.h.


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