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>
55  class ModuleHolderT;
56  }
57 
58  namespace eventsetup {
60  }
61 
62  namespace stream {
63  template <typename T>
64  class ProducingModuleAdaptorBase {
65  public:
66  template <typename U>
67  friend class edm::WorkerT;
68  template <typename U>
70 
72  virtual ~ProducingModuleAdaptorBase();
73 
74  // ---------- const member functions ---------------------
75 
76  // ---------- static member functions --------------------
77 
78  // ---------- member functions ---------------------------
79  const ModuleDescription& moduleDescription() const { return moduleDescription_; }
80 
81  virtual bool wantsGlobalRuns() const = 0;
82  virtual bool wantsGlobalLuminosityBlocks() const = 0;
83  virtual bool hasAcquire() const = 0;
84  virtual bool hasAccumulator() const = 0;
85  bool wantsStreamRuns() const { return true; }
86  bool wantsStreamLuminosityBlocks() const { return true; }
87 
89 
90  void itemsToGet(BranchType, std::vector<ProductResolverIndexAndSkipBit>&) const;
91  void itemsMayGet(BranchType, std::vector<ProductResolverIndexAndSkipBit>&) const;
92  std::vector<ProductResolverIndexAndSkipBit> const& itemsToGetFrom(BranchType) const;
93 
94  void updateLookup(BranchType iBranchType, ProductResolverIndexHelper const&, bool iPrefetchMayGet);
95  void updateLookup(eventsetup::ESRecordsToProxyIndices const&);
96 
97  void modulesWhoseProductsAreConsumed(std::vector<ModuleDescription const*>& modules,
98  ProductRegistry const& preg,
99  std::map<std::string, ModuleDescription const*> const& labelsToDesc,
100  std::string const& processName) const;
101 
102  void convertCurrentProcessAlias(std::string const& processName);
103 
104  std::vector<ConsumesInfo> consumesInfo() const;
105 
107  std::unordered_multimap<std::string, std::tuple<edm::TypeID const*, const char*, edm::ProductResolverIndex>>;
108 
109  void resolvePutIndicies(BranchType iBranchType,
110  ModuleToResolverIndicies const& iIndicies,
111  std::string const& moduleLabel);
112 
113  std::vector<edm::ProductResolverIndex> const& indiciesForPutProducts(BranchType iBranchType) const;
114 
115  protected:
116  template <typename F>
117  void createStreamModules(F iFunc) {
118  for (auto& m : m_streamModules) {
119  m = iFunc();
120  m->setModuleDescriptionPtr(&moduleDescription_);
121  }
122  }
123 
124  void commit(Run& iRun) { iRun.commit_(m_streamModules[0]->indiciesForPutProducts(InRun)); }
125  void commit(LuminosityBlock& iLumi) { iLumi.commit_(m_streamModules[0]->indiciesForPutProducts(InLumi)); }
126  template <typename I>
127  void commit(Event& iEvent, I* iID) {
128  iEvent.commit_(m_streamModules[0]->indiciesForPutProducts(InEvent), iID);
129  }
130 
131  const EDConsumerBase* consumer() { return m_streamModules[0]; }
132 
133  const ProducerBase* producer() { return m_streamModules[0]; }
134 
135  private:
136  ProducingModuleAdaptorBase(const ProducingModuleAdaptorBase&) = delete; // stop default
137 
138  const ProducingModuleAdaptorBase& operator=(const ProducingModuleAdaptorBase&) = delete; // stop default
139 
140  void doPreallocate(PreallocationConfiguration const&);
141  virtual void preallocLumis(unsigned int) {}
142  virtual void setupStreamModules() = 0;
143  void doBeginJob();
144  virtual void doEndJob() = 0;
145 
146  void doBeginStream(StreamID id);
147  void doEndStream(StreamID id);
148  void doStreamBeginRun(StreamID id, RunPrincipal const& ep, EventSetupImpl const& c, ModuleCallingContext const*);
149  virtual void setupRun(T*, RunIndex) = 0;
150  void doStreamEndRun(StreamID id, RunPrincipal const& ep, EventSetupImpl const& c, ModuleCallingContext const*);
151  virtual void streamEndRunSummary(T*, edm::Run const&, edm::EventSetup const&) = 0;
152 
153  void doStreamBeginLuminosityBlock(StreamID id,
154  LuminosityBlockPrincipal const& ep,
155  EventSetupImpl const& c,
156  ModuleCallingContext const*);
157  virtual void setupLuminosityBlock(T*, LuminosityBlockIndex) = 0;
158  void doStreamEndLuminosityBlock(StreamID id,
159  LuminosityBlockPrincipal const& ep,
160  EventSetupImpl const& c,
161  ModuleCallingContext const*);
162  virtual void streamEndLuminosityBlockSummary(T*, edm::LuminosityBlock const&, edm::EventSetup const&) = 0;
163 
164  virtual void doBeginRun(RunPrincipal const& rp, EventSetupImpl const& c, ModuleCallingContext const*) = 0;
165  virtual void doEndRun(RunPrincipal const& rp, EventSetupImpl const& c, ModuleCallingContext const*) = 0;
166  virtual void doBeginLuminosityBlock(LuminosityBlockPrincipal const& lbp,
167  EventSetupImpl const& c,
168  ModuleCallingContext const*) = 0;
169  virtual void doEndLuminosityBlock(LuminosityBlockPrincipal const& lbp,
170  EventSetupImpl const& c,
171  ModuleCallingContext const*) = 0;
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&, ThinnedAssociationsHelper&);
177 
178  // ---------- member data --------------------------------
179  void setModuleDescription(ModuleDescription const& md) { moduleDescription_ = md; }
181 
182  protected:
183  std::vector<T*> m_streamModules;
184  };
185  } // namespace stream
186 } // namespace edm
187 
188 #endif
std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >> ModuleToResolverIndicies
void registerProductsAndCallbacks(ProductRegistry *iReg) override
Definition: ModuleHolder.h:70
BranchType
Definition: BranchType.h:11
int iEvent
Definition: GenABIO.cc:224
void commit_(std::vector< edm::ProductResolverIndex > const &iShouldPut)
Definition: Run.cc:76
void setModuleDescription(ModuleDescription const &md)
void commit_(std::vector< edm::ProductResolverIndex > const &iShouldPut, ParentageID *previousParentageId=0)
Definition: Event.cc:137
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:45