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>
125 template <
typename U>
170 void const*
product()
const {
return nullptr; }
181 if (getter !=
nullptr) {
183 unsigned int iKey =
key_;
184 if (prod ==
nullptr) {
186 if (not optionalProd.has_value()) {
187 if (throwIfNotFound) {
193 std::tie(prod, iKey) = *optionalProd;
195 void const* ad =
nullptr;
196 prod->
setPtr(
typeid(
T), iKey, ad);
205 template <
typename T>
206 template <
typename C>
208 assert(iProduct !=
nullptr);
209 typename C::const_iterator it = iProduct->begin();
210 std::advance(it, iKey);
216 template <
typename T>
219 return *
reinterpret_cast<T const*
>(core_.productPtr());
223 template <
typename T>
226 return reinterpret_cast<T const*
>(core_.productPtr());
229 template <
typename T>
232 return hasProductCache();
235 template <
typename T>
237 return lhs.refCore() == rhs.refCore() && lhs.key() == rhs.key();
240 template <
typename T>
242 return !(lhs == rhs);
245 template <
typename T>
246 inline bool operator<(Ptr<T>
const& lhs,
Ptr<T> const& rhs) {
249 return (lhs.refCore() == rhs.refCore() ? lhs.key() < rhs.key() : lhs.refCore() < rhs.refCore());
259 template <
typename T>
262 std::vector<void const*>& pointers,
264 pointers.reserve(
obj.size());
265 helpers.reserve(
obj.size());
266 for (
auto const&
p :
obj) {
267 if (
p.isAvailable()) {
268 pointers.push_back(
p.get());
270 pointers.push_back(
nullptr);
272 helpers.emplace_back(
p.id(),
p.key());
void getData_(bool throwIfNotFound=true) const
constexpr bool operator==(ELseverityLevel const &e1, ELseverityLevel const &e2) noexcept
Ptr(Handle< C > const &handle, key_type itemKey, bool=true)
EDProductGetter const * mustBeNonZero(EDProductGetter const *prodGetter, std::string refType, ProductID const &productID)
void setProductPtr(void const *prodPtr) const
static const element_type * address(const iter &i)
void setPtr(std::type_info const &iToType, unsigned long iIndex, void const *&oPtr) const
Ptr(C const *iProduct, key_type iItemKey, bool=true)
T const * get() const
Returns C++ pointer to the item.
T const * getItem_(C const *product, key_type iKey)
void const * product() const
EDProductGetter const * productGetter() const
Accessor for product getter.
T const * operator->() const
Member dereference operator.
#define CMS_CLASS_VERSION(_version_)
Ptr(OrphanHandle< C > const &handle, key_type itemKey, bool=true)
T const & operator*() const
Dereference operator.
Ptr(TestHandle< C > const &handle, key_type itemKey, bool=true)
bool isTransient() const
Checks if this Ptr is transient (i.e. not persistable).
Ptr(T const *item, key_type iItemKey)
void const * productPtr() const
void fillView(AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper > const &obj, ProductID const &id, std::vector< void const * > &pointers, FillViewHelperVector &helpers)
bool isNull() const
Checks for null.
RefCore const & refCore() const
constexpr bool operator!=(ELseverityLevel const &e1, ELseverityLevel const &e2) noexcept
virtual WrapperBase const * getIt(ProductID const &) const =0
void productNotFoundException(std::type_info const &type) const
Ptr(ProductID const &productID, T const *item, key_type item_key, bool transient)
bool isNonnull() const
Checks for non-null.
Ptr(ProductID const &productID, T const *item, key_type item_key)
Ptr(Ptr< U > const &iOther, std::enable_if_t< std::is_base_of< U, T >::value > *=nullptr)
bool hasProductCache() const
Ptr(ProductID const &productID, key_type itemKey, EDProductGetter const *prodGetter)
Ptr(ProductID const &iId)
ProductID id() const
Accessor for product ID.
EDProductGetter const * productGetter() const
virtual std::optional< std::tuple< WrapperBase const *, unsigned int > > getThinnedProduct(ProductID const &, unsigned int key) const =0
bool operator!() const
Checks for null.
Ptr(Ptr< U > const &iOther, std::enable_if_t< std::is_base_of< T, U >::value > *=nullptr)
std::vector< std::pair< edm::ProductID, unsigned long > > FillViewHelperVector