CMS 3D CMS Logo

FWGenericHandle.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Framework
4 // Class : FWGenericHandle
5 //
6 // Implementation:
7 // <Notes on implementation>
8 //
9 // Original Author: Chris Jones
10 // Created: Thu Mar 30 15:48:37 EST 2006
11 //
12 
13 // system include files
14 #include <iostream>
15 
16 // user include files
18 
19 namespace edm {
21  if (orig.failedToGet()) {
22  result.setWhyFailed(orig.whyFailed());
23  return;
24  }
25 
26  WrapperBase const* originalWrap = orig.wrapper();
27  if (originalWrap == nullptr) {
28  throw edm::Exception(edm::errors::InvalidReference, "NullPointer")
29  << "edm::BasicHandle has null pointer to Wrapper";
30  }
31 
33  const_cast<void*>(static_cast<void const*>(originalWrap)));
34  assert(bool(wrap));
35 
36  edm::ObjectWithDict product(wrap.get("obj"));
37 
38  if (!product) {
39  throw edm::Exception(edm::errors::LogicError) << "FWGenericObject could not find 'obj' member";
40  }
41  if (product.typeOf() != result.type()) {
42  std::cerr << "FWGenericObject asked for " << result.type().name() << " but was given a "
43  << product.typeOf().name();
45  << "FWGenericObject asked for " << result.type().name() << " but was given a " << product.typeOf().name();
46  }
47 
48  Handle<FWGenericObject> h(product, orig.provenance(), orig.id());
49  h.swap(result);
50  }
51 
53  template <>
54  bool edm::EventBase::getByLabel<FWGenericObject>(edm::InputTag const& tag, Handle<FWGenericObject>& result) const {
55  std::string dataTypeName = result.type().name();
56  if (dataTypeName[dataTypeName.size() - 1] == '>')
57  dataTypeName += " ";
58  std::string wrapperName = "edm::Wrapper<" + dataTypeName + ">";
59 
60  edm::TypeWithDict wrapperType(edm::TypeWithDict::byName(wrapperName));
61 
62  BasicHandle bh = this->getByLabelImpl(wrapperType.typeInfo(), result.type().typeInfo(), tag);
63  convert_handle(bh, result); // throws on conversion error
64  if (bh.failedToGet())
65  return false;
66  return true;
67  }
68 
69 } // namespace edm
assert(be >=bs)
static TypeWithDict byName(std::string const &name)
Definition: TypeWithDict.cc:74
std::shared_ptr< cms::Exception > whyFailed() const
Definition: BasicHandle.h:79
bool failedToGet() const noexcept(true)
Definition: BasicHandle.h:71
Handle< T > convert_handle(BasicHandle &&bh) noexcept(true)
Definition: ConvertHandle.h:22
WrapperBase const * wrapper() const noexcept(true)
Definition: BasicHandle.h:73
std::type_info const & typeInfo() const
HLT enums.
std::type_info const & wrappedTypeInfo() const
Definition: WrapperBase.h:44
auto wrap(F iFunc) -> decltype(iFunc())
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
Provenance const * provenance() const noexcept(true)
Definition: BasicHandle.h:75
ProductID id() const noexcept(true)
Definition: BasicHandle.h:77