1 #ifndef DataFormats_Common_Ptr_h 2 #define DataFormats_Common_Ptr_h 35 #include "boost/type_traits/is_base_of.hpp" 36 #include "boost/utility/enable_if.hpp" 71 Ptr(
C const* iProduct, key_type iItemKey,
bool =
true):
75 Ptr(
T const* item, key_type iItemKey):
105 Ptr(
ProductID const& productID,
T const* item, key_type item_key,
bool transient) :
142 dynamic_cast<
T const*>(iOther.
get()),
160 T const*
get()
const {
205 if(getter !=
nullptr) {
207 unsigned int iKey =
key_;
208 if(prod ==
nullptr) {
210 if(prod ==
nullptr) {
211 if(throwIfNotFound) {
218 void const* ad =
nullptr;
219 prod->
setPtr(
typeid(
T), iKey, ad);
231 assert (iProduct != 0);
232 typename C::const_iterator it = iProduct->begin();
233 std::advance(it,iKey);
268 return lhs.refCore() == rhs.refCore() && lhs.key() == rhs.key();
275 return !(lhs == rhs);
281 operator<(Ptr<T>
const& lhs,
Ptr<T> const& rhs) {
284 return (lhs.refCore() == rhs.refCore() ? lhs.key() < rhs.key() : lhs.refCore() < rhs.refCore());
294 template <
typename T>
299 std::vector<void const*>& pointers,
301 pointers.reserve(
obj.size());
302 helpers.reserve(
obj.size());
303 for (
auto const&
p:
obj) {
304 if(
p.isAvailable()) {
305 pointers.push_back(
p.get());
307 pointers.push_back(
nullptr);
309 helpers.emplace_back(
p.id(),
p.key());
void getData_(bool throwIfNotFound=true) const
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
Ptr(Ptr< U > const &iOther, typename boost::enable_if_c< boost::is_base_of< T, U >::value >::type *=0)
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.
virtual WrapperBase const * getThinnedProduct(ProductID const &, unsigned int &key) const =0
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.
bool operator!=(debugging_allocator< X > const &, debugging_allocator< Y > const &)
#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)
bool operator==(debugging_allocator< X > const &, debugging_allocator< Y > const &)
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
def template(fileName, svg, replaceme="REPLACEME")
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)
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
Ptr(Ptr< U > const &iOther, typename boost::enable_if_c< boost::is_base_of< U, T >::value >::type *=0)
bool operator!() const
Checks for null.
std::vector< std::pair< edm::ProductID, unsigned long > > FillViewHelperVector