CMS 3D CMS Logo

ProducingModuleAdaptorBase.h
Go to the documentation of this file.
1 #ifndef FWCore_Framework_stream_ProducingModuleAdaptorBase_h
2 #define FWCore_Framework_stream_ProducingModuleAdaptorBase_h
3 // -*- C++ -*-
4 //
5 // Package: FWCore/Framework
6 // Class : ProducingModuleAdaptorBase
7 //
16 //
17 // Original Author: Chris Jones
18 // Created: Fri, 02 Aug 2013 18:09:15 GMT
19 //
20 
21 // system include files
22 #include <map>
23 #include <string>
24 #include <vector>
25 #include <unordered_map>
26 
27 // user include files
40 
41 // forward declarations
42 
43 namespace edm {
44  class Event;
45  class ModuleCallingContext;
46  class ProductResolverIndexHelper;
47  class EDConsumerBase;
48  class PreallocationConfiguration;
49  class ProductResolverIndexAndSkipBit;
50  class ProductRegistry;
51  class ThinnedAssociationsHelper;
52 
53  namespace maker {
54  template<typename T> class ModuleHolderT;
55  }
56 
57  namespace stream {
58  template<typename T>
59  class ProducingModuleAdaptorBase
60  {
61 
62  public:
63  template <typename U> friend class edm::WorkerT;
64  template <typename U> friend class edm::maker::ModuleHolderT;
65 
67  virtual ~ProducingModuleAdaptorBase();
68 
69  // ---------- const member functions ---------------------
70 
71  // ---------- static member functions --------------------
72 
73  // ---------- member functions ---------------------------
74  const ModuleDescription& moduleDescription() const { return moduleDescription_;}
75 
76  virtual bool wantsGlobalRuns() const = 0;
77  virtual bool wantsGlobalLuminosityBlocks() const = 0;
78  virtual bool hasAcquire() const = 0;
79  virtual bool hasAccumulator() const = 0;
80  bool wantsStreamRuns() const {return true;}
81  bool wantsStreamLuminosityBlocks() const {return true;}
82 
83  void
85 
86  void itemsToGet(BranchType, std::vector<ProductResolverIndexAndSkipBit>&) const;
87  void itemsMayGet(BranchType, std::vector<ProductResolverIndexAndSkipBit>&) const;
88  std::vector<ProductResolverIndexAndSkipBit> const& itemsToGetFrom(BranchType) const;
89 
90  void updateLookup(BranchType iBranchType,
92  bool iPrefetchMayGet);
93 
94  void modulesWhoseProductsAreConsumed(std::vector<ModuleDescription const*>& modules,
95  ProductRegistry const& preg,
96  std::map<std::string, ModuleDescription const*> const& labelsToDesc,
97  std::string const& processName) const;
98 
99  void convertCurrentProcessAlias(std::string const& processName);
100 
101  std::vector<ConsumesInfo> consumesInfo() const;
102 
103  using ModuleToResolverIndicies = std::unordered_multimap<std::string,
104  std::tuple<edm::TypeID const*, const char*, edm::ProductResolverIndex>>;
105 
106  void resolvePutIndicies(BranchType iBranchType,
107  ModuleToResolverIndicies const& iIndicies,
108  std::string const& moduleLabel);
109 
110  std::vector<edm::ProductResolverIndex> const& indiciesForPutProducts(BranchType iBranchType) const;
111 
112  protected:
113  template<typename F> void createStreamModules(F iFunc) {
114  for(auto& m: m_streamModules) {
115  m = iFunc();
116  m->setModuleDescriptionPtr(&moduleDescription_);
117  }
118  }
119 
120  void commit(Run& iRun) {
121  iRun.commit_(m_streamModules[0]->indiciesForPutProducts(InRun));
122  }
123  void commit(LuminosityBlock& iLumi) {
124  iLumi.commit_(m_streamModules[0]->indiciesForPutProducts(InLumi));
125  }
126  template<typename I>
127  void commit(Event& iEvent, I* iID) {
128  iEvent.commit_(m_streamModules[0]->indiciesForPutProducts(InEvent), iID);
129  }
130 
132  return m_streamModules[0];
133  }
134 
136  return m_streamModules[0];
137  }
138 
139  private:
140  ProducingModuleAdaptorBase(const ProducingModuleAdaptorBase&) = delete; // stop default
141 
142  const ProducingModuleAdaptorBase& operator=(const ProducingModuleAdaptorBase&) = delete; // stop default
143 
144  void doPreallocate(PreallocationConfiguration const&);
145  virtual void preallocLumis(unsigned int) {}
146  virtual void setupStreamModules() = 0;
147  void doBeginJob();
148  virtual void doEndJob() = 0;
149 
150  void doBeginStream(StreamID id);
151  void doEndStream(StreamID id);
152  void doStreamBeginRun(StreamID id,
153  RunPrincipal const& ep,
154  EventSetup const& c,
155  ModuleCallingContext const*);
156  virtual void setupRun(T*, RunIndex) = 0;
157  void doStreamEndRun(StreamID id,
158  RunPrincipal const& ep,
159  EventSetup const& c,
160  ModuleCallingContext const*);
161  virtual void streamEndRunSummary(T*,edm::Run const&, edm::EventSetup const&) = 0;
162 
163  void doStreamBeginLuminosityBlock(StreamID id,
164  LuminosityBlockPrincipal const& ep,
165  EventSetup const& c,
166  ModuleCallingContext const*);
167  virtual void setupLuminosityBlock(T*, LuminosityBlockIndex) = 0;
168  void doStreamEndLuminosityBlock(StreamID id,
169  LuminosityBlockPrincipal const& ep,
170  EventSetup const& c,
171  ModuleCallingContext const*);
172  virtual void streamEndLuminosityBlockSummary(T*,edm::LuminosityBlock const&, edm::EventSetup const&) = 0;
173 
174 
175  virtual void doBeginRun(RunPrincipal const& rp, EventSetup const& c,
176  ModuleCallingContext const*)=0;
177  virtual void doEndRun(RunPrincipal const& rp, EventSetup const& c,
178  ModuleCallingContext const*)=0;
179  virtual void doBeginLuminosityBlock(LuminosityBlockPrincipal const& lbp,
180  EventSetup const& c,
181  ModuleCallingContext const*)=0;
182  virtual void doEndLuminosityBlock(LuminosityBlockPrincipal const& lbp,
183  EventSetup const& c,
184  ModuleCallingContext const*)=0;
185 
186  //For now, the following are just dummy implemenations with no ability for users to override
187  void doRespondToOpenInputFile(FileBlock const& fb);
188  void doRespondToCloseInputFile(FileBlock const& fb);
189  void doRegisterThinnedAssociations(ProductRegistry const&,
191 
192  // ---------- member data --------------------------------
194  moduleDescription_ = md;
195  }
197  protected:
198  std::vector<T*> m_streamModules;
199 
200  };
201  }
202 }
203 
204 #endif
std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >> ModuleToResolverIndicies
void registerProductsAndCallbacks(ProductRegistry *iReg) override
Definition: ModuleHolder.h:76
BranchType
Definition: BranchType.h:11
int iEvent
Definition: GenABIO.cc:230
void commit_(std::vector< edm::ProductResolverIndex > const &iShouldPut)
Definition: Run.cc:87
void setModuleDescription(ModuleDescription const &md)
void commit_(std::vector< edm::ProductResolverIndex > const &iShouldPut, ParentageID *previousParentageId=0)
Definition: Event.cc:171
const std::complex< double > I
Definition: I.h:8
const ModuleDescription & moduleDescription() const
HLT enums.
static uInt32 F(BLOWFISH_CTX *ctx, uInt32 x)
Definition: blowfish.cc:281
long double T
void commit_(std::vector< edm::ProductResolverIndex > const &iShouldPut)
Definition: Run.h:44