Skip to content

Commit 692153c

Browse files
committed
Must explicitly ask for the ProductRegistry in SignallingProductRegistry
1 parent e3e58f9 commit 692153c

17 files changed

+174
-139
lines changed

DataFormats/Provenance/interface/ProductRegistry.h

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ namespace edm {
4040
ProductRegistry() = default;
4141
ProductRegistry(const ProductRegistry&) = default;
4242
ProductRegistry(ProductRegistry&&) = default;
43+
ProductRegistry& operator=(ProductRegistry&&) = default;
4344
// A constructor from the persistent data members from another product registry.
4445
// saves time by not copying the transient components.
4546
// The constructed registry will be frozen by default.
@@ -64,8 +65,6 @@ namespace edm {
6465
ProductDescription::MatchMode branchesMustMatch = ProductDescription::Permissive);
6566

6667
void updateFromInput(ProductList const& other);
67-
// triggers callbacks for modules watching registration
68-
void addFromInput(edm::ProductRegistry const&);
6968

7069
void updateFromInput(std::vector<ProductDescription> const& other);
7170

@@ -90,21 +89,6 @@ namespace edm {
9089
// colon-initialization list.
9190
std::vector<ProductDescription const*> allProductDescriptions() const;
9291

93-
//NOTE: this is not const since we only want items that have non-const access to this class to be
94-
// able to call this internal iteration
95-
// Called only for branches that are present (part of avoiding creating type information for dropped branches)
96-
template <typename T>
97-
void callForEachBranch(T const& iFunc) {
98-
//NOTE: If implementation changes from a map, need to check that iterators are still valid
99-
// after an insert with the new container, else need to copy the container and iterate over the copy
100-
for (ProductRegistry::ProductList::const_iterator itEntry = productList_.begin(), itEntryEnd = productList_.end();
101-
itEntry != itEntryEnd;
102-
++itEntry) {
103-
if (itEntry->second.present()) {
104-
iFunc(itEntry->second);
105-
}
106-
}
107-
}
10892
ProductList::size_type size() const { return productList_.size(); }
10993

11094
void print(std::ostream& os) const;
@@ -163,6 +147,8 @@ namespace edm {
163147
void addLabelAlias_(ProductDescription const& productdesc,
164148
std::string const& labelAlias,
165149
std::string const& instanceAlias);
150+
// triggers callbacks for modules watching registration
151+
void addFromInput_(edm::ProductRegistry const&);
166152

167153
private:
168154
void setProductProduced(BranchType branchType) {

DataFormats/Provenance/src/ProductRegistry.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ namespace edm {
212212
}
213213
}
214214

215-
void ProductRegistry::addFromInput(edm::ProductRegistry const& other) {
215+
void ProductRegistry::addFromInput_(edm::ProductRegistry const& other) {
216216
throwIfFrozen();
217217
for (auto const& prod : other.productList_) {
218218
ProductList::iterator iter = productList_.find(prod.first);

FWCore/Framework/interface/SignallingProductRegistry.h

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
// forward declarations
3232
namespace edm {
33-
class SignallingProductRegistry : public ProductRegistry {
33+
class SignallingProductRegistry : private ProductRegistry {
3434
public:
3535
SignallingProductRegistry() : ProductRegistry(), productAddedSignal_(), typeAddedStack_() {}
3636

@@ -40,8 +40,9 @@ namespace edm {
4040

4141
struct Copy {};
4242

43-
SignallingProductRegistry(ProductRegistry const& preg, Copy): ProductRegistry(preg), productAddedSignal_(), typeAddedStack_() {};
44-
43+
SignallingProductRegistry(ProductRegistry const& preg, Copy)
44+
: ProductRegistry(preg), productAddedSignal_(), typeAddedStack_() {};
45+
4546
void addProduct(ProductDescription const& productdesc, bool iFromListener = false) {
4647
addProduct_(productdesc, iFromListener);
4748
}
@@ -51,6 +52,27 @@ namespace edm {
5152
std::string const& instanceAlias) {
5253
addLabelAlias_(productdesc, labelAlias, instanceAlias);
5354
}
55+
void addFromInput(edm::ProductRegistry const& iReg) { addFromInput_(iReg); }
56+
57+
//NOTE: this is not const since we only want items that have non-const access to this class to be
58+
// able to call this internal iteration
59+
// Called only for branches that are present (part of avoiding creating type information for dropped branches)
60+
template <typename T>
61+
void callForEachBranch(T const& iFunc) {
62+
//NOTE: If implementation changes from a map, need to check that iterators are still valid
63+
// after an insert with the new container, else need to copy the container and iterate over the copy
64+
for (ProductRegistry::ProductList::const_iterator itEntry = productList().begin(), itEntryEnd = productList().end();
65+
itEntry != itEntryEnd;
66+
++itEntry) {
67+
if (itEntry->second.present()) {
68+
iFunc(itEntry->second);
69+
}
70+
}
71+
}
72+
void setUnscheduledProducts(std::set<std::string> const& unscheduledLabels) {
73+
ProductRegistry::setUnscheduledProducts(unscheduledLabels);
74+
}
75+
ProductList& productListUpdator() { return ProductRegistry::productListUpdator(); }
5476

5577
SignallingProductRegistry(SignallingProductRegistry const&) = delete; // Disallow copying and moving
5678
SignallingProductRegistry& operator=(SignallingProductRegistry const&) = delete; // Disallow copying and moving
@@ -65,7 +87,16 @@ namespace edm {
6587
serviceregistry::connect_but_block_self(productAddedSignal_, std::bind(iMethod, iObj, _1));
6688
}
6789

68-
ProductRegistry const& registry() { return *this; }
90+
ProductRegistry moveTo() { return std::move(*this); }
91+
ProductRegistry const& registry() const { return *this; }
92+
93+
void setFrozen(bool initializeLookupInfo = true) { ProductRegistry::setFrozen(initializeLookupInfo); }
94+
95+
void setFrozen(std::set<TypeID> const& productTypesConsumed,
96+
std::set<TypeID> const& elementTypesConsumed,
97+
std::string const& processName) {
98+
ProductRegistry::setFrozen(productTypesConsumed, elementTypesConsumed, processName);
99+
}
69100

70101
private:
71102
void addCalled(ProductDescription const&, bool) override;

FWCore/Framework/src/EventProcessor.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ namespace edm {
528528
// set the data members
529529
act_table_ = std::move(items.act_table_);
530530
actReg_ = items.actReg_;
531-
preg_ = items.preg();
531+
preg_ = std::make_shared<ProductRegistry>(items.preg()->moveTo());
532532
mergeableRunProductProcesses_.setProcessesWithMergeableRunProducts(*preg_);
533533
branchIDListHelper_ = items.branchIDListHelper();
534534
thinnedAssociationsHelper_ = items.thinnedAssociationsHelper();

FWCore/Framework/src/Schedule.cc

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,9 @@ namespace edm {
153153

154154
typedef std::vector<std::string> vstring;
155155

156-
void processSwitchProducers(ParameterSet const& proc_pset, std::string const& processName, ProductRegistry& preg) {
156+
void processSwitchProducers(ParameterSet const& proc_pset,
157+
std::string const& processName,
158+
SignallingProductRegistry& preg) {
157159
// Update Switch ProductDescriptions for the chosen case
158160
struct BranchesCases {
159161
BranchesCases(std::vector<std::string> cases) : caseLabels{std::move(cases)} {}
@@ -173,7 +175,7 @@ namespace edm {
173175
}
174176

175177
bool found = false;
176-
for (auto const& productIter : preg.productList()) {
178+
for (auto const& productIter : preg.registry().productList()) {
177179
BranchKey const& branchKey = productIter.first;
178180
// The alias-for product must be in the same process as
179181
// the SwitchProducer (earlier processes or SubProcesses
@@ -217,7 +219,7 @@ namespace edm {
217219

218220
auto addProductsToException = [&preg, &processName](auto const& caseLabels, edm::Exception& ex) {
219221
std::map<std::string, std::vector<BranchKey>> caseBranches;
220-
for (auto const& item : preg.productList()) {
222+
for (auto const& item : preg.registry().productList()) {
221223
if (item.first.processName() != processName)
222224
continue;
223225

@@ -644,18 +646,18 @@ namespace edm {
644646
// already relied on the WorkerManager being full.
645647
assert(all_workers_count == allWorkers().size());
646648

647-
branchIDListHelper.updateFromRegistry(preg);
649+
branchIDListHelper.updateFromRegistry(preg.registry());
648650

649651
for (auto const& worker : streamSchedules_[0]->allWorkersLumisAndEvents()) {
650-
worker->registerThinnedAssociations(preg, thinnedAssociationsHelper);
652+
worker->registerThinnedAssociations(preg.registry(), thinnedAssociationsHelper);
651653
}
652654

653-
processBlockHelper.updateForNewProcess(preg, processConfiguration->processName());
655+
processBlockHelper.updateForNewProcess(preg.registry(), processConfiguration->processName());
654656

655657
// The output modules consume products in kept branches.
656658
// So we must set this up before freezing.
657659
for (auto& c : all_output_communicators_) {
658-
c->selectProducts(preg, thinnedAssociationsHelper, processBlockHelper);
660+
c->selectProducts(preg.registry(), thinnedAssociationsHelper, processBlockHelper);
659661
}
660662

661663
for (auto& product : preg.productListUpdator()) {
@@ -688,7 +690,7 @@ namespace edm {
688690
}
689691

690692
for (auto& c : all_output_communicators_) {
691-
c->setEventSelectionInfo(outputModulePathPositions, preg.anyProductProduced());
693+
c->setEventSelectionInfo(outputModulePathPositions, preg.registry().anyProductProduced());
692694
}
693695

694696
if (wantSummary_) {
@@ -1241,10 +1243,10 @@ namespace edm {
12411243

12421244
{
12431245
//Need to updateLookup in order to make getByToken work
1244-
auto const processBlockLookup = iRegistry.productLookup(InProcess);
1245-
auto const runLookup = iRegistry.productLookup(InRun);
1246-
auto const lumiLookup = iRegistry.productLookup(InLumi);
1247-
auto const eventLookup = iRegistry.productLookup(InEvent);
1246+
auto const processBlockLookup = iRegistry.registry().productLookup(InProcess);
1247+
auto const runLookup = iRegistry.registry().productLookup(InRun);
1248+
auto const lumiLookup = iRegistry.registry().productLookup(InLumi);
1249+
auto const eventLookup = iRegistry.registry().productLookup(InEvent);
12481250
found->updateLookup(InProcess, *runLookup);
12491251
found->updateLookup(InRun, *runLookup);
12501252
found->updateLookup(InLumi, *lumiLookup);

FWCore/Framework/src/ScheduleItems.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ namespace edm {
8282
prod.setDropped(true);
8383
}
8484
}
85-
subProcessBlockHelper.updateFromParentProcess(parentProcessBlockHelper, *preg_);
85+
subProcessBlockHelper.updateFromParentProcess(parentProcessBlockHelper, preg_->registry());
8686
}
8787

8888
ServiceToken ScheduleItems::initServices(std::vector<ParameterSet>& pServiceSets,

FWCore/Framework/src/StreamSchedule.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ namespace edm {
291291
processSwitchEDAliases(proc_pset, preg, *processConfiguration, allConditionalMods);
292292

293293
//find branches created by the conditional modules
294-
for (auto const& prod : preg.productList()) {
294+
for (auto const& prod : preg.registry().productList()) {
295295
if (allConditionalMods.find(prod.first.moduleLabel()) != allConditionalMods.end()) {
296296
conditionalModsBranches_.emplace(prod.first.moduleLabel(), &prod.second);
297297
}

FWCore/Framework/src/SubProcess.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ namespace edm {
174174

175175
// set the items
176176
act_table_ = std::move(items.act_table_);
177-
preg_ = items.preg();
177+
preg_ = std::make_shared<ProductRegistry>(items.preg()->moveTo());
178178

179179
subProcessParentageHelper_ = items.subProcessParentageHelper();
180180
subProcessParentageHelper_->update(parentSubProcessParentageHelper, *parentProductRegistry);

FWCore/Framework/src/processEDAliases.cc

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace edm {
1616
std::string const& processName,
1717
std::string const& alias,
1818
std::string const& instanceAlias,
19-
SignallingProductRegistry const& preg,
19+
ProductRegistry const& preg,
2020
std::multimap<BranchKey, BranchKey>& aliasMap,
2121
std::map<BranchKey, BranchKey>& aliasKeys) {
2222
std::string const star("*");
@@ -109,7 +109,7 @@ namespace edm {
109109

110110
// Auxiliary search structure to support wildcard for friendlyClassName
111111
std::multimap<std::string, BranchKey> moduleLabelToBranches;
112-
for (auto const& prod : preg.productList()) {
112+
for (auto const& prod : preg.registry().productList()) {
113113
if (processName == prod.second.processName()) {
114114
moduleLabelToBranches.emplace(prod.first.moduleLabel(), prod.first);
115115
}
@@ -150,7 +150,7 @@ namespace edm {
150150
processName,
151151
alias,
152152
instanceAlias,
153-
preg,
153+
preg.registry(),
154154
aliasMap,
155155
aliasKeys);
156156
}
@@ -166,8 +166,9 @@ namespace edm {
166166
} else if (productInstanceName == star) {
167167
bool match = false;
168168
BranchKey lowerBound(friendlyClassName, moduleLabel, empty, empty);
169-
for (ProductRegistry::ProductList::const_iterator it = preg.productList().lower_bound(lowerBound);
170-
it != preg.productList().end() && it->first.friendlyClassName() == friendlyClassName &&
169+
for (ProductRegistry::ProductList::const_iterator it =
170+
preg.registry().productList().lower_bound(lowerBound);
171+
it != preg.registry().productList().end() && it->first.friendlyClassName() == friendlyClassName &&
171172
it->first.moduleLabel() == moduleLabel;
172173
++it) {
173174
if (it->first.processName() != processName) {
@@ -181,14 +182,14 @@ namespace edm {
181182
processName,
182183
alias,
183184
instanceAlias,
184-
preg,
185+
preg.registry(),
185186
aliasMap,
186187
aliasKeys);
187188
}
188189
if (!match) {
189190
// No product was found matching the alias.
190191
// We throw an exception only if a module with the specified module label was created in this process.
191-
for (auto const& product : preg.productList()) {
192+
for (auto const& product : preg.registry().productList()) {
192193
if (moduleLabel == product.first.moduleLabel() && processName == product.first.processName()) {
193194
throw Exception(errors::Configuration, "EDAlias parameter set mismatch\n")
194195
<< "There are no products of type '" << friendlyClassName << "'\n"
@@ -203,7 +204,7 @@ namespace edm {
203204
processName,
204205
alias,
205206
instanceAlias,
206-
preg,
207+
preg.registry(),
207208
aliasMap,
208209
aliasKeys);
209210
}
@@ -214,8 +215,8 @@ namespace edm {
214215
// Now add the new alias entries to the product registry.
215216
for (auto const& aliasEntry : aliasMap) {
216217
// Then check that the alias-for product exists
217-
ProductRegistry::ProductList::const_iterator it = preg.productList().find(aliasEntry.first);
218-
assert(it != preg.productList().end());
218+
ProductRegistry::ProductList::const_iterator it = preg.registry().productList().find(aliasEntry.first);
219+
assert(it != preg.registry().productList().end());
219220
preg.addLabelAlias(it->second, aliasEntry.second.moduleLabel(), aliasEntry.second.productInstanceName());
220221
}
221222
}

FWCore/Framework/test/Event_t.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ testEvent::testEvent()
376376

377377
// Freeze the product registry before we make the Event.
378378
availableProducts_->setFrozen();
379-
branchIDListHelper_->updateFromRegistry(*availableProducts_);
379+
branchIDListHelper_->updateFromRegistry(availableProducts_->registry());
380380
}
381381

382382
testEvent::~testEvent() {}
@@ -440,7 +440,7 @@ void testEvent::setUp() {
440440
// and that is used to create the product holder in the principal used to
441441
// look up the object.
442442

443-
std::shared_ptr<ProductRegistry const> preg(availableProducts_);
443+
std::shared_ptr<ProductRegistry const> preg(std::make_shared<ProductRegistry>(availableProducts_->registry()));
444444
std::string uuid = createGlobalIdentifier();
445445
Timestamp time = make_timestamp();
446446
EventID id = make_id();

0 commit comments

Comments
 (0)