FunctorHandleExceptionFactory

Macros

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
#ifndef Subsystem_Package_FunctorHandleExceptionFactory_h
#define Subsystem_Package_FunctorHandleExceptionFactory_h
// -*- C++ -*-
//
// Package:     Subsystem/Package
// Class  :     FunctorHandleExceptionFactory
//
/**\class FunctorHandleExceptionFactory FunctorHandleExceptionFactory.h "FunctorHandleExceptionFactory.h"

 Description: [one line class summary]

 Usage:
    <usage>

*/
//
// Original Author:  Chris Jones
//         Created:  Wed, 04 Dec 2013 18:41:59 GMT
//

// system include files
#include "DataFormats/Common/interface/HandleExceptionFactory.h"

// user include files

// forward declarations
namespace edm {

  template <typename T>
  class FunctorHandleExceptionFactory : public HandleExceptionFactory {
  public:
    FunctorHandleExceptionFactory(T&& iFunctor) : m_functor(std::move(iFunctor)) {}

    //FunctorHandleExceptionFactory(T iFunctor) : m_functor(iFunctor) {}

    // ---------- const member functions ---------------------

    std::shared_ptr<cms::Exception> make() const override { return m_functor(); }

  private:
    T m_functor;
  };

  template <typename T>
  std::shared_ptr<HandleExceptionFactory> makeHandleExceptionFactory(T&& iFunctor) {
    return std::make_shared<FunctorHandleExceptionFactory<T>>(std::move(iFunctor));
  }
}  // namespace edm

#endif