1 #ifndef canvas_Persistency_Common_ProductPtr_h 2 #define canvas_Persistency_Common_ProductPtr_h 38 #include "cetlib_except/demangle.h" 42 #include <type_traits> 58 :
core_{handle.
id(), handle.product(),
nullptr}
62 <<
"Attempt to construct a ProductPtr from a Handle with invalid " 65 "default-constructed ProductPtr is what you want?";
71 :
core_{productID,
nullptr, prodGetter}
77 std::enable_if_t<std::is_base_of_v<T, U>>* =
nullptr)
79 (pu.hasCache() ?
static_cast<T const*
>(pu.get()) :
nullptr),
85 std::enable_if_t<std::is_base_of_v<U, T>>* =
nullptr)
86 :
core_{pu.id(),
static_cast<T const*
>(pu.get()),
nullptr}
150 static constexpr
short 164 if (product ==
nullptr) {
166 e <<
"A request to resolve a ProductPtr to a product of type: " 167 << cet::demangle_symbol(
typeid(T).name()) <<
" with ProductID " 169 <<
"\ncannot be satisfied because the product cannot be found.\n";
171 e <<
"The productGetter was not set -- are you trying to " 172 "dereference a ProductPtr during mixing?\n";
174 e <<
"Probably the branch containing the product is not stored in " 179 auto wrapped_product =
dynamic_cast<Wrapper<T> const*
>(product);
180 if (wrapped_product ==
nullptr) {
182 <<
"A request to resolve a Product Ptr to a product of type: " 183 << cet::demangle_symbol(
typeid(T).name()) <<
" with ProductID" 184 <<
core_.
id() <<
"\ncannot be satisfied due to a type mismatch.\n";
186 return wrapped_product->product();
194 template <
typename H>
197 template <
typename T,
typename U>
198 std::enable_if_t<std::is_same_v<T, U> || std::is_base_of_v<T, U> ||
199 std::is_base_of_v<U, T>,
203 return lhs.refCore() == rhs.refCore();
206 template <
typename T,
typename U>
207 std::enable_if_t<std::is_same_v<T, U> || std::is_base_of_v<T, U> ||
208 std::is_base_of_v<U, T>,
212 return !(lhs == rhs);
215 template <
typename T,
typename U>
216 std::enable_if_t<std::is_same_v<T, U> || std::is_base_of_v<T, U> ||
217 std::is_base_of_v<U, T>,
221 return lhs.
refCore() < rhs.refCore();
224 template <
typename T>
226 operator<<(std::ostream& os, ProductPtr<T>
const& p)
228 os <<
"(" << p.
id() <<
")";
EDProduct const * getIt() const
EDProductGetter const * productGetter() const noexcept
ProductPtr(H) -> ProductPtr< typename H::element_type >
bool operator==(Provenance const &a, Provenance const &b) noexcept
ProductPtr(ProductPtr< U > const &pu, std::enable_if_t< std::is_base_of_v< T, U >> *=nullptr)
ProductPtr(H const &handle)
bool operator!=(ScheduleID const left, ScheduleID const right) noexcept
T const & operator*() const
ProductPtr(ProductID const &productID, EDProductGetter const *prodGetter)
constexpr bool isNull() const noexcept
T const & const_reference
T const * product_() const
bool hasCache() const noexcept
EDProductGetter const * productGetter() const noexcept
static constexpr short Class_Version() noexcept
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
RefCore const & refCore() const noexcept
void const * productPtr() const noexcept
void setProductPtr(void const *prodPtr) const noexcept
constexpr ProductID id() const noexcept
ProductID id() const noexcept
T const * operator->() const
ProductPtr(ProductPtr< U > const &pu, std::enable_if_t< std::is_base_of_v< U, T >> *=nullptr)