CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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
29 
30 // forward declarations
31 namespace edm {
32 
33  namespace global {
34  namespace impl {
35  class EmptyType {};
36 
37 
38  template <typename T, typename C>
39  class StreamCacheHolder : public virtual T {
40  public:
41  StreamCacheHolder() = default;
42  StreamCacheHolder( StreamCacheHolder<T,C> const&) = delete;
45  for(auto c: caches_){
46  delete c;
47  }
48  }
49  protected:
50  C * streamCache(edm::StreamID iID) const { return caches_[iID.value()]; }
51  private:
52  virtual void preallocStreams(unsigned int iNStreams) override final {
53  caches_.resize(iNStreams,static_cast<C*>(nullptr));
54  }
55  virtual void doBeginStream_(StreamID id) override final {
56  caches_[id.value()] = beginStream(id).release();
57  }
58  virtual void doEndStream_(StreamID id) override final {
59  endStream(id);
60  delete caches_[id.value()];
61  caches_[id.value()]=nullptr;
62  }
63  virtual void doStreamBeginRun_(StreamID id, Run const& rp, EventSetup const& c) override final {
64  streamBeginRun(id,rp,c);
65  }
66  virtual void doStreamEndRun_(StreamID id, Run const& rp, EventSetup const& c) override final {
67  streamEndRun(id,rp,c);
68  }
69  virtual void doStreamBeginLuminosityBlock_(StreamID id, LuminosityBlock const& lbp, EventSetup const& c) override final {
71  }
72  virtual void doStreamEndLuminosityBlock_(StreamID id, LuminosityBlock const& lbp, EventSetup const& c) override final {
74  }
75 
76  virtual std::unique_ptr<C> beginStream(edm::StreamID) const = 0;
77  virtual void streamBeginRun(edm::StreamID, edm::Run const&, edm::EventSetup const&) const {}
80  virtual void streamEndRun(edm::StreamID, edm::Run const&, edm::EventSetup const&) const {}
81  virtual void endStream(edm::StreamID) const {}
82 
83  //When threaded we will have a container for N items whre N is # of streams
84  std::vector<C*> caches_;
85  };
86 
87  template <typename T, typename C>
88  class RunCacheHolder : public virtual T {
89  public:
90  RunCacheHolder() = default;
91  RunCacheHolder( RunCacheHolder<T,C> const&) = delete;
93  protected:
94  C const* runCache(edm::RunIndex iID) const { return cache_.get(); }
95  private:
96  void doBeginRun_(Run const& rp, EventSetup const& c) override final {
97  cache_ = globalBeginRun(rp,c);
98  }
99  void doEndRun_(Run const& rp, EventSetup const& c) override final {
100  globalEndRun(rp,c);
101  cache_.reset();
102  }
103 
104  virtual std::shared_ptr<C> globalBeginRun(edm::Run const&, edm::EventSetup const&) const = 0;
105  virtual void globalEndRun(edm::Run const&, edm::EventSetup const&) const = 0;
106  //When threaded we will have a container for N items whre N is # of simultaneous runs
107  std::shared_ptr<C> cache_;
108  };
109 
110  template <typename T, typename C>
111  class LuminosityBlockCacheHolder : public virtual T {
112  public:
113  LuminosityBlockCacheHolder() = default;
116  protected:
117  C const* luminosityBlockCache(edm::LuminosityBlockIndex iID) const { return cache_.get(); }
118  private:
119  void doBeginLuminosityBlock_(LuminosityBlock const& rp, EventSetup const& c) override final {
121  }
122  void doEndLuminosityBlock_(LuminosityBlock const& rp, EventSetup const& c) override final {
124  cache_.reset();
125  }
126 
127  virtual std::shared_ptr<C> globalBeginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) const = 0;
128  virtual void globalEndLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) const = 0;
129  //When threaded we will have a container for N items whre N is # of simultaneous runs
130  std::shared_ptr<C> cache_;
131  };
132 
133  template<typename T, typename C> class EndRunSummaryProducer;
134 
135  template <typename T, typename C>
136  class RunSummaryCacheHolder : public virtual T {
137  public:
138  RunSummaryCacheHolder() = default;
141  private:
142  friend class EndRunSummaryProducer<T,C>;
143  void doBeginRunSummary_(edm::Run const& rp, EventSetup const& c) override final {
145  }
146  void doStreamEndRunSummary_(StreamID id, Run const& rp, EventSetup const& c) override final {
147  //NOTE: in future this will need to be serialized
148  streamEndRunSummary(id,rp,c,cache_.get());
149  }
150  void doEndRunSummary_(Run const& rp, EventSetup const& c) override final {
151  globalEndRunSummary(rp,c,cache_.get());
152  }
153 
154  virtual std::shared_ptr<C> globalBeginRunSummary(edm::Run const&, edm::EventSetup const&) const = 0;
155  virtual void streamEndRunSummary(StreamID, edm::Run const&, edm::EventSetup const&, C*) const = 0;
156 
157  virtual void globalEndRunSummary(edm::Run const&, edm::EventSetup const&, C*) const = 0;
158 
159  //When threaded we will have a container for N items where N is # of simultaneous runs
160  std::shared_ptr<C> cache_;
161  };
162 
163  template<typename T, typename C> class EndLuminosityBlockSummaryProducer;
164 
165 
166  template <typename T, typename C>
167  class LuminosityBlockSummaryCacheHolder : public virtual T {
168  public:
172  private:
174 
175  void doBeginLuminosityBlockSummary_(edm::LuminosityBlock const& lb, EventSetup const& c) override final {
177  }
178 
179  virtual void doStreamEndLuminosityBlockSummary_(StreamID id, LuminosityBlock const& lb, EventSetup const& c) override final
180  {
182  }
183  void doEndLuminosityBlockSummary_(LuminosityBlock const& lb, EventSetup const& c) override final {
185  }
186 
187  virtual std::shared_ptr<C> globalBeginLuminosityBlockSummary(edm::LuminosityBlock const&, edm::EventSetup const&) const = 0;
188  virtual void streamEndLuminosityBlockSummary(StreamID, edm::LuminosityBlock const&, edm::EventSetup const&, C*) const = 0;
189 
190  virtual void globalEndLuminosityBlockSummary(edm::LuminosityBlock const&, edm::EventSetup const&, C*) const = 0;
191 
192  //When threaded we will have a container for N items where N is # of simultaneous Lumis
193  std::shared_ptr<C> cache_;
194  };
195 
196 
197  template <typename T>
198  class BeginRunProducer : public virtual T {
199  public:
200  BeginRunProducer() = default;
201  BeginRunProducer( BeginRunProducer const&) = delete;
202  BeginRunProducer& operator=(BeginRunProducer const&) = delete;
203 
204  private:
205  void doBeginRunProduce_(Run& rp, EventSetup const& c) override final;
206 
207  virtual void globalBeginRunProduce(edm::Run&, edm::EventSetup const&) const = 0;
208  };
209 
210  template <typename T>
211  class EndRunProducer : public virtual T {
212  public:
213  EndRunProducer() = default;
214  EndRunProducer( EndRunProducer const&) = delete;
215  EndRunProducer& operator=(EndRunProducer const&) = delete;
216 
217  private:
218 
219  void doEndRunProduce_(Run& rp, EventSetup const& c) override final;
220 
221  virtual void globalEndRunProduce(edm::Run&, edm::EventSetup const&) const = 0;
222  };
223 
224  template <typename T, typename C>
225  class EndRunSummaryProducer : public RunSummaryCacheHolder<T,C> {
226  public:
227  EndRunSummaryProducer() = default;
230 
231  private:
232 
233  void doEndRunProduce_(Run& rp, EventSetup const& c) override final {
235  }
236 
237  virtual void globalEndRunProduce(edm::Run&, edm::EventSetup const&, C const*) const = 0;
238  };
239 
240  template <typename T>
241  class BeginLuminosityBlockProducer : public virtual T {
242  public:
243  BeginLuminosityBlockProducer() = default;
246 
247  private:
248  void doBeginLuminosityBlockProduce_(LuminosityBlock& lb, EventSetup const& c) override final;
250  };
251 
252  template <typename T>
253  class EndLuminosityBlockProducer : public virtual T {
254  public:
255  EndLuminosityBlockProducer() = default;
258 
259  private:
260  void doEndLuminosityBlockProduce_(LuminosityBlock& lb, EventSetup const& c) override final;
262  };
263 
264  template <typename T, typename S>
266  public:
270 
271  private:
272  void doEndLuminosityBlockProduce_(LuminosityBlock& lb, EventSetup const& c) override final {
274  }
275 
276  virtual void globalEndLuminosityBlockProduce(edm::LuminosityBlock&, edm::EventSetup const&, S const*) const = 0;
277  };
278  }
279  }
280 }
281 
282 
283 #endif
void doEndLuminosityBlock_(LuminosityBlock const &rp, EventSetup const &c) overridefinal
Definition: implementors.h:122
virtual void doBeginStream_(StreamID id) overridefinal
Definition: implementors.h:55
void doEndLuminosityBlockProduce_(LuminosityBlock &lb, EventSetup const &c) overridefinal
void doStreamEndRunSummary_(StreamID id, Run const &rp, EventSetup const &c) overridefinal
Definition: implementors.h:146
RunCacheHolder< T, C > & operator=(RunCacheHolder< T, C > const &)=delete
virtual void globalEndRun(edm::Run const &, edm::EventSetup const &) const =0
virtual void streamEndRun(edm::StreamID, edm::Run const &, edm::EventSetup const &) const
Definition: implementors.h:80
virtual void endStream(edm::StreamID) const
Definition: implementors.h:81
LuminosityBlockSummaryCacheHolder< T, C > & operator=(LuminosityBlockSummaryCacheHolder< T, C > const &)=delete
virtual void globalBeginRunProduce(edm::Run &, edm::EventSetup const &) const =0
void doBeginRun_(Run const &rp, EventSetup const &c) overridefinal
Definition: implementors.h:96
virtual std::shared_ptr< C > globalBeginLuminosityBlockSummary(edm::LuminosityBlock const &, edm::EventSetup const &) const =0
virtual void globalEndRunProduce(edm::Run &, edm::EventSetup const &, C const *) const =0
virtual void doEndStream_(StreamID id) overridefinal
Definition: implementors.h:58
virtual void doStreamBeginLuminosityBlock_(StreamID id, LuminosityBlock const &lbp, EventSetup const &c) overridefinal
Definition: implementors.h:69
virtual void globalBeginLuminosityBlockProduce(edm::LuminosityBlock &, edm::EventSetup const &) const =0
virtual void streamEndRunSummary(StreamID, edm::Run const &, edm::EventSetup const &, C *) const =0
virtual std::unique_ptr< C > beginStream(edm::StreamID) const =0
virtual void streamBeginRun(edm::StreamID, edm::Run const &, edm::EventSetup const &) const
Definition: implementors.h:77
void doEndLuminosityBlockSummary_(LuminosityBlock const &lb, EventSetup const &c) overridefinal
Definition: implementors.h:183
EndRunProducer & operator=(EndRunProducer const &)=delete
virtual void globalEndLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) const =0
virtual void globalEndLuminosityBlockSummary(edm::LuminosityBlock const &, edm::EventSetup const &, C *) const =0
virtual void preallocStreams(unsigned int iNStreams) overridefinal
Definition: implementors.h:52
void doEndRunProduce_(Run &rp, EventSetup const &c) overridefinal
virtual std::shared_ptr< C > globalBeginRun(edm::Run const &, edm::EventSetup const &) const =0
EndRunSummaryProducer & operator=(EndRunSummaryProducer const &)=delete
EndLuminosityBlockProducer & operator=(EndLuminosityBlockProducer const &)=delete
RunSummaryCacheHolder< T, C > & operator=(RunSummaryCacheHolder< T, C > const &)=delete
virtual void streamEndLuminosityBlockSummary(StreamID, edm::LuminosityBlock const &, edm::EventSetup const &, C *) const =0
void doBeginLuminosityBlock_(LuminosityBlock const &rp, EventSetup const &c) overridefinal
Definition: implementors.h:119
void doBeginRunSummary_(edm::Run const &rp, EventSetup const &c) overridefinal
Definition: implementors.h:143
void doBeginRunProduce_(Run &rp, EventSetup const &c) overridefinal
virtual void streamEndLuminosityBlock(edm::StreamID, edm::LuminosityBlock const &, edm::EventSetup const &) const
Definition: implementors.h:79
void doEndRun_(Run const &rp, EventSetup const &c) overridefinal
Definition: implementors.h:99
BeginLuminosityBlockProducer & operator=(BeginLuminosityBlockProducer const &)=delete
virtual std::shared_ptr< C > globalBeginRunSummary(edm::Run const &, edm::EventSetup const &) const =0
virtual void doStreamEndRun_(StreamID id, Run const &rp, EventSetup const &c) overridefinal
Definition: implementors.h:66
void doEndRunProduce_(Run &rp, EventSetup const &c) overridefinal
Definition: implementors.h:233
C const * runCache(edm::RunIndex iID) const
Definition: implementors.h:94
virtual void globalEndRunProduce(edm::Run &, edm::EventSetup const &) const =0
virtual void streamBeginLuminosityBlock(edm::StreamID, edm::LuminosityBlock const &, edm::EventSetup const &) const
Definition: implementors.h:78
StreamCacheHolder< T, C > & operator=(StreamCacheHolder< T, C > const &)=delete
unsigned int value() const
Definition: StreamID.h:46
BeginRunProducer & operator=(BeginRunProducer const &)=delete
double S(const TLorentzVector &, const TLorentzVector &)
Definition: Particle.cc:99
C const * luminosityBlockCache(edm::LuminosityBlockIndex iID) const
Definition: implementors.h:117
void doEndRunSummary_(Run const &rp, EventSetup const &c) overridefinal
Definition: implementors.h:150
virtual void globalEndLuminosityBlockProduce(edm::LuminosityBlock &, edm::EventSetup const &, S const *) const =0
virtual void globalEndRunSummary(edm::Run const &, edm::EventSetup const &, C *) const =0
virtual void doStreamBeginRun_(StreamID id, Run const &rp, EventSetup const &c) overridefinal
Definition: implementors.h:63
LuminosityBlockCacheHolder< T, C > & operator=(LuminosityBlockCacheHolder< T, C > const &)=delete
C * streamCache(edm::StreamID iID) const
Definition: implementors.h:50
void doBeginLuminosityBlockProduce_(LuminosityBlock &lb, EventSetup const &c) overridefinal
virtual void doStreamEndLuminosityBlock_(StreamID id, LuminosityBlock const &lbp, EventSetup const &c) overridefinal
Definition: implementors.h:72
void doEndLuminosityBlockProduce_(LuminosityBlock &lb, EventSetup const &c) overridefinal
Definition: implementors.h:272
virtual void globalEndLuminosityBlockProduce(edm::LuminosityBlock &, edm::EventSetup const &) const =0
EndLuminosityBlockSummaryProducer & operator=(EndLuminosityBlockSummaryProducer const &)=delete
long double T
virtual void doStreamEndLuminosityBlockSummary_(StreamID id, LuminosityBlock const &lb, EventSetup const &c) overridefinal
Definition: implementors.h:179
virtual std::shared_ptr< C > globalBeginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) const =0
void doBeginLuminosityBlockSummary_(edm::LuminosityBlock const &lb, EventSetup const &c) overridefinal
Definition: implementors.h:175
Definition: Run.h:41