Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-05-11 03:34:13

0001 
0002 #ifndef FWCore_Framework_OutputModuleCommunicatorT_h
0003 #define FWCore_Framework_OutputModuleCommunicatorT_h
0004 /*----------------------------------------------------------------------
0005 ----------------------------------------------------------------------*/
0006 
0007 #include "FWCore/Framework/interface/OutputModuleCommunicator.h"
0008 #include "FWCore/Common/interface/FWCoreCommonFwd.h"
0009 
0010 namespace edm {
0011   class ActivityRegistry;
0012   class MergeableRunProductMetadata;
0013   class ThinnedAssociationsHelper;
0014 
0015   namespace one {
0016     class OutputModuleBase;
0017   }
0018   namespace global {
0019     class OutputModuleBase;
0020   }
0021   namespace limited {
0022     class OutputModuleBase;
0023   }
0024   namespace impl {
0025     std::unique_ptr<edm::OutputModuleCommunicator> createCommunicatorIfNeeded(void*);
0026     std::unique_ptr<edm::OutputModuleCommunicator> createCommunicatorIfNeeded(::edm::one::OutputModuleBase*);
0027     std::unique_ptr<edm::OutputModuleCommunicator> createCommunicatorIfNeeded(::edm::global::OutputModuleBase*);
0028     std::unique_ptr<edm::OutputModuleCommunicator> createCommunicatorIfNeeded(::edm::limited::OutputModuleBase*);
0029   }  // namespace impl
0030 
0031   template <typename T>
0032 
0033   class OutputModuleCommunicatorT : public edm::OutputModuleCommunicator {
0034   public:
0035     OutputModuleCommunicatorT(T* iModule) : module_(iModule) {}
0036     void closeFile() override;
0037 
0038     ///\return true if output module wishes to close its file
0039     bool shouldWeCloseFile() const override;
0040 
0041     ///\return true if no event filtering is applied to OutputModule
0042     bool wantAllEvents() const override;
0043 
0044     void openFile(edm::FileBlock const& fb) override;
0045 
0046     void writeProcessBlockAsync(WaitingTaskHolder iTask,
0047                                 ProcessBlockPrincipal const&,
0048                                 ProcessContext const*,
0049                                 ActivityRegistry*) noexcept override;
0050 
0051     void writeRunAsync(WaitingTaskHolder iTask,
0052                        edm::RunPrincipal const& rp,
0053                        ProcessContext const*,
0054                        ActivityRegistry*,
0055                        MergeableRunProductMetadata const*) noexcept override;
0056 
0057     void writeLumiAsync(WaitingTaskHolder iTask,
0058                         edm::LuminosityBlockPrincipal const& lbp,
0059                         ProcessContext const*,
0060                         ActivityRegistry*) noexcept override;
0061 
0062     ///\return true if OutputModule has reached its limit on maximum number of events it wants to see
0063     bool limitReached() const override;
0064 
0065     void configure(edm::OutputModuleDescription const& desc) override;
0066 
0067     edm::SelectedProductsForBranchType const& keptProducts() const override;
0068 
0069     void selectProducts(edm::ProductRegistry const& preg,
0070                         ThinnedAssociationsHelper const&,
0071                         ProcessBlockHelperBase const&) override;
0072 
0073     void setEventSelectionInfo(
0074         std::map<std::string, std::vector<std::pair<std::string, int> > > const& outputModulePathPositions,
0075         bool anyProductProduced) override;
0076 
0077     ModuleDescription const& description() const override;
0078 
0079     static std::unique_ptr<edm::OutputModuleCommunicator> createIfNeeded(T* iMod) {
0080       return impl::createCommunicatorIfNeeded(iMod);
0081     }
0082 
0083   private:
0084     inline T& module() const noexcept { return *module_; }
0085     T* module_;
0086   };
0087 }  // namespace edm
0088 #endif