LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
art::MasterProductRegistry Class Reference

#include "MasterProductRegistry.h"

Public Member Functions

 MasterProductRegistry ()=default
 
 MasterProductRegistry (MasterProductRegistry const &)=delete
 
MasterProductRegistryoperator= (MasterProductRegistry const &)=delete
 
void registerProductListUpdatedCallback (ProductListUpdatedCallback cb)
 
void finalizeForProcessing ()
 
void addProductsFromModule (ProductDescriptions &&)
 
void updateFromModule (std::unique_ptr< ProductList > &&)
 
void updateFromInputFile (ProductList const &)
 
auto const & productList () const
 
auto size () const
 
void print (std::ostream &) const
 
bool productProduced (BranchType branchType) const
 

Private Member Functions

void addProduct_ (BranchDescription &&)
 
void updateProductLists_ (ProductList const &pl)
 

Private Attributes

bool allowExplicitRegistration_ {true}
 
ProductList productList_ {}
 
std::array< bool, NumBranchTypesproductProduced_
 
std::vector< ProductListUpdatedCallbackproductListUpdatedCallbacks_ {}
 

Detailed Description

Definition at line 47 of file MasterProductRegistry.h.

Constructor & Destructor Documentation

art::MasterProductRegistry::MasterProductRegistry ( )
explicitdefault
art::MasterProductRegistry::MasterProductRegistry ( MasterProductRegistry const &  )
delete

Member Function Documentation

void art::MasterProductRegistry::addProduct_ ( BranchDescription &&  bdp)
private

Definition at line 73 of file MasterProductRegistry.cc.

References art::errors::Configuration, and art::errors::ProductRegistrationFailure.

Referenced by productProduced().

74 {
75  CET_ASSERT_ONLY_ONE_THREAD();
76 
77  // The below check exists primarily to ensure that the framework
78  // does not accidentally call addProduct at a time when it should
79  // not.
82  << "An attempt to register the product\n"
83  << bdp << "was made after the product registry was frozen.\n"
84  << "Product registration can be done only in module constructors.\n";
85  }
86 
87  assert(bdp.produced());
88 
89  auto it = productList_.emplace(BranchKey{bdp}, BranchDescription{});
90  if (!it.second) {
92  << "The process name " << bdp.processName()
93  << " was previously used on these products.\n"
94  << "Please modify the configuration file to use a "
95  << "distinct process name.\n";
96  }
97  auto& productListEntry = *it.first;
98  auto& pd = productListEntry.second;
99  pd.swap(bdp);
100  productProduced_[pd.branchType()] = true;
101 }
std::array< bool, NumBranchTypes > productProduced_
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
std::string const & processName() const
void art::MasterProductRegistry::addProductsFromModule ( ProductDescriptions &&  descriptions)

Definition at line 25 of file MasterProductRegistry.cc.

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

27 {
28  CET_ASSERT_ONLY_ONE_THREAD();
29  for (auto&& desc : descriptions) {
30  addProduct_(std::move(desc));
31  }
32 }
void addProduct_(BranchDescription &&)
void art::MasterProductRegistry::finalizeForProcessing ( )

Definition at line 14 of file MasterProductRegistry.cc.

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

15 {
16  CET_ASSERT_ONLY_ONE_THREAD();
17  // Product registration can still happen implicitly whenever an
18  // input file is opened--via calls to updateFromInputFile.
20  cet::for_all(productListUpdatedCallbacks_,
21  [this](auto const& callback) { callback(productList_); });
22 }
std::vector< ProductListUpdatedCallback > productListUpdatedCallbacks_
MasterProductRegistry& art::MasterProductRegistry::operator= ( MasterProductRegistry const &  )
delete
void art::MasterProductRegistry::print ( std::ostream &  os) const

Definition at line 61 of file MasterProductRegistry.cc.

Referenced by art::operator<<(), and size().

62 {
63  // TODO: Shouldn't we print the BranchKey too?
64  for (auto const& val : productList_) {
65  os << val.second << "\n-----\n";
66  }
67 }
auto const& art::MasterProductRegistry::productList ( ) const
inline

Definition at line 62 of file MasterProductRegistry.h.

References productList_.

63  {
64  return productList_;
65  }
bool art::MasterProductRegistry::productProduced ( BranchType  branchType) const
inline

Definition at line 75 of file MasterProductRegistry.h.

References addProduct_(), productProduced_, and updateProductLists_().

76  {
77  return productProduced_[branchType];
78  }
std::array< bool, NumBranchTypes > productProduced_
void art::MasterProductRegistry::registerProductListUpdatedCallback ( ProductListUpdatedCallback  cb)

Definition at line 53 of file MasterProductRegistry.cc.

55 {
56  CET_ASSERT_ONLY_ONE_THREAD();
57  productListUpdatedCallbacks_.push_back(cb);
58 }
std::vector< ProductListUpdatedCallback > productListUpdatedCallbacks_
auto art::MasterProductRegistry::size ( void  ) const
inline

Definition at line 67 of file MasterProductRegistry.h.

References print(), and productList_.

68  {
69  return productList_.size();
70  }
void art::MasterProductRegistry::updateFromInputFile ( ProductList const &  pl)

Definition at line 44 of file MasterProductRegistry.cc.

45 {
46  CET_ASSERT_ONLY_ONE_THREAD();
48  cet::for_all(productListUpdatedCallbacks_,
49  [this](auto const& callback) { callback(productList_); });
50 }
void updateProductLists_(ProductList const &pl)
std::vector< ProductListUpdatedCallback > productListUpdatedCallbacks_
void art::MasterProductRegistry::updateFromModule ( std::unique_ptr< ProductList > &&  pl)

Definition at line 35 of file MasterProductRegistry.cc.

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

36 {
37  CET_ASSERT_ONLY_ONE_THREAD();
38  if (!pl)
39  return;
41 }
void updateProductLists_(ProductList const &pl)
void art::MasterProductRegistry::updateProductLists_ ( ProductList const &  pl)
private

Definition at line 104 of file MasterProductRegistry.cc.

References art::combinable().

Referenced by productProduced().

105 {
106  for (auto const& val : pl) {
107  auto const& pd = val.second;
108  assert(!pd.produced());
109  auto bk = BranchKey{pd};
110  auto it = productList_.find(bk);
111  if (it == productList_.end()) {
112  // New product
113  productList_.emplace(bk, pd);
114  continue;
115  }
116  auto& found_pd = it->second;
117  assert(combinable(found_pd, pd));
118  found_pd.merge(pd);
119  }
120 }
bool combinable(BranchDescription const &a, BranchDescription const &b)

Member Data Documentation

bool art::MasterProductRegistry::allowExplicitRegistration_ {true}
private

Definition at line 84 of file MasterProductRegistry.h.

ProductList art::MasterProductRegistry::productList_ {}
private

Definition at line 87 of file MasterProductRegistry.h.

Referenced by productList(), and size().

std::vector<ProductListUpdatedCallback> art::MasterProductRegistry::productListUpdatedCallbacks_ {}
private

Definition at line 90 of file MasterProductRegistry.h.

std::array<bool, NumBranchTypes> art::MasterProductRegistry::productProduced_
private
Initial value:
{
{false}}

Definition at line 88 of file MasterProductRegistry.h.

Referenced by productProduced().


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