Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 10:49:22

0001 #ifndef Subsystem_Package_FunctorHandleExceptionFactory_h
0002 #define Subsystem_Package_FunctorHandleExceptionFactory_h
0003 // -*- C++ -*-
0004 //
0005 // Package:     Subsystem/Package
0006 // Class  :     FunctorHandleExceptionFactory
0007 //
0008 /**\class FunctorHandleExceptionFactory FunctorHandleExceptionFactory.h "FunctorHandleExceptionFactory.h"
0009 
0010  Description: [one line class summary]
0011 
0012  Usage:
0013     <usage>
0014 
0015 */
0016 //
0017 // Original Author:  Chris Jones
0018 //         Created:  Wed, 04 Dec 2013 18:41:59 GMT
0019 //
0020 
0021 // system include files
0022 #include "DataFormats/Common/interface/HandleExceptionFactory.h"
0023 
0024 // user include files
0025 
0026 // forward declarations
0027 namespace edm {
0028 
0029   template <typename T>
0030   class FunctorHandleExceptionFactory : public HandleExceptionFactory {
0031   public:
0032     FunctorHandleExceptionFactory(T&& iFunctor) : m_functor(std::move(iFunctor)) {}
0033 
0034     //FunctorHandleExceptionFactory(T iFunctor) : m_functor(iFunctor) {}
0035 
0036     // ---------- const member functions ---------------------
0037 
0038     std::shared_ptr<cms::Exception> make() const override { return m_functor(); }
0039 
0040   private:
0041     T m_functor;
0042   };
0043 
0044   template <typename T>
0045   std::shared_ptr<HandleExceptionFactory> makeHandleExceptionFactory(T&& iFunctor) {
0046     return std::make_shared<FunctorHandleExceptionFactory<T>>(std::move(iFunctor));
0047   }
0048 }  // namespace edm
0049 
0050 #endif