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 
7 
8 #include <typeinfo>
9 #include <algorithm>
10 
11 namespace edm {
12 
13  namespace handleimpl {
14  void throwInvalidReference();
15  void throwConvertTypeError(std::type_info const& expected, std::type_info const& actual);
16  }
17 
18  // Convert from handle-to-void to handle-to-T
19  template<typename T>
21  Handle<T>& result) {
22  if(bh.failedToGet()) {
23  Handle<T> h(std::move(bh.whyFailedFactory()));
24  result = std::move(h);
25  return;
26  }
27  void const* basicWrapper = bh.wrapper();
28  if(basicWrapper == nullptr) {
30  }
31  if(!(bh.wrapper()->dynamicTypeInfo() == typeid(T))) {
32  handleimpl::throwConvertTypeError(typeid(T), bh.wrapper()->dynamicTypeInfo());
33  }
34  Wrapper<T> const* wrapper = static_cast<Wrapper<T> const*>(basicWrapper);
35 
36  Handle<T> h(wrapper->product(), bh.provenance());
37  h.swap(result);
38  }
39 }
40 
41 #endif
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
void throwConvertTypeError(std::type_info const &expected, std::type_info const &actual)
void convert_handle(BasicHandle &&bh, Handle< T > &result)
Definition: ConvertHandle.h:20
void throwInvalidReference()
Definition: ConvertHandle.cc:6
HLT enums.
long double T
def move(src, dest)
Definition: eostools.py:511
static HepMC::HEPEVT_Wrapper wrapper