Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:21:19

0001 #ifndef IOPool_Streamer_StreamerOutputModule_h
0002 #define IOPool_Streamer_StreamerOutputModule_h
0003 
0004 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0005 #include "FWCore/Utilities/interface/propagate_const.h"
0006 #include "IOPool/Streamer/interface/StreamerOutputModuleBase.h"
0007 
0008 namespace edm {
0009   template <typename Consumer>
0010   class StreamerOutputModule : public StreamerOutputModuleBase {
0011     /** Consumers are suppose to provide
0012          void doOutputHeader(InitMsgBuilder const& init_message)
0013          void doOutputEvent(EventMsgBuilder const& msg)
0014          void start()
0015          void stop()
0016      static void fillDescription(ParameterSetDescription&)
0017   **/
0018 
0019   public:
0020     explicit StreamerOutputModule(ParameterSet const& ps);
0021     ~StreamerOutputModule() override;
0022     static void fillDescriptions(ConfigurationDescriptions& descriptions);
0023 
0024   private:
0025     void start() override;
0026     void stop() override;
0027     void doOutputHeader(InitMsgBuilder const& init_message) override;
0028     void doOutputEvent(EventMsgBuilder const& msg) override;
0029     void beginLuminosityBlock(edm::LuminosityBlockForOutput const&) override;
0030     void endLuminosityBlock(edm::LuminosityBlockForOutput const&) override;
0031 
0032   private:
0033     edm::propagate_const<std::unique_ptr<Consumer>> c_;
0034   };  //end-of-class-def
0035 
0036   template <typename Consumer>
0037   StreamerOutputModule<Consumer>::StreamerOutputModule(ParameterSet const& ps)
0038       : edm::one::OutputModuleBase::OutputModuleBase(ps), StreamerOutputModuleBase(ps), c_(new Consumer(ps)) {}
0039 
0040   template <typename Consumer>
0041   StreamerOutputModule<Consumer>::~StreamerOutputModule() {}
0042 
0043   template <typename Consumer>
0044   void StreamerOutputModule<Consumer>::start() {
0045     c_->start();
0046   }
0047 
0048   template <typename Consumer>
0049   void StreamerOutputModule<Consumer>::stop() {
0050     c_->stop();
0051   }
0052 
0053   template <typename Consumer>
0054   void StreamerOutputModule<Consumer>::doOutputHeader(InitMsgBuilder const& init_message) {
0055     c_->doOutputHeader(init_message);
0056   }
0057 
0058   //______________________________________________________________________________
0059   template <typename Consumer>
0060   void StreamerOutputModule<Consumer>::doOutputEvent(EventMsgBuilder const& msg) {
0061     c_->doOutputEvent(msg);  // You can't use msg in StreamerOutputModule after this point
0062   }
0063 
0064   template <typename Consumer>
0065   void StreamerOutputModule<Consumer>::beginLuminosityBlock(edm::LuminosityBlockForOutput const&) {}
0066 
0067   template <typename Consumer>
0068   void StreamerOutputModule<Consumer>::endLuminosityBlock(edm::LuminosityBlockForOutput const&) {}
0069 
0070   template <typename Consumer>
0071   void StreamerOutputModule<Consumer>::fillDescriptions(ConfigurationDescriptions& descriptions) {
0072     ParameterSetDescription desc;
0073     StreamerOutputModuleBase::fillDescription(desc);
0074     Consumer::fillDescription(desc);
0075     descriptions.add("streamerOutput", desc);
0076   }
0077 }  // namespace edm
0078 
0079 #endif