8 #include "cetlib/HorizontalRule.h" 9 #include "cetlib/container_algorithms.h" 19 ConsumesInfo::~ConsumesInfo() =
default;
21 ConsumesInfo::ConsumesInfo()
23 requireConsumes_ =
false;
34 ConsumesInfo::assemble_consumes_statement(
BranchType const bt,
39 switch (pi.consumableType) {
40 case ProductInfo::ConsumableType::Product:
43 case ProductInfo::ConsumableType::ViewElement:
44 result +=
"consumesView";
46 case ProductInfo::ConsumableType::Many:
47 result +=
"consumesMany";
52 result += pi.typeID.className();
61 if (pi.consumableType == ProductInfo::ConsumableType::Many) {
71 if (!pi.process.name().empty()) {
73 result += pi.instance;
75 result += pi.process.name();
76 }
else if (!pi.instance.empty()) {
78 result += pi.instance;
87 string result{
"module label: '"};
89 result +=
"' of class type '";
96 ConsumesInfo::setRequireConsumes(
bool const val)
98 requireConsumes_ = val;
102 ConsumesInfo::collectConsumes(
103 string const& module_label,
106 std::lock_guard sentry{mutex_};
107 consumables_.emplace(module_label, consumables);
116 std::lock_guard sentry{mutex_};
117 if (cet::binary_search_all(consumables_[md.
moduleLabel()][bt],
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";
130 missingConsumes_[md.
moduleLabel()][bt].insert(productInfo);
134 ConsumesInfo::showMissingConsumes()
const 136 std::lock_guard sentry{mutex_};
137 for (
auto const& [modLabel, arySetPI] : missingConsumes_) {
138 constexpr cet::HorizontalRule rule{60};
142 <<
"The following consumes (or mayConsume) statements are missing " 144 <<
"module label: " << modLabel <<
'\n' 145 << rule(
'-') <<
'\n';
147 for (
auto const& setPI : arySetPI) {
148 for (
auto const&
pi : setPI) {
150 << assemble_consumes_statement(static_cast<BranchType>(i),
pi)
std::string const & moduleLabel() const
const std::string instance
std::string const & moduleName() const
auto array(Array const &a)
Returns a manipulator which will print the specified array.
std::string const & BranchTypeToString(BranchType const bt)
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
constexpr T pi()
Returns the constant pi (up to 35 decimal digits of precision)