Skip to content

Commit e3e58f9

Browse files
committed
Only SignallingProductRegistry can add products
This isolates where where the ProductRegistry can have additional products added.
1 parent e7f919b commit e3e58f9

25 files changed

+82
-60
lines changed

DataFormats/Provenance/interface/ProductRegistry.h

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@ namespace edm {
3737
public:
3838
typedef std::map<BranchKey, ProductDescription> ProductList;
3939

40-
ProductRegistry();
41-
40+
ProductRegistry() = default;
41+
ProductRegistry(const ProductRegistry&) = default;
42+
ProductRegistry(ProductRegistry&&) = default;
4243
// A constructor from the persistent data members from another product registry.
4344
// saves time by not copying the transient components.
4445
// The constructed registry will be frozen by default.
@@ -48,12 +49,6 @@ namespace edm {
4849

4950
typedef std::map<BranchKey, ProductDescription const> ConstProductList;
5051

51-
void addProduct(ProductDescription const& productdesc, bool iFromListener = false);
52-
53-
void addLabelAlias(ProductDescription const& productdesc,
54-
std::string const& labelAlias,
55-
std::string const& instanceAlias);
56-
5752
void copyProduct(ProductDescription const& productdesc);
5853

5954
void setFrozen(bool initializeLookupInfo = true);
@@ -117,7 +112,6 @@ namespace edm {
117112
bool anyProducts(BranchType const brType) const;
118113

119114
std::shared_ptr<ProductResolverIndexHelper const> productLookup(BranchType branchType) const;
120-
std::shared_ptr<ProductResolverIndexHelper> productLookup(BranchType branchType);
121115

122116
// returns the appropriate ProductResolverIndex else ProductResolverIndexInvalid if no BranchID is available
123117
ProductResolverIndex indexFrom(BranchID const& iID) const;
@@ -163,6 +157,13 @@ namespace edm {
163157
AliasToOriginalVector aliasToOriginal_;
164158
};
165159

160+
protected:
161+
void addProduct_(ProductDescription const& productdesc, bool iFromListener = false);
162+
163+
void addLabelAlias_(ProductDescription const& productdesc,
164+
std::string const& labelAlias,
165+
std::string const& instanceAlias);
166+
166167
private:
167168
void setProductProduced(BranchType branchType) {
168169
transient_.productProduced_[branchType] = true;

DataFormats/Provenance/src/ProductRegistry.cc

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@
2929

3030
namespace edm {
3131

32-
ProductRegistry::ProductRegistry() : productList_(), transient_() {}
33-
3432
ProductRegistry::Transients::Transients()
3533
: frozen_(false),
3634
productProduced_(),
@@ -65,7 +63,7 @@ namespace edm {
6563
freezeIt(toBeFrozen);
6664
}
6765

68-
void ProductRegistry::addProduct(ProductDescription const& productDesc, bool fromListener) {
66+
void ProductRegistry::addProduct_(ProductDescription const& productDesc, bool fromListener) {
6967
assert(productDesc.produced());
7068
throwIfFrozen();
7169
std::pair<ProductList::iterator, bool> ret =
@@ -105,9 +103,9 @@ namespace edm {
105103
addCalled(productDesc, fromListener);
106104
}
107105

108-
void ProductRegistry::addLabelAlias(ProductDescription const& productDesc,
109-
std::string const& labelAlias,
110-
std::string const& instanceAlias) {
106+
void ProductRegistry::addLabelAlias_(ProductDescription const& productDesc,
107+
std::string const& labelAlias,
108+
std::string const& instanceAlias) {
111109
assert(productDesc.produced());
112110
assert(productDesc.branchID().isValid());
113111
throwIfFrozen();
@@ -440,11 +438,11 @@ namespace edm {
440438
}
441439
}
442440
ProductResolverIndex index = new_productLookups[desc.branchType()]->insert(typeID,
443-
desc.moduleLabel().c_str(),
444-
desc.productInstanceName().c_str(),
445-
desc.processName().c_str(),
446-
containedTypeID,
447-
baseTypesOfContainedType);
441+
desc.moduleLabel().c_str(),
442+
desc.productInstanceName().c_str(),
443+
desc.processName().c_str(),
444+
containedTypeID,
445+
baseTypesOfContainedType);
448446

449447
transient_.branchIDToIndex_[desc.branchID()] = index;
450448
}

FWCore/Framework/interface/EventProcessor.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -280,8 +280,7 @@ namespace edm {
280280

281281
void processEventWithLooper(EventPrincipal&, unsigned int iStreamIndex);
282282

283-
std::shared_ptr<SignallingProductRegistry const> preg() const { return get_underlying_safe(preg_); }
284-
std::shared_ptr<SignallingProductRegistry>& preg() { return get_underlying_safe(preg_); }
283+
std::shared_ptr<ProductRegistry const> preg() const { return get_underlying_safe(preg_); }
285284
std::shared_ptr<BranchIDListHelper const> branchIDListHelper() const {
286285
return get_underlying_safe(branchIDListHelper_);
287286
}
@@ -312,7 +311,7 @@ namespace edm {
312311
oneapi::tbb::task_group taskGroup_;
313312

314313
std::shared_ptr<ActivityRegistry> actReg_; // We do not use propagate_const because the registry itself is mutable.
315-
edm::propagate_const<std::shared_ptr<SignallingProductRegistry>> preg_;
314+
edm::propagate_const<std::shared_ptr<ProductRegistry>> preg_;
316315
edm::propagate_const<std::shared_ptr<BranchIDListHelper>> branchIDListHelper_;
317316
edm::propagate_const<std::shared_ptr<ProcessBlockHelper>> processBlockHelper_;
318317
edm::propagate_const<std::shared_ptr<ThinnedAssociationsHelper>> thinnedAssociationsHelper_;

FWCore/Framework/interface/InputSource.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ namespace edm {
4444
class ParameterSetDescription;
4545
class ProcessContext;
4646
class ProcessHistoryRegistry;
47-
class SignallingProductRegistry;
4847
class StreamContext;
4948
class ModuleCallingContext;
5049
class SharedResourcesAcquirer;

FWCore/Framework/interface/ProductRegistryHelper.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
namespace edm {
1919
class ModuleDescription;
20-
class ProductRegistry;
20+
class SignallingProductRegistry;
2121
struct DoNotRecordParents;
2222

2323
template <Transition B>
@@ -104,7 +104,7 @@ namespace edm {
104104
static void addToRegistry(TypeLabelList::const_iterator const& iBegin,
105105
TypeLabelList::const_iterator const& iEnd,
106106
ModuleDescription const& iDesc,
107-
ProductRegistry& iReg,
107+
SignallingProductRegistry& iReg,
108108
ProductRegistryHelper* iProd,
109109
bool iIsListener = false);
110110

FWCore/Framework/interface/Schedule.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ namespace edm {
300300
void initializeEarlyDelete(std::vector<std::string> const& branchesToDeleteEarly,
301301
std::multimap<std::string, std::string> const& referencesToBranches,
302302
std::vector<std::string> const& modulesToSkip,
303-
edm::SignallingProductRegistry const& preg);
303+
edm::ProductRegistry const& preg);
304304

305305
/// returns the collection of pointers to workers
306306
AllWorkers const& allWorkers() const;

FWCore/Framework/interface/SignallingProductRegistry.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,25 @@ namespace edm {
3333
class SignallingProductRegistry : public ProductRegistry {
3434
public:
3535
SignallingProductRegistry() : ProductRegistry(), productAddedSignal_(), typeAddedStack_() {}
36+
3637
explicit SignallingProductRegistry(ProductRegistry const& preg)
3738
: ProductRegistry(preg.productList(), false), productAddedSignal_(), typeAddedStack_() {}
3839
signalslot::Signal<void(ProductDescription const&)> productAddedSignal_;
3940

41+
struct Copy {};
42+
43+
SignallingProductRegistry(ProductRegistry const& preg, Copy): ProductRegistry(preg), productAddedSignal_(), typeAddedStack_() {};
44+
45+
void addProduct(ProductDescription const& productdesc, bool iFromListener = false) {
46+
addProduct_(productdesc, iFromListener);
47+
}
48+
49+
void addLabelAlias(ProductDescription const& productdesc,
50+
std::string const& labelAlias,
51+
std::string const& instanceAlias) {
52+
addLabelAlias_(productdesc, labelAlias, instanceAlias);
53+
}
54+
4055
SignallingProductRegistry(SignallingProductRegistry const&) = delete; // Disallow copying and moving
4156
SignallingProductRegistry& operator=(SignallingProductRegistry const&) = delete; // Disallow copying and moving
4257

@@ -50,6 +65,8 @@ namespace edm {
5065
serviceregistry::connect_but_block_self(productAddedSignal_, std::bind(iMethod, iObj, _1));
5166
}
5267

68+
ProductRegistry const& registry() { return *this; }
69+
5370
private:
5471
void addCalled(ProductDescription const&, bool) override;
5572
// ---------- member data --------------------------------

FWCore/Framework/interface/StreamSchedule.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ namespace edm {
221221
std::vector<std::string> const& branchesToDeleteEarly,
222222
std::multimap<std::string, std::string> const& referencesToBranches,
223223
std::vector<std::string> const& modulesToSkip,
224-
edm::SignallingProductRegistry const& preg);
224+
edm::ProductRegistry const& preg);
225225

226226
/// returns the collection of pointers to workers
227227
AllWorkers const& allWorkersBeginEnd() const { return workerManagerBeginEnd_.allWorkers(); }

FWCore/Framework/src/EventProcessor.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1099,7 +1099,8 @@ namespace edm {
10991099

11001100
bool EventProcessor::endOfLoop() {
11011101
if (looper_) {
1102-
ModuleChanger changer(schedule_.get(), preg_.get(), esp_->recordsToResolverIndices());
1102+
SignallingProductRegistry sReg(*preg(), edm::SignallingProductRegistry::Copy{});
1103+
ModuleChanger changer(schedule_.get(), &sReg, esp_->recordsToResolverIndices());
11031104
looper_->setModuleChanger(&changer);
11041105
EDLooperBase::Status status = looper_->doEndOfLoop(esp_->eventSetupImpl());
11051106
looper_->setModuleChanger(nullptr);

FWCore/Framework/src/ProducerBase.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ namespace edm {
2323
public:
2424
CallbackWrapper(ProductRegistryHelper* iProd,
2525
std::function<void(ProductDescription const&)> iCallback,
26-
ProductRegistry* iReg,
26+
SignallingProductRegistry* iReg,
2727
const ModuleDescription& iDesc)
2828
: prod_(iProd), callback_(iCallback), reg_(iReg), mdesc_(iDesc), lastSize_(iProd->typeLabelList().size()) {}
2929

@@ -46,7 +46,7 @@ namespace edm {
4646
private:
4747
ProductRegistryHelper* prod_;
4848
std::function<void(ProductDescription const&)> callback_;
49-
ProductRegistry* reg_;
49+
SignallingProductRegistry* reg_;
5050
ModuleDescription mdesc_;
5151
unsigned int lastSize_;
5252
};

0 commit comments

Comments
 (0)