CMS 3D CMS Logo

outputmoduleAbilityToImplementor.h
Go to the documentation of this file.
1 #ifndef FWCore_Framework_global_outputmoduleAbilityToImplementor_h
2 #define FWCore_Framework_global_outputmoduleAbilityToImplementor_h
3 // -*- C++ -*-
4 //
5 // Package: FWCore/Framework
6 // Class : outputmodule::AbilityToImplementor
7 //
16 //
17 //
18 
19 // system include files
20 
21 // user include files
26 
27 // forward declarations
28 
29 namespace edm {
30  class FileBlock;
31  class ModuleCallingContext;
32 
33  namespace global {
34  namespace outputmodule {
35 
36  class InputFileWatcher : public virtual OutputModuleBase {
37  public:
39  InputFileWatcher(InputFileWatcher const&) = delete;
41  ~InputFileWatcher() noexcept(false) override{};
42 
43  private:
44  void doRespondToOpenInputFile_(FileBlock const&) final;
45  void doRespondToCloseInputFile_(FileBlock const&) final;
46 
47  virtual void respondToOpenInputFile(FileBlock const&) = 0;
48  virtual void respondToCloseInputFile(FileBlock const&) = 0;
49  };
50 
51  template <typename T, typename C>
52  class StreamCacheHolder : public virtual T {
53  public:
54  explicit StreamCacheHolder(edm::ParameterSet const& iPSet) : OutputModuleBase(iPSet) {}
57  ~StreamCacheHolder() override {
58  for (auto c : caches_) {
59  delete c;
60  }
61  }
62 
63  protected:
64  C* streamCache(edm::StreamID iID) const { return caches_[iID.value()]; }
65 
66  private:
67  void preallocStreams(unsigned int iNStreams) final { caches_.resize(iNStreams, static_cast<C*>(nullptr)); }
68  void doBeginStream_(StreamID id) final { caches_[id.value()] = beginStream(id).release(); }
69  void doEndStream_(StreamID id) final {
70  endStream(id);
71  delete caches_[id.value()];
72  caches_[id.value()] = nullptr;
73  }
74 
75  virtual std::unique_ptr<C> beginStream(edm::StreamID) const = 0;
76  virtual void endStream(edm::StreamID) const {}
77 
78  //When threaded we will have a container for N items whre N is # of streams
79  std::vector<C*> caches_;
80  };
81 
82  template <typename T, typename C>
83  class RunCacheHolder : public virtual T {
84  public:
86  RunCacheHolder(RunCacheHolder<T, C> const&) = delete;
88  ~RunCacheHolder() noexcept(false) override{};
89 
90  protected:
91  C const* runCache(edm::RunIndex iID) const { return cache_.get(); }
92 
93  private:
94  void doBeginRun_(RunForOutput const& rp) final { cache_ = globalBeginRun(rp); }
95  void doEndRun_(RunForOutput const& rp) final {
96  globalEndRun(rp);
97  cache_ = nullptr; // propagate_const<T> has no reset() function
98  }
99 
100  virtual std::shared_ptr<C> globalBeginRun(RunForOutput const&) const = 0;
101  virtual void globalEndRun(RunForOutput const&) const = 0;
102  //When threaded we will have a container for N items whre N is # of simultaneous runs
104  };
105 
106  template <typename T, typename C>
107  class LuminosityBlockCacheHolder : public virtual T {
108  public:
112  ~LuminosityBlockCacheHolder() noexcept(false) override{};
113 
114  protected:
115  void preallocLumis(unsigned int iNLumis) final { caches_.reset(new std::shared_ptr<C>[iNLumis]); }
116  C const* luminosityBlockCache(edm::LuminosityBlockIndex iID) const { return caches_[iID].get(); }
117 
118  private:
120  caches_[lp.index()] = globalBeginLuminosityBlock(lp);
121  }
124  caches_[lp.index()].reset();
125  }
126 
127  virtual std::shared_ptr<C> globalBeginLuminosityBlock(LuminosityBlockForOutput const&) const = 0;
128  virtual void globalEndLuminosityBlock(LuminosityBlockForOutput const&) const = 0;
129  //When threaded we will have a container for N items whre N is # of simultaneous runs
130  std::unique_ptr<std::shared_ptr<C>[]> caches_;
131  };
132 
133  template <typename T>
134  class ExternalWork : public virtual T {
135  public:
137  ExternalWork(ExternalWork const&) = delete;
138  ExternalWork& operator=(ExternalWork const&) = delete;
139  ~ExternalWork() noexcept(false) override{};
140 
141  private:
142  bool hasAcquire() const override { return true; }
143 
145  acquire(id, event, holder);
146  }
147 
148  virtual void acquire(StreamID, EventForOutput const&, WaitingTaskWithArenaHolder) const = 0;
149  };
150 
151  template <typename T>
153 
154  template <>
157  };
158 
159  template <typename C>
162  };
163 
164  template <typename C>
167  };
168 
169  template <typename C>
172  };
173 
174  template <>
177  };
178 
179  } // namespace outputmodule
180  } // namespace global
181 } // namespace edm
182 
183 #endif
virtual void respondToOpenInputFile(FileBlock const &)=0
InputFileWatcher & operator=(InputFileWatcher const &)=delete
virtual std::shared_ptr< C > globalBeginRun(RunForOutput const &) const =0
edm::global::outputmodule::ExternalWork< edm::global::OutputModuleBase > Type
virtual void globalEndRun(RunForOutput const &) const =0
virtual void globalEndLuminosityBlock(LuminosityBlockForOutput const &) const =0
constexpr element_type const * get() const
void doAcquire_(StreamID id, EventForOutput const &event, WaitingTaskWithArenaHolder &holder) final
edm::global::outputmodule::LuminosityBlockCacheHolder< edm::global::OutputModuleBase, C > Type
StreamCacheHolder< T, C > & operator=(StreamCacheHolder< T, C > const &)=delete
edm::propagate_const< std::shared_ptr< C > > cache_
edm::global::outputmodule::StreamCacheHolder< edm::global::OutputModuleBase, C > Type
void doBeginLuminosityBlock_(LuminosityBlockForOutput const &lp) final
void doRespondToOpenInputFile_(FileBlock const &) final
ExternalWork & operator=(ExternalWork const &)=delete
C const * luminosityBlockCache(edm::LuminosityBlockIndex iID) const
void doRespondToCloseInputFile_(FileBlock const &) final
virtual std::unique_ptr< C > beginStream(edm::StreamID) const =0
edm::global::outputmodule::RunCacheHolder< edm::global::OutputModuleBase, C > Type
HLT enums.
void doEndLuminosityBlock_(LuminosityBlockForOutput const &lp) final
unsigned int value() const
Definition: StreamID.h:43
LuminosityBlockCacheHolder< T, C > & operator=(LuminosityBlockCacheHolder< T, C > const &)=delete
long double T
virtual void respondToCloseInputFile(FileBlock const &)=0
RunCacheHolder< T, C > & operator=(RunCacheHolder< T, C > const &)=delete
virtual std::shared_ptr< C > globalBeginLuminosityBlock(LuminosityBlockForOutput const &) const =0
Definition: event.py:1
virtual void acquire(StreamID, EventForOutput const &, WaitingTaskWithArenaHolder) const =0