CMS 3D CMS Logo

ConvertHandle.h
Go to the documentation of this file.
1 #ifndef DataFormats_Common_ConvertHandle_h
2 #define DataFormats_Common_ConvertHandle_h
3 
8 
9 #include <typeinfo>
10 #include <algorithm>
11 #include <memory>
12 
13 namespace edm {
14 
15  namespace handleimpl {
16  void throwConvertTypeError(std::type_info const& expected, std::type_info const& actual);
17  std::shared_ptr<edm::HandleExceptionFactory> makeInvalidReferenceException();
18  }
19 
20  // Convert from handle-to-void to handle-to-T
21  template<typename T>
23  if UNLIKELY(bh.failedToGet()) {
24  return Handle<T>(std::move(bh.whyFailedFactory()));
25  }
26  void const* basicWrapper = bh.wrapper();
27  if UNLIKELY(nullptr == basicWrapper) {
29  }
30  auto wrapper = static_cast<Wrapper<T> const*>(basicWrapper);
31 
32  return Handle<T>(wrapper->product(), bh.provenance());
33  }
34 
35  template<typename T>
37  if UNLIKELY(bh.failedToGet()) {
38  return Handle<T>(std::move(bh.whyFailedFactory()));
39  }
40  void const* basicWrapper = bh.wrapper();
41  if UNLIKELY(basicWrapper == nullptr) {
43  }
44  if UNLIKELY(!(bh.wrapper()->dynamicTypeInfo() == typeid(T))) {
45  handleimpl::throwConvertTypeError(typeid(T), bh.wrapper()->dynamicTypeInfo());
46  }
47  Wrapper<T> const* wrapper = static_cast<Wrapper<T> const*>(basicWrapper);
48 
49  return Handle<T>(wrapper->product(), bh.provenance());
50  }
51 
52 }
53 
54 #endif
void throwConvertTypeError(std::type_info const &expected, std::type_info const &actual)
Handle< T > convert_handle(BasicHandle &&bh)(true)
Definition: ConvertHandle.h:22
#define noexcept
HLT enums.
Handle< T > convert_handle_check_type(BasicHandle &&bh)
Definition: ConvertHandle.h:36
std::shared_ptr< edm::HandleExceptionFactory > makeInvalidReferenceException()
#define UNLIKELY(x)
Definition: Likely.h:21
long double T
def move(src, dest)
Definition: eostools.py:511
static HepMC::HEPEVT_Wrapper wrapper