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

#include "ProducesCollector.h"

Public Member Functions

template<typename P , BranchType B = InEvent>
void produces (std::string const &instanceName={}, Persistable const persistable=Persistable::Yes)
 
template<typename P , BranchType B>
TypeLabel const & reconstitutes (std::string const &modLabel, std::string const &instanceName={})
 
TypeLabelLookup_t const & expectedProducts (BranchType) const
 
void fillDescriptions (ModuleDescription const &md)
 

Private Member Functions

TypeLabel const & insertOrThrow (BranchType const bt, TypeLabel const &tl)
 

Private Attributes

std::array< TypeLabelLookup_t, NumBranchTypestypeLabelList_ {{}}
 

Detailed Description

Definition at line 55 of file ProducesCollector.h.

Member Function Documentation

TypeLabelLookup_t const & art::ProducesCollector::expectedProducts ( BranchType  bt) const
inline

Definition at line 81 of file ProducesCollector.h.

Referenced by art::ProductRegistryHelper::registerProducts().

82  {
83  return typeLabelList_[bt];
84  }
std::array< TypeLabelLookup_t, NumBranchTypes > typeLabelList_
void art::ProducesCollector::fillDescriptions ( ModuleDescription const &  md)

Definition at line 88 of file ProducesCollector.cc.

References art::for_each_branch_type(), art::ModuleDescription::moduleLabel(), art::ModuleDescription::parameterSetID(), and art::ModuleDescription::processConfiguration().

Referenced by art::ProductRegistryHelper::fillDescriptions().

89  {
90  auto fillDescriptionsPerBT = [this, &md](BranchType const bt) {
91  auto& expectedProducts = typeLabelList_[bt];
92  // Go through products that will be produced in the current process.
93  check_for_duplicate_friendly_names(expectedProducts);
94 
95  for (auto& [typeLabel, pd] : expectedProducts) {
96  pd = BranchDescription{bt,
97  typeLabel,
98  md.moduleLabel(),
99  md.parameterSetID(),
100  md.processConfiguration()};
101  }
102  };
103  for_each_branch_type(fillDescriptionsPerBT);
104  }
std::array< TypeLabelLookup_t, NumBranchTypes > typeLabelList_
BranchType
Definition: BranchType.h:20
void for_each_branch_type(F f)
Definition: BranchType.h:38
TypeLabelLookup_t const & expectedProducts(BranchType) const
TypeLabel const & art::ProducesCollector::insertOrThrow ( BranchType const  bt,
TypeLabel const &  tl 
)
private

Definition at line 69 of file ProducesCollector.cc.

References art::TypeLabel::className(), art::TypeLabel::productInstanceName(), and art::errors::ProductRegistrationFailure.

70  {
71  auto result = typeLabelList_[bt].emplace(tl, BranchDescription{});
72  if (!result.second) {
73  ostringstream oss;
74  oss << "An attempt was made to declare the following product in the same "
75  "module:\n"
76  << "Branch type: " << bt << '\n'
77  << "Class name: " << tl.className() << '\n'
78  << "Product instance name: " << tl.productInstanceName() << '\n';
79  throw Exception{
81  "An error occurred during a call to 'produces' or 'reconstitutes'."}
82  << oss.str();
83  }
84  return result.first->first;
85  }
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
std::array< TypeLabelLookup_t, NumBranchTypes > typeLabelList_
template<typename P , art::BranchType B>
void art::ProducesCollector::produces ( std::string const &  instanceName = {},
Persistable const  persistable = Persistable::Yes 
)
inline

Definition at line 88 of file ProducesCollector.h.

References art::No, art::detail::verifyFriendlyClassName(), and art::detail::verifyInstanceName().

Referenced by recob::HitAndAssociationsWriterBase::declare_products(), larg4::LArG4DetectorService::doCallArtProduces(), nnet::EmTrack< N >::EmTrack(), ShowerRecoTools::IShowerTool::InitialiseProduct(), artg4tk::DummyService::notifyArtOfProduction(), lar_cluster3d::SpacePointHit3DBuilder::produces(), lar_cluster3d::StandardHit3DBuilder::produces(), lar_cluster3d::SnippetHit3DBuilder::produces(), art::MixHelper::produces(), recob::ChargedSpacePointCollectionCreator::produces(), and anab::FVectorWriter< N >::produces_using().

90  {
91  verifyInstanceName(instanceName);
92  TypeID const productType{typeid(P)};
93  verifyFriendlyClassName(productType.friendlyClassName());
94  bool const isTransient = (persistable == Persistable::No);
95  TypeLabel const typeLabel{
96  productType, instanceName, SupportsView<P>::value, isTransient};
97  insertOrThrow(B, typeLabel);
98  }
TypeLabel const & insertOrThrow(BranchType const bt, TypeLabel const &tl)
void verifyFriendlyClassName(std::string const &fcn)
Definition: verify_names.cc:16
double value
Definition: spectrum.C:18
void verifyInstanceName(std::string const &in)
Definition: verify_names.cc:5
template<typename P , BranchType B>
TypeLabel const & art::ProducesCollector::reconstitutes ( std::string const &  modLabel,
std::string const &  instanceName = {} 
)

Definition at line 102 of file ProducesCollector.h.

References art::detail::verifyFriendlyClassName(), and art::detail::verifyInstanceName().

104  {
105  verifyModuleLabel(emulatedModule);
106  verifyInstanceName(instanceName);
107  TypeID const productType{typeid(P)};
108  verifyFriendlyClassName(productType.friendlyClassName());
109  TypeLabel const typeLabel{
110  productType, instanceName, SupportsView<P>::value, emulatedModule};
111  return insertOrThrow(B, typeLabel);
112  }
TypeLabel const & insertOrThrow(BranchType const bt, TypeLabel const &tl)
void verifyFriendlyClassName(std::string const &fcn)
Definition: verify_names.cc:16
double value
Definition: spectrum.C:18
void verifyInstanceName(std::string const &in)
Definition: verify_names.cc:5

Member Data Documentation

std::array<TypeLabelLookup_t, NumBranchTypes> art::ProducesCollector::typeLabelList_ {{}}
private

Definition at line 77 of file ProducesCollector.h.


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