1 #ifndef art_Framework_Principal_Handle_h 2 #define art_Framework_Principal_Handle_h 42 #include "cetlib_except/demangle.h" 43 #include "cetlib_except/exception.h" 69 template <
typename... T>
73 bool const all_valid =
true && (... && t.isValid());
83 template <
class T,
class U>
84 std::enable_if_t<detail::are_handles_v<T, U>,
bool>
same_ranges(T
const& a,
86 template <
class T,
class U>
90 template <
class T,
class U>
104 explicit constexpr
Handle() =
114 T
const* operator->()
const;
115 T
const* product()
const;
118 explicit operator bool()
const noexcept;
119 bool isValid()
const noexcept;
124 std::shared_ptr<art::Exception const> whyFailed()
const;
130 bool removeProduct();
133 T
const* prod_{
nullptr};
134 cet::exempt_ptr<Group> group_{
nullptr};
136 std::shared_ptr<art::Exception const> whyFailed_{
nullptr};
146 if (gqr.succeeded()) {
147 auto const wrapperPtr =
dynamic_cast<Wrapper<T> const*
>(
149 if (wrapperPtr !=
nullptr) {
150 prod_ = wrapperPtr->product();
153 e <<
"Product retrieval via Handle<T> succeeded for product:\n" 155 <<
"but an attempt to interpret it as an object of type '" 156 << cet::demangle_symbol(
typeid(T).name()) <<
"' failed.\n";
157 whyFailed_ = std::make_shared<art::Exception const>(std::move(
e));
179 if (
prod_ ==
nullptr)
181 <<
"Attempt to de-reference product that points to 'nullptr'.\n";
230 inline std::shared_ptr<art::Exception const>
236 template <
typename T>
267 group_->removeCachedProduct();
287 template <
typename T>
304 operator T
const*()
const;
314 std::shared_ptr<art::Exception const>
whyFailed()
const;
335 if (
prod_ ==
nullptr) {
337 <<
"Attempt to create ValidHandle with null pointer";
397 inline std::shared_ptr<art::Exception const>
400 return std::shared_ptr<art::Exception const>();
410 template <
typename T>
421 std::enable_if_t<art::detail::is_handle_v<T>,
art::RangeSet const&>
424 std::string
const& errMsg =
425 "Attempt to retrieve range set from invalid handle.";
427 return h.provenance()->rangeOfValidity();
430 template <
class T,
class U>
431 std::enable_if_t<art::detail::are_handles_v<T, U>,
bool>
434 std::string
const& errMsg =
435 "Attempt to compare range sets where one or both handles are invalid.";
440 template <
class T,
class U>
441 std::enable_if_t<art::detail::are_handles_v<T, U>,
bool>
444 std::string
const& errMsg =
445 "Attempt to compare range sets where one or both handles are invalid.";
450 template <
class T,
class U>
451 std::enable_if_t<art::detail::are_handles_v<T, U>,
bool>
454 std::string
const& errMsg =
455 "Attempt to compare range sets where one or both handles are invalid.";
461 template <
typename T>
541 template <
typename T>
Handle & operator=(Handle const &)=default
BranchDescription const & productDescription() const noexcept
bool isValid() const noexcept
EDProductGetter const * productGetter_
ProductID productID() const noexcept
std::shared_ptr< art::Exception const > whyFailed_
std::enable_if_t< detail::are_handles_v< T, U >, bool > overlapping_ranges(T const &a, U const &b)
void swap(Handle< T > &other)
T const & operator*() const
T const * operator->() const
T const * product() const
T const * product() const
EDProductGetter const * productGetter() const noexcept
bool isValid() const noexcept
std::enable_if_t< detail::are_handles_v< T, U >, bool > disjoint_ranges(T const &a, U const &b)
T const * product() const
EDProductGetter const * productGetter_
void swap(Handle< T > &a, Handle< T > &b)
Provenance const * provenance() const
T const * operator->() const
void convert_handle(GroupQueryResult const &, Handle< T > &)
Provenance const * provenance() const
constexpr Handle()=default
void throw_if_invalid(std::string const &msg, T const &...t)
T const & operator*() const
cet::exempt_ptr< Group > result() const
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
T const * operator->() const
void swap(ValidHandle< T > &a, ValidHandle< T > &b)
T const & operator*() const
std::enable_if_t< detail::are_handles_v< T, U >, bool > same_ranges(T const &a, U const &b)
EDProductGetter const * productGetter() const noexcept
PutHandle(T const *prod, EDProductGetter const *productGetter, ProductID id)
std::shared_ptr< art::Exception const > whyFailed() const
bool produced() const noexcept
std::shared_ptr< art::Exception const > whyFailed() const
EDProductGetter const * productGetter() const noexcept
QuadExpr operator*(double v, const QuadExpr &e)
void swap(ValidHandle< T > &other)
std::enable_if_t< detail::is_handle_v< T >, RangeSet const & > range_of_validity(T const &h)
cet::exempt_ptr< Group > group_