CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
HandleBase.cc
Go to the documentation of this file.
5 
6 namespace {
7  void throwInvalidHandleDeref() {
8  throw cms::Exception("DereferenceUnsetHandle")
9  << "An attempt was made to dereference an edm::Handle which was never set.";
10  }
11  void throwInvalidHandleProv() {
12  throw cms::Exception("ProvenanceFromUnsetHandle")
13  << "An attempt was made to get the ProductId from an edm::Handle which was never set.";
14  }
15 } // namespace
16 
17 namespace edm {
18  void const* HandleBase::productStorage() const {
19  if UNLIKELY (not product_) {
20  if LIKELY (static_cast<bool>(whyFailedFactory_)) {
21  whyFailedFactory_->make()->raise();
22  } else {
23  throwInvalidHandleDeref();
24  }
25  }
26  return product_;
27  }
28 
30  if UNLIKELY (not prov_) {
31  if LIKELY (static_cast<bool>(whyFailedFactory_)) {
32  whyFailedFactory_->make()->raise();
33  } else {
34  throwInvalidHandleProv();
35  }
36  }
37  return prov_->productID();
38  }
39 } // namespace edm
ProductID id() const
Definition: HandleBase.cc:29
#define LIKELY(x)
Definition: Likely.h:20
void const * productStorage() const
Definition: HandleBase.cc:18
std::shared_ptr< HandleExceptionFactory const > whyFailedFactory_
Definition: HandleBase.h:110
Provenance const * prov_
Definition: HandleBase.h:109
void const * product_
Definition: HandleBase.h:108
#define UNLIKELY(x)
Definition: Likely.h:21