File indexing completed on 2025-04-22 06:27:18
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 explicit SignallingProductRegistryFiller(ProductRegistry const& preg)
0038 : productAddedSignal_(), registry_(preg), typeAddedStack_() {};
0039
0040 SignallingProductRegistryFiller(SignallingProductRegistryFiller const&) = delete;
0041 SignallingProductRegistryFiller(SignallingProductRegistryFiller&&) = delete;
0042 SignallingProductRegistryFiller& operator=(SignallingProductRegistryFiller const&) = delete;
0043 SignallingProductRegistryFiller& operator=(SignallingProductRegistryFiller&&) = delete;
0044
0045 signalslot::Signal<void(ProductDescription const&)> productAddedSignal_;
0046
0047 void addProduct(ProductDescription const& productdesc, bool iFromListener = false) {
0048 registry_.addProduct_(productdesc);
0049 addCalled(productdesc, iFromListener);
0050 }
0051
0052 void addLabelAlias(ProductDescription const& productdesc,
0053 std::string const& labelAlias,
0054 std::string const& instanceAlias) {
0055 addCalled(registry_.addLabelAlias_(productdesc, labelAlias, instanceAlias), false);
0056 }
0057 void addFromInput(edm::ProductRegistry const& iReg) {
0058 registry_.addFromInput_(iReg, [this](auto const& prod) { addCalled(prod, false); });
0059 }
0060
0061
0062
0063
0064 template <typename T>
0065 void callForEachBranch(T const& iFunc) {
0066
0067
0068 for (auto const& entry : registry_.productList()) {
0069 if (entry.second.present()) {
0070 iFunc(entry.second);
0071 }
0072 }
0073 }
0074 void setUnscheduledProducts(std::set<std::string> const& unscheduledLabels) {
0075 registry_.setUnscheduledProducts(unscheduledLabels);
0076 }
0077 ProductRegistry::ProductList& productListUpdator() { return registry_.productListUpdator(); }
0078
0079 template <class T>
0080 void watchProductAdditions(const T& iFunc) {
0081 serviceregistry::connect_but_block_self(productAddedSignal_, iFunc);
0082 }
0083 template <class T, class TMethod>
0084 void watchProductAdditions(T const& iObj, TMethod iMethod) {
0085 using std::placeholders::_1;
0086 serviceregistry::connect_but_block_self(productAddedSignal_, std::bind(iMethod, iObj, _1));
0087 }
0088
0089 ProductRegistry moveTo() { return std::move(registry_); }
0090 ProductRegistry const& registry() const { return registry_; }
0091
0092 void setFrozen(bool initializeLookupInfo = true) { registry_.setFrozen(initializeLookupInfo); }
0093
0094 void setFrozen(std::set<TypeID> const& productTypesConsumed,
0095 std::set<TypeID> const& elementTypesConsumed,
0096 std::string const& processName) {
0097 registry_.setFrozen(productTypesConsumed, elementTypesConsumed, processName);
0098 }
0099
0100 private:
0101 void addCalled(ProductDescription const&, bool);
0102
0103 ProductRegistry registry_;
0104 std::map<std::string, unsigned int> typeAddedStack_;
0105 };
0106 }
0107
0108 #endif