CMS 3D CMS Logo

implementors.h
Go to the documentation of this file.
1 #ifndef FWCore_Framework_one_implementors_h
2 #define FWCore_Framework_one_implementors_h
3 // -*- C++ -*-
4 //
5 // Package: FWCore/Framework
6 // Class : implementors
7 //
16 //
17 // Original Author: Chris Jones
18 // Created: Thu, 09 May 2013 18:40:17 GMT
19 //
20 
21 // system include files
22 #include <string>
23 #include <set>
24 
25 // user include files
32 
33 // forward declarations
34 
35 namespace edm {
37 
38  namespace one {
39  namespace impl {
40  template <bool V>
42 
43  template <>
45  edm::SerialTaskQueue* queue() { return &queue_; }
47  };
48 
49  template <>
51  edm::SerialTaskQueue* queue() { return nullptr; }
52  };
53 
54  template <typename T>
55  class SharedResourcesUser : public virtual T {
56  public:
57  template <typename... Args>
58  SharedResourcesUser(Args... args) : T(args...) {}
61 
62  ~SharedResourcesUser() override {}
63 
64  protected:
65  void usesResource(std::string const& iName);
66  void usesResource();
67 
68  private:
70  std::set<std::string> resourceNames_;
71  };
72 
73  template <typename T>
74  class RunWatcher : public virtual T {
75  public:
76  RunWatcher() = default;
77  RunWatcher(RunWatcher const&) = delete;
78  RunWatcher& operator=(RunWatcher const&) = delete;
79  ~RunWatcher() noexcept(false) override{};
80 
81  private:
82  void doBeginRun_(Run const& rp, EventSetup const& c) final;
83  void doEndRun_(Run const& rp, EventSetup const& c) final;
84 
85  virtual void beginRun(edm::Run const&, edm::EventSetup const&) = 0;
86  virtual void endRun(edm::Run const&, edm::EventSetup const&) = 0;
87  };
88 
89  template <typename T>
90  class LuminosityBlockWatcher : public virtual T {
91  public:
92  LuminosityBlockWatcher() = default;
95  ~LuminosityBlockWatcher() noexcept(false) override{};
96 
97  private:
98  void doBeginLuminosityBlock_(LuminosityBlock const& rp, EventSetup const& c) final;
99  void doEndLuminosityBlock_(LuminosityBlock const& rp, EventSetup const& c) final;
100 
101  virtual void beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) = 0;
102  virtual void endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) = 0;
103  };
104 
105  template <typename T>
106  class BeginRunProducer : public virtual T {
107  public:
108  BeginRunProducer() = default;
109  BeginRunProducer(BeginRunProducer const&) = delete;
110  BeginRunProducer& operator=(BeginRunProducer const&) = delete;
111  ~BeginRunProducer() noexcept(false) override{};
112 
113  private:
114  void doBeginRunProduce_(Run& rp, EventSetup const& c) final;
115 
116  virtual void beginRunProduce(edm::Run&, edm::EventSetup const&) = 0;
117  };
118 
119  template <typename T>
120  class EndRunProducer : public virtual T {
121  public:
122  EndRunProducer() = default;
123  EndRunProducer(EndRunProducer const&) = delete;
124  EndRunProducer& operator=(EndRunProducer const&) = delete;
125  ~EndRunProducer() noexcept(false) override{};
126 
127  private:
128  void doEndRunProduce_(Run& rp, EventSetup const& c) final;
129 
130  virtual void endRunProduce(edm::Run&, edm::EventSetup const&) = 0;
131  };
132 
133  template <typename T>
134  class BeginLuminosityBlockProducer : public virtual T {
135  public:
136  BeginLuminosityBlockProducer() = default;
139  ~BeginLuminosityBlockProducer() noexcept(false) override{};
140 
141  private:
143 
145  };
146 
147  template <typename T>
148  class EndLuminosityBlockProducer : public virtual T {
149  public:
150  EndLuminosityBlockProducer() = default;
153  ~EndLuminosityBlockProducer() noexcept(false) override{};
154 
155  private:
156  void doEndLuminosityBlockProduce_(LuminosityBlock& lbp, EventSetup const& c) final;
157 
159  };
160 
161  template <typename T, typename C>
162  class RunCacheHolder : public virtual T {
163  public:
164  RunCacheHolder() = default;
165  RunCacheHolder(RunCacheHolder<T, C> const&) = delete;
167  ~RunCacheHolder() noexcept(false) override{};
168 
169  protected:
170  C* runCache(edm::RunIndex iID) { return cache_.get(); }
171  C const* runCache(edm::RunIndex iID) const { return cache_.get(); }
172 
173  private:
174  void doBeginRun_(Run const& rp, EventSetup const& c) final { cache_ = globalBeginRun(rp, c); }
175  void doEndRun_(Run const& rp, EventSetup const& c) final {
176  globalEndRun(rp, c);
177  cache_ = nullptr; // propagate_const<T> has no reset() function
178  }
179 
180  virtual std::shared_ptr<C> globalBeginRun(edm::Run const&, edm::EventSetup const&) const = 0;
181  virtual void globalEndRun(edm::Run const&, edm::EventSetup const&) = 0;
182  //When threaded we will have a container for N items whre N is # of simultaneous runs
184  };
185 
186  template <typename T, typename C>
187  class LuminosityBlockCacheHolder : public virtual T {
188  public:
189  LuminosityBlockCacheHolder() = default;
192  ~LuminosityBlockCacheHolder() noexcept(false) override{};
193 
194  protected:
195  void preallocLumis(unsigned int iNLumis) final { caches_.reset(new std::shared_ptr<C>[iNLumis]); }
196 
197  C const* luminosityBlockCache(edm::LuminosityBlockIndex iID) const { return caches_[iID].get(); }
199 
200  private:
201  void doBeginLuminosityBlock_(LuminosityBlock const& lp, EventSetup const& c) final {
202  caches_[lp.index()] = globalBeginLuminosityBlock(lp, c);
203  }
204  void doEndLuminosityBlock_(LuminosityBlock const& lp, EventSetup const& c) final {
206  caches_[lp.index()].reset();
207  }
208 
209  virtual std::shared_ptr<C> globalBeginLuminosityBlock(edm::LuminosityBlock const&,
210  edm::EventSetup const&) const = 0;
211  virtual void globalEndLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) = 0;
212  std::unique_ptr<std::shared_ptr<C>[]> caches_;
213  };
214 
215  template <typename T>
216  class Accumulator : public virtual T {
217  public:
218  Accumulator() = default;
219  Accumulator(Accumulator const&) = delete;
220  Accumulator& operator=(Accumulator const&) = delete;
221  ~Accumulator() noexcept(false) override{};
222 
223  private:
224  bool hasAccumulator() const override { return true; }
225 
226  void produce(Event& ev, EventSetup const& es) final { accumulate(ev, es); }
227 
228  virtual void accumulate(Event const& ev, EventSetup const& es) = 0;
229  };
230  } // namespace impl
231  } // namespace one
232 } // namespace edm
233 
234 #endif
edm::one::impl::RunCacheHolder::doEndRun_
void doEndRun_(Run const &rp, EventSetup const &c) final
Definition: implementors.h:175
writedatasetfile.args
args
Definition: writedatasetfile.py:18
edm::SharedResourcesAcquirer
Definition: SharedResourcesAcquirer.h:34
edm::one::impl::RunCacheHolder
Definition: implementors.h:162
edm::one::impl::SharedResourcesUser::createAcquirer
SharedResourcesAcquirer createAcquirer() override
Definition: implementorsMethods.h:44
edm::one::impl::OptionalSerialTaskQueueHolder< true >::queue_
edm::SerialTaskQueue queue_
Definition: implementors.h:46
funct::false
false
Definition: Factorize.h:34
edm::one::impl::Accumulator::operator=
Accumulator & operator=(Accumulator const &)=delete
edm::one::impl::LuminosityBlockCacheHolder::preallocLumis
void preallocLumis(unsigned int iNLumis) final
Definition: implementors.h:195
edm::one::impl::LuminosityBlockCacheHolder::operator=
LuminosityBlockCacheHolder< T, C > & operator=(LuminosityBlockCacheHolder< T, C > const &)=delete
edm::one::impl::EndRunProducer::operator=
EndRunProducer & operator=(EndRunProducer const &)=delete
edm::one::impl::BeginRunProducer::~BeginRunProducer
~BeginRunProducer() noexcept(false) override
Definition: implementors.h:111
edm::one::impl::Accumulator::~Accumulator
~Accumulator() noexcept(false) override
Definition: implementors.h:221
propagate_const.h
edm::LuminosityBlock
Definition: LuminosityBlock.h:50
edm::one::impl::Accumulator::accumulate
virtual void accumulate(Event const &ev, EventSetup const &es)=0
edm::one::impl::BeginLuminosityBlockProducer::beginLuminosityBlockProduce
virtual void beginLuminosityBlockProduce(edm::LuminosityBlock &, edm::EventSetup const &)=0
edm::Run
Definition: Run.h:45
LuminosityBlock.h
edm::one::impl::BeginRunProducer::beginRunProduce
virtual void beginRunProduce(edm::Run &, edm::EventSetup const &)=0
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::one::impl::RunCacheHolder::~RunCacheHolder
~RunCacheHolder() noexcept(false) override
Definition: implementors.h:167
edm::one::impl::BeginLuminosityBlockProducer::BeginLuminosityBlockProducer
BeginLuminosityBlockProducer()=default
edm::one::impl::SharedResourcesUser
Definition: implementors.h:55
edm::one::impl::BeginRunProducer::BeginRunProducer
BeginRunProducer()=default
edm::one::impl::OptionalSerialTaskQueueHolder< true >::queue
edm::SerialTaskQueue * queue()
Definition: implementors.h:45
edm::one::impl::BeginLuminosityBlockProducer
Definition: implementors.h:134
edm::one::impl::RunWatcher::endRun
virtual void endRun(edm::Run const &, edm::EventSetup const &)=0
edm::SerialTaskQueue
Definition: SerialTaskQueue.h:67
edm::one::impl::RunCacheHolder::globalBeginRun
virtual std::shared_ptr< C > globalBeginRun(edm::Run const &, edm::EventSetup const &) const =0
edm::one::impl::LuminosityBlockCacheHolder::luminosityBlockCache
C const * luminosityBlockCache(edm::LuminosityBlockIndex iID) const
Definition: implementors.h:197
edm::one::impl::EndLuminosityBlockProducer::endLuminosityBlockProduce
virtual void endLuminosityBlockProduce(edm::LuminosityBlock &, edm::EventSetup const &)=0
edm::one::impl::OptionalSerialTaskQueueHolder< false >::queue
edm::SerialTaskQueue * queue()
Definition: implementors.h:51
edm::one::impl::SharedResourcesUser::operator=
SharedResourcesUser & operator=(SharedResourcesUser const &)=delete
edm::one::impl::LuminosityBlockCacheHolder::globalBeginLuminosityBlock
virtual std::shared_ptr< C > globalBeginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) const =0
edm::one::impl::Accumulator::hasAccumulator
bool hasAccumulator() const override
Definition: implementors.h:224
edm::one::impl::SharedResourcesUser::usesResource
void usesResource()
Definition: implementorsMethods.h:39
edm::one::impl::EndRunProducer::EndRunProducer
EndRunProducer()=default
edm::propagate_const::get
element_type const * get() const
Definition: propagate_const.h:64
edm::propagate_const
Definition: propagate_const.h:32
edm::LuminosityBlockIndex
Definition: LuminosityBlockIndex.h:33
SerialTaskQueue.h
edm::one::impl::RunCacheHolder::doBeginRun_
void doBeginRun_(Run const &rp, EventSetup const &c) final
Definition: implementors.h:174
edm::one::impl::LuminosityBlockCacheHolder
Definition: implementors.h:187
edm::one::impl::LuminosityBlockCacheHolder::globalEndLuminosityBlock
virtual void globalEndLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &)=0
edm::one::impl::RunWatcher::doBeginRun_
void doBeginRun_(Run const &rp, EventSetup const &c) final
Definition: implementorsMethods.h:50
edm::one::impl::EndLuminosityBlockProducer::EndLuminosityBlockProducer
EndLuminosityBlockProducer()=default
edm::one::impl::EndLuminosityBlockProducer
Definition: implementors.h:148
edm::one::impl::EndLuminosityBlockProducer::~EndLuminosityBlockProducer
~EndLuminosityBlockProducer() noexcept(false) override
Definition: implementors.h:153
edm::one::impl::RunCacheHolder::globalEndRun
virtual void globalEndRun(edm::Run const &, edm::EventSetup const &)=0
edm::one::impl::BeginRunProducer::operator=
BeginRunProducer & operator=(BeginRunProducer const &)=delete
edm::one::impl::LuminosityBlockWatcher::doBeginLuminosityBlock_
void doBeginLuminosityBlock_(LuminosityBlock const &rp, EventSetup const &c) final
Definition: implementorsMethods.h:59
RunIndex.h
SharedResourcesAcquirer
edm::one::impl::LuminosityBlockWatcher
Definition: implementors.h:90
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::one::impl::RunWatcher::beginRun
virtual void beginRun(edm::Run const &, edm::EventSetup const &)=0
funct::true
true
Definition: Factorize.h:173
edm::one::impl::SharedResourcesUser::SharedResourcesUser
SharedResourcesUser(Args... args)
Definition: implementors.h:58
edm::one::impl::EndRunProducer::endRunProduce
virtual void endRunProduce(edm::Run &, edm::EventSetup const &)=0
edm::one::impl::EndLuminosityBlockProducer::doEndLuminosityBlockProduce_
void doEndLuminosityBlockProduce_(LuminosityBlock &lbp, EventSetup const &c) final
Definition: implementorsMethods.h:83
edm::one::impl::RunWatcher::~RunWatcher
~RunWatcher() noexcept(false) override
Definition: implementors.h:79
edm::one::impl::SharedResourcesUser::~SharedResourcesUser
~SharedResourcesUser() override
Definition: implementors.h:62
edm::EventSetup
Definition: EventSetup.h:57
edm::one::impl::LuminosityBlockWatcher::LuminosityBlockWatcher
LuminosityBlockWatcher()=default
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
edm::one::impl::LuminosityBlockWatcher::doEndLuminosityBlock_
void doEndLuminosityBlock_(LuminosityBlock const &rp, EventSetup const &c) final
Definition: implementorsMethods.h:63
edm::one::impl::RunWatcher::RunWatcher
RunWatcher()=default
edm::one::impl::Accumulator
Definition: implementors.h:216
edm::one::impl::LuminosityBlockCacheHolder::doEndLuminosityBlock_
void doEndLuminosityBlock_(LuminosityBlock const &lp, EventSetup const &c) final
Definition: implementors.h:204
edm::one::impl::BeginRunProducer::doBeginRunProduce_
void doBeginRunProduce_(Run &rp, EventSetup const &c) final
Definition: implementorsMethods.h:68
edm::one::impl::LuminosityBlockCacheHolder::~LuminosityBlockCacheHolder
~LuminosityBlockCacheHolder() noexcept(false) override
Definition: implementors.h:192
edm::one::impl::RunCacheHolder::cache_
edm::propagate_const< std::shared_ptr< C > > cache_
Definition: implementors.h:183
impl
Definition: trackAlgoPriorityOrder.h:18
edm::one::impl::LuminosityBlockCacheHolder::LuminosityBlockCacheHolder
LuminosityBlockCacheHolder()=default
edm::one::impl::BeginRunProducer
Definition: implementors.h:106
edm::one::impl::RunWatcher::operator=
RunWatcher & operator=(RunWatcher const &)=delete
edm::one::impl::RunCacheHolder::runCache
C const * runCache(edm::RunIndex iID) const
Definition: implementors.h:171
gen::C
C
Definition: PomwigHadronizer.cc:76
Frameworkfwd.h
T
long double T
Definition: Basic3DVectorLD.h:48
ev
bool ev
Definition: Hydjet2Hadronizer.cc:95
edm::one::impl::LuminosityBlockCacheHolder::caches_
std::unique_ptr< std::shared_ptr< C >[]> caches_
Definition: implementors.h:212
edm::one::impl::LuminosityBlockWatcher::endLuminosityBlock
virtual void endLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &)=0
edm::one::impl::LuminosityBlockCacheHolder::luminosityBlockCache
C * luminosityBlockCache(edm::LuminosityBlockIndex iID)
Definition: implementors.h:198
edm::one::impl::EndRunProducer::~EndRunProducer
~EndRunProducer() noexcept(false) override
Definition: implementors.h:125
edm::one::impl::LuminosityBlockWatcher::~LuminosityBlockWatcher
~LuminosityBlockWatcher() noexcept(false) override
Definition: implementors.h:95
edm::one::impl::RunCacheHolder::operator=
RunCacheHolder< T, C > & operator=(RunCacheHolder< T, C > const &)=delete
edm::one::impl::BeginLuminosityBlockProducer::~BeginLuminosityBlockProducer
~BeginLuminosityBlockProducer() noexcept(false) override
Definition: implementors.h:139
edm::RunIndex
Definition: RunIndex.h:32
LuminosityBlockIndex.h
edm::one::impl::Accumulator::produce
void produce(Event &ev, EventSetup const &es) final
Definition: implementors.h:226
edm::one::impl::EndRunProducer::doEndRunProduce_
void doEndRunProduce_(Run &rp, EventSetup const &c) final
Definition: implementorsMethods.h:73
edm::one::impl::RunCacheHolder::RunCacheHolder
RunCacheHolder()=default
edm::one::impl::RunCacheHolder::runCache
C * runCache(edm::RunIndex iID)
Definition: implementors.h:170
edm::one::impl::RunWatcher
Definition: implementors.h:74
edm::one::impl::LuminosityBlockWatcher::beginLuminosityBlock
virtual void beginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &)=0
edm::one::impl::BeginLuminosityBlockProducer::doBeginLuminosityBlockProduce_
void doBeginLuminosityBlockProduce_(LuminosityBlock &lbp, EventSetup const &c) final
Definition: implementorsMethods.h:78
edm::Event
Definition: Event.h:73
edm::one::impl::Accumulator::Accumulator
Accumulator()=default
edm::one::impl::OptionalSerialTaskQueueHolder
Definition: implementors.h:41
edm::one::impl::LuminosityBlockCacheHolder::doBeginLuminosityBlock_
void doBeginLuminosityBlock_(LuminosityBlock const &lp, EventSetup const &c) final
Definition: implementors.h:201
edm::one::impl::EndRunProducer
Definition: implementors.h:120
edm::one::impl::EndLuminosityBlockProducer::operator=
EndLuminosityBlockProducer & operator=(EndLuminosityBlockProducer const &)=delete
edm::one::impl::SharedResourcesUser::resourceNames_
std::set< std::string > resourceNames_
Definition: implementors.h:70
edm::one::impl::RunWatcher::doEndRun_
void doEndRun_(Run const &rp, EventSetup const &c) final
Definition: implementorsMethods.h:54
edm::one::impl::BeginLuminosityBlockProducer::operator=
BeginLuminosityBlockProducer & operator=(BeginLuminosityBlockProducer const &)=delete
edm::one::impl::LuminosityBlockWatcher::operator=
LuminosityBlockWatcher & operator=(LuminosityBlockWatcher const &)=delete