File indexing completed on 2024-04-06 12:12:03
0001 #ifndef FWCore_Framework_FunctorESHandleExceptionFactory_h
0002 #define FWCore_Framework_FunctorESHandleExceptionFactory_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
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 }
0045 #endif