File indexing completed on 2025-03-13 02:31:50
0001 #ifndef FWCore_Framework_SignallingProductRegistryFiller_h
0002 #define FWCore_Framework_SignallingProductRegistryFiller_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022 #include <map>
0023 #include <string>
0024
0025 #include "FWCore/Utilities/interface/Signal.h"
0026
0027
0028 #include "DataFormats/Provenance/interface/ProductRegistry.h"
0029 #include "FWCore/ServiceRegistry/interface/connect_but_block_self.h"
0030
0031
0032 namespace edm {
0033 class SignallingProductRegistryFiller {
0034 public:
0035 SignallingProductRegistryFiller() : productAddedSignal_(), registry_(), typeAddedStack_() {}
0036
0037 struct FromEarlierProcess {};
0038 explicit SignallingProductRegistryFiller(ProductRegistry::ProductList const& preg, FromEarlierProcess)
0039 : productAddedSignal_(), registry_(preg, false), typeAddedStack_() {}
0040
0041 explicit SignallingProductRegistryFiller(ProductRegistry const& preg)
0042 : productAddedSignal_(), registry_(preg), typeAddedStack_() {};
0043
0044 SignallingProductRegistryFiller(SignallingProductRegistryFiller const&) = delete;
0045 SignallingProductRegistryFiller(SignallingProductRegistryFiller&&) = delete;
0046 SignallingProductRegistryFiller& operator=(SignallingProductRegistryFiller const&) = delete;
0047 SignallingProductRegistryFiller& operator=(SignallingProductRegistryFiller&&) = delete;
0048
0049 signalslot::Signal<void(ProductDescription const&)> productAddedSignal_;
0050
0051 void addProduct(ProductDescription const& productdesc, bool iFromListener = false) {
0052 registry_.addProduct_(productdesc);
0053 addCalled(productdesc, iFromListener);
0054 }
0055
0056 void addLabelAlias(ProductDescription const& productdesc,
0057 std::string const& labelAlias,
0058 std::string const& instanceAlias) {
0059 addCalled(registry_.addLabelAlias_(productdesc, labelAlias, instanceAlias), false);
0060 }
0061 void addFromInput(edm::ProductRegistry const& iReg) {
0062 registry_.addFromInput_(iReg, [this](auto const& prod) { addCalled(prod, false); });
0063 }
0064
0065
0066
0067
0068 template <typename T>
0069 void callForEachBranch(T const& iFunc) {
0070
0071
0072 for (auto const& entry : registry_.productList()) {
0073 if (entry.second.present()) {
0074 iFunc(entry.second);
0075 }
0076 }
0077 }
0078 void setUnscheduledProducts(std::set<std::string> const& unscheduledLabels) {
0079 registry_.setUnscheduledProducts(unscheduledLabels);
0080 }
0081 ProductRegistry::ProductList& productListUpdator() { return registry_.productListUpdator(); }
0082
0083 template <class T>
0084 void watchProductAdditions(const T& iFunc) {
0085 serviceregistry::connect_but_block_self(productAddedSignal_, iFunc);
0086 }
0087 template <class T, class TMethod>
0088 void watchProductAdditions(T const& iObj, TMethod iMethod) {
0089 using std::placeholders::_1;
0090 serviceregistry::connect_but_block_self(productAddedSignal_, std::bind(iMethod, iObj, _1));
0091 }
0092
0093 ProductRegistry moveTo() { return std::move(registry_); }
0094 ProductRegistry const& registry() const { return registry_; }
0095
0096 void setFrozen(bool initializeLookupInfo = true) { registry_.setFrozen(initializeLookupInfo); }
0097
0098 void setFrozen(std::set<TypeID> const& productTypesConsumed,
0099 std::set<TypeID> const& elementTypesConsumed,
0100 std::string const& processName) {
0101 registry_.setFrozen(productTypesConsumed, elementTypesConsumed, processName);
0102 }
0103
0104 private:
0105 void addCalled(ProductDescription const&, bool);
0106
0107 ProductRegistry registry_;
0108 std::map<std::string, unsigned int> typeAddedStack_;
0109 };
0110 }
0111
0112 #endif