test
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
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;
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 {
72  }
73  virtual void doStreamEndLuminosityBlock_(StreamID id, LuminosityBlock const& lbp, EventSetup const& c) override final {
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;
94  protected:
95  C const* runCache(edm::RunIndex iID) const { return cache_.get(); }
96  private:
97  void doBeginRun_(Run const& rp, EventSetup const& c) override final {
98  cache_ = globalBeginRun(rp,c);
99  }
100  void doEndRun_(Run const& rp, EventSetup const& c) override final {
101  globalEndRun(rp,c);
102  cache_ = nullptr; // propagate_const<T> has no reset() function
103  }
104 
105  virtual std::shared_ptr<C> globalBeginRun(edm::Run const&, edm::EventSetup const&) const = 0;
106  virtual void globalEndRun(edm::Run const&, edm::EventSetup const&) const = 0;
107  //When threaded we will have a container for N items whre N is # of simultaneous runs
109  };
110 
111  template <typename T, typename C>
112  class LuminosityBlockCacheHolder : public virtual T {
113  public:
114  LuminosityBlockCacheHolder() = default;
117  protected:
118  C const* luminosityBlockCache(edm::LuminosityBlockIndex iID) const { return cache_.get(); }
119  private:
120  void doBeginLuminosityBlock_(LuminosityBlock const& rp, EventSetup const& c) override final {
122  }
123  void doEndLuminosityBlock_(LuminosityBlock const& rp, EventSetup const& c) override final {
125  cache_.reset();
126  }
127 
128  virtual std::shared_ptr<C> globalBeginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) const = 0;
129  virtual void globalEndLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) const = 0;
130  //When threaded we will have a container for N items whre N is # of simultaneous runs
131  std::shared_ptr<C> cache_;
132  };
133 
134  template<typename T, typename C> class EndRunSummaryProducer;
135 
136  template <typename T, typename C>
137  class RunSummaryCacheHolder : public virtual T {
138  public:
139  RunSummaryCacheHolder() = default;
142  private:
143  friend class EndRunSummaryProducer<T,C>;
144  void doBeginRunSummary_(edm::Run const& rp, EventSetup const& c) override final {
146  }
147  void doStreamEndRunSummary_(StreamID id, Run const& rp, EventSetup const& c) override final {
148  //NOTE: in future this will need to be serialized
149  streamEndRunSummary(id,rp,c,cache_.get());
150  }
151  void doEndRunSummary_(Run const& rp, EventSetup const& c) override final {
152  globalEndRunSummary(rp,c,cache_.get());
153  }
154 
155  virtual std::shared_ptr<C> globalBeginRunSummary(edm::Run const&, edm::EventSetup const&) const = 0;
156  virtual void streamEndRunSummary(StreamID, edm::Run const&, edm::EventSetup const&, C*) const = 0;
157 
158  virtual void globalEndRunSummary(edm::Run const&, edm::EventSetup const&, C*) const = 0;
159 
160  //When threaded we will have a container for N items where N is # of simultaneous runs
161  std::shared_ptr<C> cache_;
162  };
163 
164  template<typename T, typename C> class EndLuminosityBlockSummaryProducer;
165 
166 
167  template <typename T, typename C>
168  class LuminosityBlockSummaryCacheHolder : public virtual T {
169  public:
173  private:
175 
176  void doBeginLuminosityBlockSummary_(edm::LuminosityBlock const& lb, EventSetup const& c) override final {
178  }
179 
180  virtual void doStreamEndLuminosityBlockSummary_(StreamID id, LuminosityBlock const& lb, EventSetup const& c) override final
181  {
183  }
184  void doEndLuminosityBlockSummary_(LuminosityBlock const& lb, EventSetup const& c) override final {
186  }
187 
188  virtual std::shared_ptr<C> globalBeginLuminosityBlockSummary(edm::LuminosityBlock const&, edm::EventSetup const&) const = 0;
189  virtual void streamEndLuminosityBlockSummary(StreamID, edm::LuminosityBlock const&, edm::EventSetup const&, C*) const = 0;
190 
191  virtual void globalEndLuminosityBlockSummary(edm::LuminosityBlock const&, edm::EventSetup const&, C*) const = 0;
192 
193  //When threaded we will have a container for N items where N is # of simultaneous Lumis
194  std::shared_ptr<C> cache_;
195  };
196 
197 
198  template <typename T>
199  class BeginRunProducer : public virtual T {
200  public:
201  BeginRunProducer() = default;
202  BeginRunProducer( BeginRunProducer const&) = delete;
203  BeginRunProducer& operator=(BeginRunProducer const&) = delete;
204 
205  private:
206  void doBeginRunProduce_(Run& rp, EventSetup const& c) override final;
207 
208  virtual void globalBeginRunProduce(edm::Run&, edm::EventSetup const&) const = 0;
209  };
210 
211  template <typename T>
212  class EndRunProducer : public virtual T {
213  public:
214  EndRunProducer() = default;
215  EndRunProducer( EndRunProducer const&) = delete;
216  EndRunProducer& operator=(EndRunProducer const&) = delete;
217 
218  private:
219 
220  void doEndRunProduce_(Run& rp, EventSetup const& c) override final;
221 
222  virtual void globalEndRunProduce(edm::Run&, edm::EventSetup const&) const = 0;
223  };
224 
225  template <typename T, typename C>
226  class EndRunSummaryProducer : public RunSummaryCacheHolder<T,C> {
227  public:
228  EndRunSummaryProducer() = default;
231 
232  private:
233 
234  void doEndRunProduce_(Run& rp, EventSetup const& c) override final {
236  }
237 
238  virtual void globalEndRunProduce(edm::Run&, edm::EventSetup const&, C const*) const = 0;
239  };
240 
241  template <typename T>
242  class BeginLuminosityBlockProducer : public virtual T {
243  public:
244  BeginLuminosityBlockProducer() = default;
247 
248  private:
249  void doBeginLuminosityBlockProduce_(LuminosityBlock& lb, EventSetup const& c) override final;
251  };
252 
253  template <typename T>
254  class EndLuminosityBlockProducer : public virtual T {
255  public:
256  EndLuminosityBlockProducer() = default;
259 
260  private:
261  void doEndLuminosityBlockProduce_(LuminosityBlock& lb, EventSetup const& c) override final;
263  };
264 
265  template <typename T, typename S>
267  public:
271 
272  private:
273  void doEndLuminosityBlockProduce_(LuminosityBlock& lb, EventSetup const& c) override final {
275  }
276 
277  virtual void globalEndLuminosityBlockProduce(edm::LuminosityBlock&, edm::EventSetup const&, S const*) const = 0;
278  };
279  }
280  }
281 }
282 
283 
284 #endif
void doEndLuminosityBlock_(LuminosityBlock const &rp, EventSetup const &c) overridefinal
Definition: implementors.h:123
virtual void doBeginStream_(StreamID id) overridefinal
Definition: implementors.h:56
void doEndLuminosityBlockProduce_(LuminosityBlock &lb, EventSetup const &c) overridefinal
void doStreamEndRunSummary_(StreamID id, Run const &rp, EventSetup const &c) overridefinal
Definition: implementors.h:147
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:81
virtual void endStream(edm::StreamID) const
Definition: implementors.h:82
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:97
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:59
virtual void doStreamBeginLuminosityBlock_(StreamID id, LuminosityBlock const &lbp, EventSetup const &c) overridefinal
Definition: implementors.h:70
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:78
void doEndLuminosityBlockSummary_(LuminosityBlock const &lb, EventSetup const &c) overridefinal
Definition: implementors.h:184
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:53
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:120
void doBeginRunSummary_(edm::Run const &rp, EventSetup const &c) overridefinal
Definition: implementors.h:144
edm::propagate_const< std::shared_ptr< C > > cache_
Definition: implementors.h:108
void doBeginRunProduce_(Run &rp, EventSetup const &c) overridefinal
virtual void streamEndLuminosityBlock(edm::StreamID, edm::LuminosityBlock const &, edm::EventSetup const &) const
Definition: implementors.h:80
void doEndRun_(Run const &rp, EventSetup const &c) overridefinal
Definition: implementors.h:100
BeginLuminosityBlockProducer & operator=(BeginLuminosityBlockProducer const &)=delete
virtual std::shared_ptr< C > globalBeginRunSummary(edm::Run const &, edm::EventSetup const &) const =0
element_type const * get() const
virtual void doStreamEndRun_(StreamID id, Run const &rp, EventSetup const &c) overridefinal
Definition: implementors.h:67
void doEndRunProduce_(Run &rp, EventSetup const &c) overridefinal
Definition: implementors.h:234
C const * runCache(edm::RunIndex iID) const
Definition: implementors.h:95
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:79
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:118
void doEndRunSummary_(Run const &rp, EventSetup const &c) overridefinal
Definition: implementors.h:151
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:64
LuminosityBlockCacheHolder< T, C > & operator=(LuminosityBlockCacheHolder< T, C > const &)=delete
C * streamCache(edm::StreamID iID) const
Definition: implementors.h:51
void doBeginLuminosityBlockProduce_(LuminosityBlock &lb, EventSetup const &c) overridefinal
virtual void doStreamEndLuminosityBlock_(StreamID id, LuminosityBlock const &lbp, EventSetup const &c) overridefinal
Definition: implementors.h:73
void doEndLuminosityBlockProduce_(LuminosityBlock &lb, EventSetup const &c) overridefinal
Definition: implementors.h:273
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:180
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:176
Definition: Run.h:43