Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
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< boolrequireConsumes_
 
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

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.

21 { requireConsumes_ = false; }
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 31 of file ConsumesInfo.cc.

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

Definition at line 99 of file ConsumesInfo.cc.

102  {
103  std::lock_guard sentry{mutex_};
104  consumables_.emplace(module_label, consumables);
105  }
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.

111  {
112  return consumables_.at(module_label);
113  }
consumables_t consumables_
Definition: ConsumesInfo.h:137
ConsumesInfo * art::ConsumesInfo::instance ( )
static

Definition at line 24 of file ConsumesInfo.cc.

25  {
26  static ConsumesInfo me;
27  return &me;
28  }
string art::ConsumesInfo::module_context ( ModuleDescription const &  md)
static

Definition at line 82 of file ConsumesInfo.cc.

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

Definition at line 93 of file ConsumesInfo.cc.

94  {
96  }
std::atomic< bool > requireConsumes_
Definition: ConsumesInfo.h:131
void art::ConsumesInfo::showMissingConsumes ( ) const

Definition at line 131 of file ConsumesInfo.cc.

132  {
133  std::lock_guard sentry{mutex_};
134  for (auto const& modLabelAndarySetPI : missingConsumes_) {
135  auto const& modLabel = modLabelAndarySetPI.first;
136  auto const& arySetPI = modLabelAndarySetPI.second;
137  constexpr cet::HorizontalRule rule{60};
138  mf::LogPrint log{"MTdiagnostics"};
139  log << '\n'
140  << rule('=') << '\n'
141  << "The following consumes (or mayConsume) statements are missing "
142  "from\n"
143  << "module label: " << modLabel << '\n'
144  << rule('-') << '\n';
145  size_t i = 0;
146  for (auto const& setPI : arySetPI) {
147  for (auto const& pi : setPI) {
148  log << " "
149  << assemble_consumes_statement(static_cast<BranchType>(i), pi)
150  << '\n';
151  }
152  ++i;
153  }
154  log << rule('=');
155  }
156  }
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:31
float pi
Definition: units.py:11
void art::ConsumesInfo::validateConsumedProduct ( BranchType const  bt,
ModuleDescription const &  md,
ProductInfo const &  productInfo 
)

Definition at line 108 of file ConsumesInfo.cc.

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

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: