Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef FWCore_Framework_FunctorESHandleExceptionFactory_h
0002 #define FWCore_Framework_FunctorESHandleExceptionFactory_h
0003 // -*- C++ -*-
0004 //
0005 // Package:     FWCore/Framework
0006 // Class  :     FunctorESHandleExceptionFactory
0007 //
0008 /**\class edm::FunctorESHandleExceptionFactory
0009 
0010  Description: [one line class summary]
0011 
0012  Usage:
0013     <usage>
0014 
0015 */
0016 //
0017 // Original Author:  W. David Dagenhart
0018 //         Created:  1 May 2014
0019 //
0020 
0021 #include "FWCore/Framework/interface/ESHandleExceptionFactory.h"
0022 
0023 #include <exception>
0024 #include <memory>
0025 #include <utility>
0026 
0027 namespace edm {
0028 
0029   template <typename T>
0030   class FunctorESHandleExceptionFactory : public ESHandleExceptionFactory {
0031   public:
0032     FunctorESHandleExceptionFactory(T&& iFunctor) : m_functor(std::move(iFunctor)) {}
0033 
0034     std::exception_ptr make() const override { return m_functor(); }
0035 
0036   private:
0037     T m_functor;
0038   };
0039 
0040   template <typename T>
0041   std::shared_ptr<ESHandleExceptionFactory> makeESHandleExceptionFactory(T&& iFunctor) {
0042     return std::make_shared<FunctorESHandleExceptionFactory<T>>(std::move(iFunctor));
0043   }
0044 }  // namespace edm
0045 #endif