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
edm::TypeWithDict::byName
static TypeWithDict byName(std::string const &name)
Definition: TypeWithDict.cc:74
edm::BasicHandle::failedToGet
bool failedToGet() const noexcept(true)
Definition: BasicHandle.h:71
edm::BasicHandle::provenance
Provenance const * provenance() const noexcept(true)
Definition: BasicHandle.h:75
edm::errors::InvalidReference
Definition: EDMException.h:39
edm::BasicHandle
Definition: BasicHandle.h:43
edm::errors::LogicError
Definition: EDMException.h:37
edm
HLT enums.
Definition: AlignableModifier.h:19
h
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
Definition: L1TUtmAlgorithmRcd.h:4
edm::ObjectWithDict
Definition: ObjectWithDict.h:17
cms::cuda::assert
assert(be >=bs)
edm::convert_handle
Handle< T > convert_handle(BasicHandle &&bh) noexcept(true)
Definition: ConvertHandle.h:22
GlobalPosition_Frontier_DevDB_cff.tag
tag
Definition: GlobalPosition_Frontier_DevDB_cff.py:11
FWGenericHandle.h
edm::convertException::wrap
auto wrap(F iFunc) -> decltype(iFunc())
Definition: ConvertException.h:19
h
edm::BasicHandle::wrapper
WrapperBase const * wrapper() const noexcept(true)
Definition: BasicHandle.h:73
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::TypeWithDict
Definition: TypeWithDict.h:38
edm::TypeWithDict::typeInfo
std::type_info const & typeInfo() const
Definition: TypeWithDict.cc:357
edm::BasicHandle::id
ProductID id() const noexcept(true)
Definition: BasicHandle.h:77
edm::WrapperBase
Definition: WrapperBase.h:23
Exception
Definition: hltDiff.cc:245
edm::Handle< FWGenericObject >
Definition: FWGenericHandle.h:48
mps_fire.result
result
Definition: mps_fire.py:311
edm::BasicHandle::whyFailed
std::shared_ptr< cms::Exception > whyFailed() const
Definition: BasicHandle.h:79
EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0.cerr
cerr
Definition: EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0.py:8
edm::InputTag
Definition: InputTag.h:15
edm::WrapperBase::wrappedTypeInfo
std::type_info const & wrappedTypeInfo() const
Definition: WrapperBase.h:44