Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:13:12

0001 #ifndef FWCore_Utilities_RootHandlers_h
0002 #define FWCore_Utilities_RootHandlers_h
0003 
0004 #include "FWCore/Utilities/interface/propagate_const.h"
0005 namespace edm {
0006   class EventProcessor;
0007   class RootHandlers {
0008   public:
0009     enum class SeverityLevel { kInfo, kWarning, kError, kSysError, kFatal };
0010 
0011   private:
0012     struct WarningSentry {
0013       WarningSentry(RootHandlers* iHandler, SeverityLevel level) : m_handler(iHandler) {
0014         m_handler->ignoreWarnings_(level);
0015       };
0016       ~WarningSentry() { m_handler->enableWarnings_(); }
0017       edm::propagate_const<RootHandlers*> m_handler;
0018     };
0019     friend struct edm::RootHandlers::WarningSentry;
0020     friend class edm::EventProcessor;
0021 
0022   public:
0023     virtual ~RootHandlers() {}
0024 
0025     template <typename F>
0026     void ignoreWarningsWhileDoing(F iFunc, SeverityLevel level = SeverityLevel::kWarning) {
0027       WarningSentry sentry(this, level);
0028       iFunc();
0029     }
0030 
0031   private:
0032     virtual void willBeUsingThreads() = 0;
0033 
0034     virtual void enableWarnings_() = 0;
0035     virtual void ignoreWarnings_(SeverityLevel level) = 0;
0036   };
0037 }  // end of namespace edm
0038 
0039 #endif  // InitRootHandlers_H