CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ProducingModuleAdaptorBase.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: FWCore/Framework
4 // Class : edm::stream::ProducingModuleAdaptorBase
5 //
6 // Implementation:
7 // [Notes on implementation]
8 //
9 // Original Author: Chris Jones
10 // Created: Fri, 02 Aug 2013 21:43:44 GMT
11 //
12 
13 // system include files
14 
15 // user include files
22 
23 //
24 // constants, enums and typedefs
25 //
26 
27 //
28 // static data member definitions
29 //
30 
31 //
32 // constructors and destructor
33 //
34 namespace edm {
35  namespace stream {
36  template< typename T>
38  {
39  }
40 
41  template< typename T>
43  {
44  for(auto m: m_streamModules) {
45  delete m;
46  }
47  }
48 
49  //
50  // member functions
51  //
52 
53  template< typename T>
54  void
56  m_streamModules.resize(iPrealloc.numberOfStreams(),
57  static_cast<T*>(nullptr));
58  setupStreamModules();
59  }
60 
61  template< typename T>
62  void
64  auto firstMod = m_streamModules[0];
65  if(firstMod->registrationCallback() and m_streamModules.size()>1) {
66  //we have a callback so we will collect all callbacks and create a new callback which calls them all.
67 
68  std::vector<std::function<void(BranchDescription const&)>> callbacks;
69  callbacks.reserve(m_streamModules.size());
70 
71  for(auto mod: m_streamModules) {
72  callbacks.push_back(mod->registrationCallback());
73  }
74  //Since only the first module will actually do the registration
75  // we will change its callback to call all the callbacks
76  firstMod->callWhenNewProductsRegistered([callbacks](BranchDescription const& iBD) {
77  for(auto c: callbacks) {
78  c(iBD);
79  }
80  });
81  }
82  firstMod->registerProducts(firstMod,reg,moduleDescription_);
83  }
84 
85  template< typename T>
86  void
87  ProducingModuleAdaptorBase<T>::itemsToGet(BranchType iType, std::vector<ProductHolderIndexAndSkipBit>& iIndices) const {
88  assert(not m_streamModules.empty());
89  m_streamModules[0]->itemsToGet(iType,iIndices);
90  }
91 
92  template< typename T>
93  void
94  ProducingModuleAdaptorBase<T>::itemsMayGet(BranchType iType, std::vector<ProductHolderIndexAndSkipBit>& iIndices) const {
95  assert(not m_streamModules.empty());
96  m_streamModules[0]->itemsMayGet(iType,iIndices);
97  }
98 
99  template<typename T>
100  std::vector<edm::ProductHolderIndexAndSkipBit> const&
102  assert(not m_streamModules.empty());
103  return m_streamModules[0]->itemsToGetFromEvent();
104  }
105 
106  template< typename T>
107  void
109  ProductHolderIndexHelper const& iHelper) {
110  for(auto mod: m_streamModules) {
111  mod->updateLookup(iType,iHelper);
112  }
113  }
114 
115  template< typename T>
116  void
118 
119  }
120 
121  template< typename T>
122  void
124  m_streamModules[id]->beginStream(id);
125  }
126  template< typename T>
127  void
129  m_streamModules[id]->endStream();
130  }
131 
132  template< typename T>
133  void
135  RunPrincipal& rp,
136  EventSetup const& c,
137  ModuleCallingContext const* mcc)
138  {
139  auto mod = m_streamModules[id];
140  setupRun(mod, rp.index());
141 
142  Run r(rp, moduleDescription_, mcc);
143  r.setConsumer(mod);
144  mod->beginRun(r, c);
145 
146  }
147  template< typename T>
148  void
150  RunPrincipal& rp,
151  EventSetup const& c,
152  ModuleCallingContext const* mcc)
153  {
154  auto mod = m_streamModules[id];
155  Run r(rp, moduleDescription_, mcc);
156  r.setConsumer(mod);
157  mod->endRun(r, c);
158  streamEndRunSummary(mod,r,c);
159  }
160 
161  template< typename T>
162  void
165  EventSetup const& c,
166  ModuleCallingContext const* mcc) {
167  auto mod = m_streamModules[id];
168  setupLuminosityBlock(mod,lbp.index());
169 
170  LuminosityBlock lb(lbp, moduleDescription_, mcc);
171  lb.setConsumer(mod);
172  mod->beginLuminosityBlock(lb, c);
173  }
174 
175  template< typename T>
176  void
179  EventSetup const& c,
180  ModuleCallingContext const* mcc)
181  {
182  auto mod = m_streamModules[id];
183  LuminosityBlock lb(lbp, moduleDescription_, mcc);
184  lb.setConsumer(mod);
185  mod->endLuminosityBlock(lb, c);
186  streamEndLuminosityBlockSummary(mod,lb, c);
187  }
188 
189  template< typename T>
190  void
192  template< typename T>
193  void
195  template< typename T>
196  void
198  template< typename T>
199  void
200  ProducingModuleAdaptorBase<T>::doPostForkReacquireResources(unsigned int iChildIndex, unsigned int iNumberOfChildren){}
201  }
202 }
void setConsumer(EDConsumerBase const *iConsumer)
void doStreamEndRun(StreamID id, RunPrincipal &ep, EventSetup const &c, ModuleCallingContext const *)
LuminosityBlockIndex index() const
void doPreallocate(PreallocationConfiguration const &)
void doStreamBeginLuminosityBlock(StreamID id, LuminosityBlockPrincipal &ep, EventSetup const &c, ModuleCallingContext const *)
BranchType
Definition: BranchType.h:11
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventIDconst &, edm::Timestampconst & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those callbacks
Definition: Activities.doc:12
void itemsToGet(BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
void registerProductsAndCallbacks(ProducingModuleAdaptorBase const *, ProductRegistry *reg)
void doStreamEndLuminosityBlock(StreamID id, LuminosityBlockPrincipal &ep, EventSetup const &c, ModuleCallingContext const *)
void itemsMayGet(BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
RunIndex index() const
Definition: RunPrincipal.h:53
void updateLookup(BranchType iBranchType, ProductHolderIndexHelper const &)
std::vector< ProductHolderIndexAndSkipBit > const & itemsToGetFromEvent() const
void doStreamBeginRun(StreamID id, RunPrincipal &ep, EventSetup const &c, ModuleCallingContext const *)
long double T
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4
void setConsumer(EDConsumerBase const *iConsumer)
Definition: Run.h:48
Definition: Run.h:41
void doPostForkReacquireResources(unsigned int iChildIndex, unsigned int iNumberOfChildren)