Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:03:55

0001 #include "DataFormats/Common/interface/HandleBase.h"
0002 #include "DataFormats/Provenance/interface/Provenance.h"
0003 #include "FWCore/Utilities/interface/Exception.h"
0004 #include "FWCore/Utilities/interface/Likely.h"
0005 
0006 namespace {
0007   void throwInvalidHandleDeref() {
0008     throw cms::Exception("DereferenceUnsetHandle")
0009         << "An attempt was made to dereference an edm::Handle which was never set.";
0010   }
0011   void throwInvalidHandleProv() {
0012     throw cms::Exception("ProvenanceFromUnsetHandle")
0013         << "An attempt was made to get the ProductId from an edm::Handle which was never set.";
0014   }
0015 }  // namespace
0016 
0017 namespace edm {
0018   void const* HandleBase::productStorage() const {
0019     if UNLIKELY (not product_) {
0020       if LIKELY (static_cast<bool>(whyFailedFactory_)) {
0021         whyFailedFactory_->make()->raise();
0022       } else {
0023         throwInvalidHandleDeref();
0024       }
0025     }
0026     return product_;
0027   }
0028 
0029   ProductID HandleBase::id() const {
0030     if UNLIKELY (not prov_) {
0031       if LIKELY (static_cast<bool>(whyFailedFactory_)) {
0032         whyFailedFactory_->make()->raise();
0033       } else {
0034         throwInvalidHandleProv();
0035       }
0036     }
0037     return prov_->productID();
0038   }
0039 }  // namespace edm