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& itemsToGetFrom(BranchType) 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  void convertCurrentProcessAlias(std::string const& processName);
93 
94  std::vector<ConsumesInfo> consumesInfo() const;
95 
96  void resolvePutIndicies(BranchType iBranchType,
97  std::unordered_multimap<std::string, edm::ProductResolverIndex> const& iIndicies,
98  std::string const& moduleLabel);
99 
100  std::vector<edm::ProductResolverIndex> const& indiciesForPutProducts(BranchType iBranchType) const;
101 
102  protected:
103  template<typename F> void createStreamModules(F iFunc) {
104  for(auto& m: m_streamModules) {
105  m = iFunc();
106  m->setModuleDescriptionPtr(&moduleDescription_);
107  }
108  }
109 
110  void commit(Run& iRun) {
111  iRun.commit_(m_streamModules[0]->indiciesForPutProducts(InRun));
112  }
113  void commit(LuminosityBlock& iLumi) {
114  iLumi.commit_(m_streamModules[0]->indiciesForPutProducts(InLumi));
115  }
116  template<typename L, typename I>
117  void commit(Event& iEvent, L* iList, I* iID) {
118  iEvent.commit_(m_streamModules[0]->indiciesForPutProducts(InEvent), iList,iID);
119  }
120 
122  return m_streamModules[0];
123  }
124  private:
125  ProducingModuleAdaptorBase(const ProducingModuleAdaptorBase&) = delete; // stop default
126 
127  const ProducingModuleAdaptorBase& operator=(const ProducingModuleAdaptorBase&) = delete; // stop default
128 
129  void doPreallocate(PreallocationConfiguration const&);
130  virtual void setupStreamModules() = 0;
131  void doBeginJob();
132  virtual void doEndJob() = 0;
133 
134  void doBeginStream(StreamID id);
135  void doEndStream(StreamID id);
136  void doStreamBeginRun(StreamID id,
137  RunPrincipal const& ep,
138  EventSetup const& c,
139  ModuleCallingContext const*);
140  virtual void setupRun(T*, RunIndex) = 0;
141  void doStreamEndRun(StreamID id,
142  RunPrincipal const& ep,
143  EventSetup const& c,
144  ModuleCallingContext const*);
145  virtual void streamEndRunSummary(T*,edm::Run const&, edm::EventSetup const&) = 0;
146 
147  void doStreamBeginLuminosityBlock(StreamID id,
148  LuminosityBlockPrincipal const& ep,
149  EventSetup const& c,
150  ModuleCallingContext const*);
151  virtual void setupLuminosityBlock(T*, LuminosityBlockIndex) = 0;
152  void doStreamEndLuminosityBlock(StreamID id,
153  LuminosityBlockPrincipal const& ep,
154  EventSetup const& c,
155  ModuleCallingContext const*);
156  virtual void streamEndLuminosityBlockSummary(T*,edm::LuminosityBlock const&, edm::EventSetup const&) = 0;
157 
158 
159  virtual void doBeginRun(RunPrincipal const& rp, EventSetup const& c,
160  ModuleCallingContext const*)=0;
161  virtual void doEndRun(RunPrincipal const& rp, EventSetup const& c,
162  ModuleCallingContext const*)=0;
163  virtual void doBeginLuminosityBlock(LuminosityBlockPrincipal const& lbp,
164  EventSetup const& c,
165  ModuleCallingContext const*)=0;
166  virtual void doEndLuminosityBlock(LuminosityBlockPrincipal const& lbp,
167  EventSetup const& c,
168  ModuleCallingContext const*)=0;
169 
170  void doPreForkReleaseResources();
171  void doPostForkReacquireResources(unsigned int iChildIndex, unsigned int iNumberOfChildren);
172 
173  //For now, the following are just dummy implemenations with no ability for users to override
174  void doRespondToOpenInputFile(FileBlock const& fb);
175  void doRespondToCloseInputFile(FileBlock const& fb);
176  void doRegisterThinnedAssociations(ProductRegistry const&,
178 
179  // ---------- member data --------------------------------
181  moduleDescription_ = md;
182  }
184  protected:
185  std::vector<T*> m_streamModules;
186 
187  };
188  }
189 }
190 
191 #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:123
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