CMS 3D CMS Logo

GenericHandle.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Framework
4 // Class : GenericHandle
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 
15 // user include files
17 
18 namespace edm {
20  if (orig.failedToGet()) {
21  result.setWhyFailedFactory(orig.whyFailedFactory());
22  return;
23  }
24  WrapperBase const* originalWrap = orig.wrapper();
25  if (originalWrap == nullptr) {
26  throw Exception(errors::InvalidReference, "NullPointer") << "edm::BasicHandle has null pointer to Wrapper";
27  }
28 
29  ObjectWithDict wrap(originalWrap->wrappedTypeInfo(), const_cast<WrapperBase*>(originalWrap));
30  assert(bool(wrap));
31 
32  ObjectWithDict product(wrap.get("obj"));
33  if (!product) {
34  throw Exception(errors::LogicError) << "GenericObject could not find 'obj' member";
35  }
36  if (product.typeOf() != result.type()) {
38  << "GenericObject asked for " << result.type().name() << " but was given a " << product.typeOf().name();
39  }
40 
41  Handle<GenericObject> h(product, orig.provenance(), orig.id());
42  h.swap(result);
43  }
44 
46  template <>
47  bool Event::getByLabel<GenericObject>(std::string const& label,
48  std::string const& productInstanceName,
51  TypeID(result.type().typeInfo()), label, productInstanceName, std::string(), moduleCallingContext_);
52  convert_handle(std::move(bh), result); // throws on conversion error
53  if (!result.failedToGet()) {
55  return true;
56  }
57  return false;
58  }
59 
60  template <>
61  bool Event::getByLabel<GenericObject>(InputTag const& tag, Handle<GenericObject>& result) const {
62  if (tag.process().empty()) {
63  return this->getByLabel(tag.label(), tag.instance(), result);
64  } else {
66  TypeID(result.type().typeInfo()), tag.label(), tag.instance(), tag.process(), moduleCallingContext_);
67  convert_handle(std::move(bh), result); // throws on conversion error
68  if (!result.failedToGet()) {
70  return true;
71  }
72  }
73  return false;
74  }
75 
77  template <>
78  bool Event::getByToken<GenericObject>(EDGetToken token, Handle<GenericObject>& result) const {
79  result.clear();
80  BasicHandle bh =
82  convert_handle(std::move(bh), result); // throws on conversion error
83  if (UNLIKELY(result.failedToGet())) {
84  return false;
85  }
86  addToGotBranchIDs(*result.provenance());
87  return true;
88  }
89 
90 } // namespace edm
edm::BasicHandle::provenance
Provenance const * provenance() const noexcept(true)
Definition: BasicHandle.h:75
edm::PRODUCT_TYPE
Definition: ProductKindOfType.h:5
edm::errors::InvalidReference
Definition: EDMException.h:39
edm::BasicHandle
Definition: BasicHandle.h:43
edm::Event::addToGotBranchIDs
void addToGotBranchIDs(Provenance const &prov) const
Definition: Event.cc:235
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
edm::Event::moduleCallingContext_
ModuleCallingContext const * moduleCallingContext_
Definition: Event.h:336
cms::cuda::assert
assert(be >=bs)
edm::convert_handle
Handle< T > convert_handle(BasicHandle &&bh) noexcept(true)
Definition: ConvertHandle.h:22
edm::InputTag::label
std::string const & label() const
Definition: InputTag.h:36
UNLIKELY
#define UNLIKELY(x)
Definition: Likely.h:21
GenericHandle.h
edm::PrincipalGetAdapter::getByToken_
BasicHandle getByToken_(TypeID const &id, KindOfType kindOfType, EDGetToken token, ModuleCallingContext const *mcc) const
Definition: PrincipalGetAdapter.cc:147
GlobalPosition_Frontier_DevDB_cff.tag
tag
Definition: GlobalPosition_Frontier_DevDB_cff.py:11
edm::convertException::wrap
auto wrap(F iFunc) -> decltype(iFunc())
Definition: ConvertException.h:19
edm::PrincipalGetAdapter::getByLabel_
BasicHandle getByLabel_(TypeID const &tid, InputTag const &tag, ModuleCallingContext const *mcc) const
Definition: PrincipalGetAdapter.cc:133
h
edm::Event::getByLabel
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:496
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::Event::provRecorder_
PrincipalGetAdapter provRecorder_
Definition: Event.h:307
edm::WrapperBase
Definition: WrapperBase.h:23
edm::EDGetToken
Definition: EDGetToken.h:35
edm::TypeID
Definition: TypeID.h:22
eostools.move
def move(src, dest)
Definition: eostools.py:511
Exception
Definition: hltDiff.cc:245
mps_fire.result
result
Definition: mps_fire.py:311
edm::Handle< GenericObject >
Definition: GenericHandle.h:43
edm::InputTag
Definition: InputTag.h:15
label
const char * label
Definition: PFTauDecayModeTools.cc:11
edm::WrapperBase::wrappedTypeInfo
std::type_info const & wrappedTypeInfo() const
Definition: WrapperBase.h:44
unpackBuffers-CaloStage2.token
token
Definition: unpackBuffers-CaloStage2.py:316