1 #ifndef DataFormats_Common_Ptr_h 2 #define DataFormats_Common_Ptr_h 35 #include <type_traits> 101 :
core_(productID,
item, nullptr, transient),
key_(item_key) {}
111 template <
typename U>
126 template <
typename U>
174 void const*
product()
const {
return nullptr; }
185 if (getter !=
nullptr) {
187 unsigned int iKey =
key_;
188 if (
prod ==
nullptr) {
190 if (not optionalProd.has_value()) {
191 if (throwIfNotFound) {
197 std::tie(
prod, iKey) = *optionalProd;
199 void const* ad =
nullptr;
200 prod->setPtr(
typeid(
T), iKey, ad);
209 template <
typename T>
210 template <
typename C>
212 assert(iProduct !=
nullptr);
213 typename C::const_iterator
it = iProduct->begin();
214 std::advance(
it, iKey);
220 template <
typename T>
223 return *
reinterpret_cast<T const*
>(core_.productPtr());
227 template <
typename T>
230 return reinterpret_cast<T const*
>(core_.productPtr());
233 template <
typename T>
236 return hasProductCache();
239 template <
typename T>
241 return lhs.refCore() == rhs.refCore() && lhs.key() == rhs.key();
244 template <
typename T>
246 return !(lhs == rhs);
249 template <
typename T>
250 inline bool operator<(Ptr<T>
const& lhs,
Ptr<T> const& rhs) {
253 return (lhs.refCore() == rhs.refCore() ? lhs.key() < rhs.key() : lhs.refCore() < rhs.refCore());
263 template <
typename T>
266 std::vector<void const*>& pointers,
268 pointers.reserve(
obj.size());
270 for (
auto const&
p :
obj) {
271 if (
p.isAvailable()) {
272 pointers.push_back(
p.get());
274 pointers.push_back(
nullptr);
constexpr bool operator==(ELseverityLevel const &e1, ELseverityLevel const &e2) noexcept
Ptr(Handle< C > const &handle, key_type itemKey, bool=true)
void fillView(AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper > const &obj, ProductID const &id, std::vector< void const *> &pointers, FillViewHelperVector &helpers)
static const element_type * address(const iter &i)
ProductID id() const
Accessor for product ID.
Ptr(C const *iProduct, key_type iItemKey, bool=true)
requires std::is_base_of_v< U, T > Ptr(Ptr< U > const &iOther)
void getData_(bool throwIfNotFound=true) const
EDProductGetter const * mustBeNonZero(EDProductGetter const *prodGetter, std::string refType, ProductID const &productID)
#define CMS_CLASS_VERSION(_version_)
void const * productPtr() const
Ptr(OrphanHandle< C > const &handle, key_type itemKey, bool=true)
T const * operator->() const
Member dereference operator.
T const * getItem_(C const *product, key_type iKey)
requires std::is_base_of_v< T, U > Ptr(Ptr< U > const &iOther)
Ptr(TestHandle< C > const &handle, key_type itemKey, bool=true)
bool isNull() const
Checks for null.
void const * product() const
void setProductPtr(void const *prodPtr) const
Ptr(T const *item, key_type iItemKey)
bool isNonnull() const
Checks for non-null.
T const & operator*() const
Dereference operator.
def template(fileName, svg, replaceme="REPLACEME")
bool operator!() const
Checks for null.
constexpr bool operator!=(ELseverityLevel const &e1, ELseverityLevel const &e2) noexcept
virtual WrapperBase const * getIt(ProductID const &) const =0
Ptr(ProductID const &productID, T const *item, key_type item_key, bool transient)
T const * get() const
Returns C++ pointer to the item.
Ptr(ProductID const &productID, T const *item, key_type item_key)
bool hasProductCache() const
Ptr(ProductID const &productID, key_type itemKey, EDProductGetter const *prodGetter)
Ptr(ProductID const &iId)
void productNotFoundException(std::type_info const &type) const
EDProductGetter const * productGetter() const
Accessor for product getter.
virtual std::optional< std::tuple< WrapperBase const *, unsigned int > > getThinnedProduct(ProductID const &, unsigned int key) const =0
RefCore const & refCore() const
EDProductGetter const * productGetter() const
bool isTransient() const
Checks if this Ptr is transient (i.e. not persistable).
std::vector< std::pair< edm::ProductID, unsigned long > > FillViewHelperVector