CMS 3D CMS Logo

implementors.h
Go to the documentation of this file.
1 #ifndef FWCore_Framework_global_implementors_h
2 #define FWCore_Framework_global_implementors_h
3 // -*- C++ -*-
4 //
5 // Package: FWCore/Framework
6 // Class : implementors
7 //
16 //
17 // Original Author: Chris Jones
18 // Created: Thu, 18 Jul 2013 11:52:34 GMT
19 //
20 
21 // system include files
22 #include <memory>
23 
24 // user include files
30 
31 // forward declarations
32 namespace edm {
33 
34  namespace global {
35  namespace impl {
36  class EmptyType {};
37 
38 
39  template <typename T, typename C>
40  class StreamCacheHolder : public virtual T {
41  public:
42  StreamCacheHolder() = default;
43  StreamCacheHolder( StreamCacheHolder<T,C> const&) = delete;
44  StreamCacheHolder<T,C>& operator=(StreamCacheHolder<T,C> const&) = delete;
46  for(auto c: caches_){
47  delete c;
48  }
49  }
50  protected:
51  C * streamCache(edm::StreamID iID) const { return caches_[iID.value()]; }
52  private:
53  virtual void preallocStreams(unsigned int iNStreams) override final {
54  caches_.resize(iNStreams,static_cast<C*>(nullptr));
55  }
56  virtual void doBeginStream_(StreamID id) override final {
57  caches_[id.value()] = beginStream(id).release();
58  }
59  virtual void doEndStream_(StreamID id) override final {
60  endStream(id);
61  delete caches_[id.value()];
62  caches_[id.value()]=nullptr;
63  }
64  virtual void doStreamBeginRun_(StreamID id, Run const& rp, EventSetup const& c) override final {
65  streamBeginRun(id,rp,c);
66  }
67  virtual void doStreamEndRun_(StreamID id, Run const& rp, EventSetup const& c) override final {
68  streamEndRun(id,rp,c);
69  }
70  virtual void doStreamBeginLuminosityBlock_(StreamID id, LuminosityBlock const& lbp, EventSetup const& c) override final {
71  streamBeginLuminosityBlock(id,lbp,c);
72  }
73  virtual void doStreamEndLuminosityBlock_(StreamID id, LuminosityBlock const& lbp, EventSetup const& c) override final {
74  streamEndLuminosityBlock(id,lbp,c);
75  }
76 
77  virtual std::unique_ptr<C> beginStream(edm::StreamID) const = 0;
78  virtual void streamBeginRun(edm::StreamID, edm::Run const&, edm::EventSetup const&) const {}
81  virtual void streamEndRun(edm::StreamID, edm::Run const&, edm::EventSetup const&) const {}
82  virtual void endStream(edm::StreamID) const {}
83 
84  //When threaded we will have a container for N items whre N is # of streams
85  std::vector<C*> caches_;
86  };
87 
88  template <typename T, typename C>
89  class RunCacheHolder : public virtual T {
90  public:
91  RunCacheHolder() = default;
92  RunCacheHolder( RunCacheHolder<T,C> const&) = delete;
93  RunCacheHolder<T,C>& operator=(RunCacheHolder<T,C> const&) = delete;
95  protected:
96  C const* runCache(edm::RunIndex iID) const { return cache_.get(); }
97  private:
98  void doBeginRun_(Run const& rp, EventSetup const& c) override final {
99  cache_ = globalBeginRun(rp,c);
100  }
101  void doEndRun_(Run const& rp, EventSetup const& c) override final {
102  globalEndRun(rp,c);
103  cache_ = nullptr; // propagate_const<T> has no reset() function
104  }
105 
106  virtual std::shared_ptr<C> globalBeginRun(edm::Run const&, edm::EventSetup const&) const = 0;
107  virtual void globalEndRun(edm::Run const&, edm::EventSetup const&) const = 0;
108  //When threaded we will have a container for N items whre N is # of simultaneous runs
110  };
111 
112  template <typename T, typename C>
113  class LuminosityBlockCacheHolder : public virtual T {
114  public:
115  LuminosityBlockCacheHolder() = default;
119  protected:
120  C const* luminosityBlockCache(edm::LuminosityBlockIndex iID) const { return cache_.get(); }
121  private:
122  void doBeginLuminosityBlock_(LuminosityBlock const& rp, EventSetup const& c) override final {
123  cache_ = globalBeginLuminosityBlock(rp,c);
124  }
125  void doEndLuminosityBlock_(LuminosityBlock const& rp, EventSetup const& c) override final {
126  globalEndLuminosityBlock(rp,c);
127  cache_.reset();
128  }
129 
130  virtual std::shared_ptr<C> globalBeginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) const = 0;
131  virtual void globalEndLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) const = 0;
132  //When threaded we will have a container for N items whre N is # of simultaneous runs
133  std::shared_ptr<C> cache_;
134  };
135 
136  template<typename T, typename C> class EndRunSummaryProducer;
137 
138  template <typename T, typename C>
139  class RunSummaryCacheHolder : public virtual T {
140  public:
141  RunSummaryCacheHolder() = default;
143  RunSummaryCacheHolder<T,C>& operator=(RunSummaryCacheHolder<T,C> const&) = delete;
145  private:
146  friend class EndRunSummaryProducer<T,C>;
147  void doBeginRunSummary_(edm::Run const& rp, EventSetup const& c) override final {
148  cache_ = globalBeginRunSummary(rp,c);
149  }
150  void doStreamEndRunSummary_(StreamID id, Run const& rp, EventSetup const& c) override final {
151  //NOTE: in future this will need to be serialized
152  streamEndRunSummary(id,rp,c,cache_.get());
153  }
154  void doEndRunSummary_(Run const& rp, EventSetup const& c) override final {
155  globalEndRunSummary(rp,c,cache_.get());
156  }
157 
158  virtual std::shared_ptr<C> globalBeginRunSummary(edm::Run const&, edm::EventSetup const&) const = 0;
159  virtual void streamEndRunSummary(StreamID, edm::Run const&, edm::EventSetup const&, C*) const = 0;
160 
161  virtual void globalEndRunSummary(edm::Run const&, edm::EventSetup const&, C*) const = 0;
162 
163  //When threaded we will have a container for N items where N is # of simultaneous runs
164  std::shared_ptr<C> cache_;
165  };
166 
167  template<typename T, typename C> class EndLuminosityBlockSummaryProducer;
168 
169 
170  template <typename T, typename C>
171  class LuminosityBlockSummaryCacheHolder : public virtual T {
172  public:
177  private:
178  friend class EndLuminosityBlockSummaryProducer<T,C>;
179 
180  void doBeginLuminosityBlockSummary_(edm::LuminosityBlock const& lb, EventSetup const& c) override final {
181  cache_ = globalBeginLuminosityBlockSummary(lb,c);
182  }
183 
184  virtual void doStreamEndLuminosityBlockSummary_(StreamID id, LuminosityBlock const& lb, EventSetup const& c) override final
185  {
186  streamEndLuminosityBlockSummary(id,lb,c,cache_.get());
187  }
188  void doEndLuminosityBlockSummary_(LuminosityBlock const& lb, EventSetup const& c) override final {
189  globalEndLuminosityBlockSummary(lb,c,cache_.get());
190  }
191 
192  virtual std::shared_ptr<C> globalBeginLuminosityBlockSummary(edm::LuminosityBlock const&, edm::EventSetup const&) const = 0;
193  virtual void streamEndLuminosityBlockSummary(StreamID, edm::LuminosityBlock const&, edm::EventSetup const&, C*) const = 0;
194 
195  virtual void globalEndLuminosityBlockSummary(edm::LuminosityBlock const&, edm::EventSetup const&, C*) const = 0;
196 
197  //When threaded we will have a container for N items where N is # of simultaneous Lumis
198  std::shared_ptr<C> cache_;
199  };
200 
201 
202  template <typename T>
203  class BeginRunProducer : public virtual T {
204  public:
205  BeginRunProducer() = default;
206  BeginRunProducer( BeginRunProducer const&) = delete;
207  BeginRunProducer& operator=(BeginRunProducer const&) = delete;
209 
210  private:
211  void doBeginRunProduce_(Run& rp, EventSetup const& c) override final;
212 
213  virtual void globalBeginRunProduce(edm::Run&, edm::EventSetup const&) const = 0;
214  };
215 
216  template <typename T>
217  class EndRunProducer : public virtual T {
218  public:
219  EndRunProducer() = default;
220  EndRunProducer( EndRunProducer const&) = delete;
221  EndRunProducer& operator=(EndRunProducer const&) = delete;
223 
224  private:
225 
226  void doEndRunProduce_(Run& rp, EventSetup const& c) override final;
227 
228  virtual void globalEndRunProduce(edm::Run&, edm::EventSetup const&) const = 0;
229  };
230 
231  template <typename T, typename C>
232  class EndRunSummaryProducer : public RunSummaryCacheHolder<T,C> {
233  public:
234  EndRunSummaryProducer() = default;
236  EndRunSummaryProducer& operator=(EndRunSummaryProducer const&) = delete;
238 
239  private:
240 
241  void doEndRunProduce_(Run& rp, EventSetup const& c) override final {
242  globalEndRunProduce(rp,c,RunSummaryCacheHolder<T,C>::cache_.get());
243  }
244 
245  virtual void globalEndRunProduce(edm::Run&, edm::EventSetup const&, C const*) const = 0;
246  };
247 
248  template <typename T>
249  class BeginLuminosityBlockProducer : public virtual T {
250  public:
251  BeginLuminosityBlockProducer() = default;
255 
256  private:
257  void doBeginLuminosityBlockProduce_(LuminosityBlock& lb, EventSetup const& c) override final;
258  virtual void globalBeginLuminosityBlockProduce(edm::LuminosityBlock&, edm::EventSetup const&) const = 0;
259  };
260 
261  template <typename T>
262  class EndLuminosityBlockProducer : public virtual T {
263  public:
264  EndLuminosityBlockProducer() = default;
266  EndLuminosityBlockProducer& operator=(EndLuminosityBlockProducer const&) = delete;
268 
269  private:
270  void doEndLuminosityBlockProduce_(LuminosityBlock& lb, EventSetup const& c) override final;
271  virtual void globalEndLuminosityBlockProduce(edm::LuminosityBlock&, edm::EventSetup const&) const = 0;
272  };
273 
274  template <typename T, typename S>
276  public:
281 
282  private:
283  void doEndLuminosityBlockProduce_(LuminosityBlock& lb, EventSetup const& c) override final {
284  globalEndLuminosityBlockProduce(lb,c,LuminosityBlockSummaryCacheHolder<T,S>::cache_.get());
285  }
286 
287  virtual void globalEndLuminosityBlockProduce(edm::LuminosityBlock&, edm::EventSetup const&, S const*) const = 0;
288  };
289  }
290  }
291 }
292 
293 
294 #endif
void doEndLuminosityBlock_(LuminosityBlock const &rp, EventSetup const &c) override final
Definition: implementors.h:125
void doBeginRunSummary_(edm::Run const &rp, EventSetup const &c) override final
Definition: implementors.h:147
virtual void streamEndRun(edm::StreamID, edm::Run const &, edm::EventSetup const &) const
Definition: implementors.h:81
virtual void endStream(edm::StreamID) const
Definition: implementors.h:82
void doEndLuminosityBlockSummary_(LuminosityBlock const &lb, EventSetup const &c) override final
Definition: implementors.h:188
void doEndRunProduce_(Run &rp, EventSetup const &c) override final
Definition: implementors.h:241
#define noexcept
virtual void doStreamEndLuminosityBlockSummary_(StreamID id, LuminosityBlock const &lb, EventSetup const &c) override final
Definition: implementors.h:184
~RunCacheHolder() noexcept(false)
Definition: implementors.h:94
void doBeginLuminosityBlock_(LuminosityBlock const &rp, EventSetup const &c) override final
Definition: implementors.h:122
virtual void streamBeginRun(edm::StreamID, edm::Run const &, edm::EventSetup const &) const
Definition: implementors.h:78
virtual void preallocStreams(unsigned int iNStreams) override final
Definition: implementors.h:53
void doStreamEndRunSummary_(StreamID id, Run const &rp, EventSetup const &c) override final
Definition: implementors.h:150
virtual void doStreamEndLuminosityBlock_(StreamID id, LuminosityBlock const &lbp, EventSetup const &c) override final
Definition: implementors.h:73
edm::propagate_const< std::shared_ptr< C > > cache_
Definition: implementors.h:109
virtual void doStreamEndRun_(StreamID id, Run const &rp, EventSetup const &c) override final
Definition: implementors.h:67
virtual void streamEndLuminosityBlock(edm::StreamID, edm::LuminosityBlock const &, edm::EventSetup const &) const
Definition: implementors.h:80
C const * runCache(edm::RunIndex iID) const
Definition: implementors.h:96
virtual void streamBeginLuminosityBlock(edm::StreamID, edm::LuminosityBlock const &, edm::EventSetup const &) const
Definition: implementors.h:79
unsigned int value() const
Definition: StreamID.h:46
void doEndLuminosityBlockProduce_(LuminosityBlock &lb, EventSetup const &c) override final
Definition: implementors.h:283
double S(const TLorentzVector &, const TLorentzVector &)
Definition: Particle.cc:99
C const * luminosityBlockCache(edm::LuminosityBlockIndex iID) const
Definition: implementors.h:120
virtual void doBeginStream_(StreamID id) override final
Definition: implementors.h:56
HLT enums.
C * streamCache(edm::StreamID iID) const
Definition: implementors.h:51
virtual void doEndStream_(StreamID id) override final
Definition: implementors.h:59
void doEndRun_(Run const &rp, EventSetup const &c) override final
Definition: implementors.h:101
void doBeginLuminosityBlockSummary_(edm::LuminosityBlock const &lb, EventSetup const &c) override final
Definition: implementors.h:180
virtual void doStreamBeginLuminosityBlock_(StreamID id, LuminosityBlock const &lbp, EventSetup const &c) override final
Definition: implementors.h:70
void doBeginRun_(Run const &rp, EventSetup const &c) override final
Definition: implementors.h:98
void doEndRunSummary_(Run const &rp, EventSetup const &c) override final
Definition: implementors.h:154
long double T
Definition: Run.h:42
virtual void doStreamBeginRun_(StreamID id, Run const &rp, EventSetup const &c) override final
Definition: implementors.h:64