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" 61 template <
typename...
T>
65 bool const all_valid =
true && (... && t.isValid());
75 template <
class T,
class U>
79 template <
class T,
class U>
83 template <
class T,
class U>
97 explicit constexpr
Handle() =
107 T const* operator->()
const;
108 T const* product()
const;
111 explicit operator bool()
const noexcept;
112 bool isValid()
const noexcept;
117 std::shared_ptr<art::Exception const> whyFailed()
const;
124 T const* prod_{
nullptr};
126 std::shared_ptr<art::Exception const> whyFailed_{
nullptr};
136 if (gqr.succeeded()) {
139 if (wrapperPtr !=
nullptr) {
140 prod_ = wrapperPtr->product();
143 e <<
"Product retrieval via Handle<T> succeeded for product:\n" 145 <<
"but an attempt to interpret it as an object of type '" 146 << cet::demangle_symbol(
typeid(
T).
name()) <<
"' failed.\n";
168 if (
prod_ ==
nullptr)
170 <<
"Attempt to de-reference product that points to 'nullptr'.\n";
218 inline std::shared_ptr<art::Exception const>
255 template <
typename T>
270 operator T const*()
const;
280 std::shared_ptr<art::Exception const>
whyFailed()
const;
297 if (prod ==
nullptr) {
299 <<
"Attempt to create ValidHandle with null pointer";
357 inline std::shared_ptr<art::Exception const>
360 return std::shared_ptr<art::Exception const>();
378 "Attempt to retrieve range set from invalid handle.";
380 return h.provenance()->rangeOfValidity();
383 template <
class T,
class U>
388 "Attempt to compare range sets where one or both handles are invalid.";
393 template <
class T,
class U>
398 "Attempt to compare range sets where one or both handles are invalid.";
403 template <
class T,
class U>
408 "Attempt to compare range sets where one or both handles are invalid.";
Handle & operator=(Handle const &)=default
std::enable_if_t< detail::is_handle< T >::value, RangeSet const & > range_of_validity(T const &h)
BranchDescription const & productDescription() const noexcept
bool isValid() const noexcept
void msg(const char *fmt,...)
ProductID productID() const noexcept
std::shared_ptr< art::Exception const > whyFailed_
void swap(Handle< T > &other)
T const & operator*() const
T const * product() const
bool isValid() const noexcept
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
void throw_if_invalid(std::string const &msg, T const &...t)
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< 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
vector< vector< double > > clear
QuadExpr operator*(double v, const QuadExpr &e)
void swap(ValidHandle< T > &other)