CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ConvertHandle.h
Go to the documentation of this file.
1 #ifndef DataFormats_Common_ConvertHandle_h
2 #define DataFormats_Common_ConvertHandle_h
3 
4 #if !defined(__CINT__) && !defined(__MAKECINT__) && !defined(__REFLEX__)
8 
9 #include <typeinfo>
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 == 0) {
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 #else
41 namespace edm {
42  class BasicHandle;
43  template<typename T> class Handle;
44 
45  template<typename T>
46  void convert_handle(BasicHandle & bh,
47  Handle<T>& result);
48 }
49 #endif
50 
51 #endif
void throwConvertTypeError(std::type_info const &expected, std::type_info const &actual)
tuple result
Definition: query.py:137
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
void convert_handle(BasicHandle &&bh, Handle< T > &result)
Definition: ConvertHandle.h:20
void throwInvalidReference()
Definition: ConvertHandle.cc:6
T const * product() const
Definition: Wrapper.h:34
string const
Definition: compareJSON.py:14
long double T
static HepMC::HEPEVT_Wrapper wrapper