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  void
78 
79  void itemsToGet(BranchType, std::vector<ProductResolverIndexAndSkipBit>&) const;
80  void itemsMayGet(BranchType, std::vector<ProductResolverIndexAndSkipBit>&) const;
81  std::vector<ProductResolverIndexAndSkipBit> const& itemsToGetFromEvent() const;
82 
83  void updateLookup(BranchType iBranchType,
85  bool iPrefetchMayGet);
86 
87  void modulesWhoseProductsAreConsumed(std::vector<ModuleDescription const*>& modules,
88  ProductRegistry const& preg,
89  std::map<std::string, ModuleDescription const*> const& labelsToDesc,
90  std::string const& processName) const;
91 
92  std::vector<ConsumesInfo> consumesInfo() const;
93 
94  void resolvePutIndicies(BranchType iBranchType,
95  std::unordered_multimap<std::string, edm::ProductResolverIndex> const& iIndicies,
96  std::string const& moduleLabel);
97 
98  std::vector<edm::ProductResolverIndex> const& indiciesForPutProducts(BranchType iBranchType) const;
99 
100  protected:
101  template<typename F> void createStreamModules(F iFunc) {
102  for(auto& m: m_streamModules) {
103  m = iFunc();
104  m->setModuleDescriptionPtr(&moduleDescription_);
105  }
106  }
107 
108  void commit(Run& iRun) {
109  iRun.commit_(m_streamModules[0]->indiciesForPutProducts(InRun));
110  }
111  void commit(LuminosityBlock& iLumi) {
112  iLumi.commit_(m_streamModules[0]->indiciesForPutProducts(InLumi));
113  }
114  template<typename L, typename I>
115  void commit(Event& iEvent, L* iList, I* iID) {
116  iEvent.commit_(m_streamModules[0]->indiciesForPutProducts(InEvent), iList,iID);
117  }
118 
120  return m_streamModules[0];
121  }
122  private:
123  ProducingModuleAdaptorBase(const ProducingModuleAdaptorBase&) = delete; // stop default
124 
125  const ProducingModuleAdaptorBase& operator=(const ProducingModuleAdaptorBase&) = delete; // stop default
126 
127  void doPreallocate(PreallocationConfiguration const&);
128  virtual void setupStreamModules() = 0;
129  void doBeginJob();
130  virtual void doEndJob() = 0;
131 
132  void doBeginStream(StreamID id);
133  void doEndStream(StreamID id);
134  void doStreamBeginRun(StreamID id,
135  RunPrincipal const& ep,
136  EventSetup const& c,
137  ModuleCallingContext const*);
138  virtual void setupRun(T*, RunIndex) = 0;
139  void doStreamEndRun(StreamID id,
140  RunPrincipal const& ep,
141  EventSetup const& c,
142  ModuleCallingContext const*);
143  virtual void streamEndRunSummary(T*,edm::Run const&, edm::EventSetup const&) = 0;
144 
145  void doStreamBeginLuminosityBlock(StreamID id,
146  LuminosityBlockPrincipal const& ep,
147  EventSetup const& c,
148  ModuleCallingContext const*);
149  virtual void setupLuminosityBlock(T*, LuminosityBlockIndex) = 0;
150  void doStreamEndLuminosityBlock(StreamID id,
151  LuminosityBlockPrincipal const& ep,
152  EventSetup const& c,
153  ModuleCallingContext const*);
154  virtual void streamEndLuminosityBlockSummary(T*,edm::LuminosityBlock const&, edm::EventSetup const&) = 0;
155 
156 
157  virtual void doBeginRun(RunPrincipal const& rp, EventSetup const& c,
158  ModuleCallingContext const*)=0;
159  virtual void doEndRun(RunPrincipal const& rp, EventSetup const& c,
160  ModuleCallingContext const*)=0;
161  virtual void doBeginLuminosityBlock(LuminosityBlockPrincipal const& lbp,
162  EventSetup const& c,
163  ModuleCallingContext const*)=0;
164  virtual void doEndLuminosityBlock(LuminosityBlockPrincipal const& lbp,
165  EventSetup const& c,
166  ModuleCallingContext const*)=0;
167 
168  void doPreForkReleaseResources();
169  void doPostForkReacquireResources(unsigned int iChildIndex, unsigned int iNumberOfChildren);
170 
171  //For now, the following are just dummy implemenations with no ability for users to override
172  void doRespondToOpenInputFile(FileBlock const& fb);
173  void doRespondToCloseInputFile(FileBlock const& fb);
174  void doRegisterThinnedAssociations(ProductRegistry const&,
176 
177  // ---------- member data --------------------------------
179  moduleDescription_ = md;
180  }
182  protected:
183  std::vector<T*> m_streamModules;
184 
185  };
186  }
187 }
188 
189 #endif
void commit(Event &iEvent, L *iList, I *iID)
void registerProductsAndCallbacks(ProductRegistry *iReg) override
Definition: ModuleHolder.h:76
void commit_(std::vector< edm::ProductResolverIndex > const &iShouldPut, std::vector< BranchID > *previousParentage=0, ParentageID *previousParentageId=0)
Definition: Event.cc:118
BranchType
Definition: BranchType.h:11
int iEvent
Definition: GenABIO.cc:230
void commit_(std::vector< edm::ProductResolverIndex > const &iShouldPut)
Definition: Run.cc:79
void setModuleDescription(ModuleDescription const &md)
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:42