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