FWCore
Framework
src
SignallingProductRegistry.cc
Go to the documentation of this file.
1
// -*- C++ -*-
2
//
3
// Package: Framework
4
// Class : SignallingProductRegistry
5
//
6
// Implementation:
7
// <Notes on implementation>
8
//
9
// Original Author: Chris Jones
10
// Created: Fri Sep 23 16:52:50 CEST 2005
11
//
12
13
// system include files
14
15
// user include files
16
#include "
FWCore/Framework/src/SignallingProductRegistry.h
"
17
#include "
FWCore/Utilities/interface/Exception.h
"
18
19
using namespace
edm
;
20
//
21
// member functions
22
//
23
namespace
{
24
struct
StackGuard {
25
StackGuard(
std::string
const
& iTypeName, std::map<std::string, unsigned int>& ioStack,
bool
iFromListener)
26
: numType_(++ioStack[iTypeName]), itr_(ioStack.
find
(iTypeName)), fromListener_(iFromListener) {
27
if
(iFromListener) {
28
++(itr_->second);
29
}
30
}
31
32
~StackGuard() {
33
--(itr_->second);
34
if
(fromListener_) {
35
--(itr_->second);
36
}
37
}
38
39
unsigned
int
numType_;
40
std::map<std::string, unsigned int>::iterator itr_;
41
bool
fromListener_;
42
};
43
}
// namespace
44
45
void
SignallingProductRegistry::addCalled
(
BranchDescription
const
& iProd,
bool
iFromListener) {
46
StackGuard guard(iProd.
className
(),
typeAddedStack_
, iFromListener);
47
if
(guard.numType_ > 2) {
48
throw
cms::Exception
(
"CircularReference"
)
49
<<
"Attempted to register the production of "
<< iProd.
className
() <<
" from module "
<< iProd.
moduleLabel
()
50
<<
" with product instance \""
<< iProd.
productInstanceName
() <<
"\"\n"
51
<<
"However, this was in reaction to a registration of a production for the same type \n"
52
<<
"from another module who was also listening to product registrations.\n"
53
<<
"This can lead to circular Event::get* calls.\n"
54
<<
"Please reconfigure job so it does not contain both of the modules."
;
55
}
56
productAddedSignal_
(iProd);
57
}
edm::SignallingProductRegistry::typeAddedStack_
std::map< std::string, unsigned int > typeAddedStack_
Definition:
SignallingProductRegistry.h:45
edm::BranchDescription::productInstanceName
std::string const & productInstanceName() const
Definition:
BranchDescription.h:81
edm::SignallingProductRegistry::productAddedSignal_
signalslot::Signal< void(BranchDescription const &)> productAddedSignal_
Definition:
SignallingProductRegistry.h:37
edm
HLT enums.
Definition:
AlignableModifier.h:19
SignallingProductRegistry.h
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition:
FindCaloHit.cc:19
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition:
AlCaHLTBitMon_QueryRunRegistry.py:256
edm::BranchDescription::moduleLabel
std::string const & moduleLabel() const
Definition:
BranchDescription.h:72
Exception
Definition:
hltDiff.cc:245
edm::SignallingProductRegistry::addCalled
void addCalled(BranchDescription const &, bool) override
Definition:
SignallingProductRegistry.cc:45
Exception.h
edm::BranchDescription
Definition:
BranchDescription.h:32
edm::BranchDescription::className
std::string const & className() const
Definition:
BranchDescription.h:79
Generated for CMSSW Reference Manual by
1.8.16