1 #ifndef art_Framework_Principal_Handle_h 2 #define art_Framework_Principal_Handle_h 37 #include "cetlib_except/demangle.h" 38 #include "cetlib_except/exception.h" 66 template <
typename H,
typename... T>
80 template <
class T,
class U>
85 template <
class T,
class U>
90 template <
class T,
class U>
106 explicit constexpr
Handle() =
112 T
const* operator->()
const;
113 T
const* product()
const;
116 bool isValid()
const;
121 std::shared_ptr<art::Exception const> whyFailed()
const;
128 T
const* prod_{
nullptr};
130 std::shared_ptr<art::Exception const> whyFailed_{
nullptr};
140 if (gqr.succeeded()) {
141 auto const wrapperPtr =
dynamic_cast<Wrapper<T> const*
>(
143 if (wrapperPtr ==
nullptr) {
145 e <<
"Product retrieval via Handle<T> succeeded for product:\n" 147 <<
"but an attempt to interpret it as an object of type '" 148 << cet::demangle_symbol(
typeid(T).name()) <<
"' failed.\n";
149 whyFailed_ = std::make_shared<art::Exception const>(std::move(
e));
151 prod_ = wrapperPtr->product();
172 if (
prod_ ==
nullptr)
174 <<
"Attempt to de-reference product that points to 'nullptr'";
219 inline std::shared_ptr<art::Exception const>
256 template <
typename T>
270 operator T
const*()
const;
280 std::shared_ptr<art::Exception const>
whyFailed()
const;
298 <<
"Attempt to create ValidHandle with null pointer";
355 inline std::shared_ptr<art::Exception const>
358 return std::shared_ptr<art::Exception const>();
375 std::string
const& errMsg =
376 "Attempt to retrieve range set from invalid handle.";
378 return h.provenance()->rangeOfValidity();
381 template <
class T,
class U>
385 std::string
const& errMsg =
386 "Attempt to compare range sets where one or both handles are invalid.";
391 template <
class T,
class U>
395 std::string
const& errMsg =
396 "Attempt to compare range sets where one or both handles are invalid.";
401 template <
class T,
class U>
405 std::string
const& errMsg =
406 "Attempt to compare range sets where one or both handles are invalid.";
std::enable_if_t< detail::is_handle< T >::value, RangeSet const & > range_of_validity(T const &h)
void throw_if_invalid(std::string const &)
std::shared_ptr< art::Exception const > whyFailed_
void swap(Handle< T > &other)
T const & operator*() const
T const * product() const
ProductID const & productID() const
T const * product() const
void swap(Handle< T > &a, Handle< T > &b)
Provenance const * provenance() const
T const * operator->() const
void convert_handle(GroupQueryResult const &, Handle< T > &)
std::enable_if_t< detail::are_handles< T, U >::value, bool > disjoint_ranges(T const &a, U const &b)
Provenance const * provenance() const
constexpr Handle()=default
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
std::string value(boost::any const &)
T const * operator->() const
void swap(ValidHandle< T > &a, ValidHandle< T > &b)
T const & operator*() const
std::enable_if_t< detail::are_handles< T, U >::value, bool > overlapping_ranges(T const &a, U const &b)
std::enable_if_t< detail::are_handles< T, U >::value, bool > same_ranges(T const &a, U const &b)
std::shared_ptr< art::Exception const > whyFailed() const
std::shared_ptr< art::Exception const > whyFailed() const
BranchDescription const & productDescription() const
QuadExpr operator*(double v, const QuadExpr &e)
void swap(ValidHandle< T > &other)