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 
7 
8 #include <typeinfo>
9 
10 namespace edm {
11 
12  namespace handleimpl {
13  void throwInvalidReference();
14  void throwConvertTypeError(std::type_info const& expected, std::type_info const& actual);
15  }
16 
17  // Convert from handle-to-void to handle-to-T
18  template<typename T>
19  void convert_handle(BasicHandle const& bh,
20  Handle<T>& result) {
21  if(bh.failedToGet()) {
22  Handle<T> h(bh.whyFailed());
23  h.swap(result);
24  return;
25  }
26  void const* basicWrapper = bh.wrapper();
27  if(basicWrapper == 0) {
29  }
30  if(!(bh.interface()->dynamicTypeInfo() == typeid(T))) {
32  }
33  Wrapper<T> const* wrapper = static_cast<Wrapper<T> const*>(basicWrapper);
34 
35  Handle<T> h(wrapper->product(), bh.provenance());
36  h.swap(result);
37  }
38 }
39 
40 #endif
std::type_info const & dynamicTypeInfo() const
WrapperInterfaceBase const * interface() const
Definition: BasicHandle.h:98
void const * wrapper() const
Definition: BasicHandle.h:102
void throwConvertTypeError(std::type_info const &expected, std::type_info const &actual)
Provenance const * provenance() const
Definition: BasicHandle.h:110
tuple result
Definition: query.py:137
bool failedToGet() const
Definition: BasicHandle.h:94
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
void throwInvalidReference()
Definition: ConvertHandle.cc:6
T const * product() const
Definition: Wrapper.h:36
void convert_handle(BasicHandle const &bh, Handle< T > &result)
Definition: ConvertHandle.h:19
boost::shared_ptr< cms::Exception > whyFailed() const
Definition: BasicHandle.h:118
string const
Definition: compareJSON.py:14
long double T
static HepMC::HEPEVT_Wrapper wrapper