1 #ifndef DataFormats_Common_Ref_h 2 #define DataFormats_Common_Ref_h 115 #include "boost/functional.hpp" 118 #include <type_traits> 124 template <
typename,
typename =
void>
126 template <
typename T>
129 template <
typename C,
typename K>
132 using comparison_functor =
typename C::key_compare;
133 return comparison_functor()(lhs, rhs);
139 template <
typename C,
typename T,
typename F>
142 template <
typename T>
145 template <
typename C,
163 typedef typename boost::binary_traits<F>::second_argument_type
argument_type;
184 Ref(
C const* product,
key_type itemKey,
bool setNow =
true);
287 #define REF_FOR_VECTOR_ARGS \ 288 std::vector<E>, typename refhelper::ValueTrait<std::vector<E>>::value, \ 289 typename refhelper::FindTrait<std::vector<E>, typename refhelper::ValueTrait<std::vector<E>>::value>::value 291 template <
typename E>
302 friend class
RefVector<RefVector<std::vector<E>, T, F>, T, VF>;
303 friend class
RefVector<RefVector<std::vector<E>, T, F>, T, VBF>;
312 typedef typename boost::binary_traits<F>::second_argument_type
argument_type;
360 :
product_(iProductID,
item, nullptr, transient, itemKey) {}
440 template <
typename C,
typename T,
typename F>
442 : product_(
handle.
id(), nullptr, nullptr,
false), index_(itemKey) {
445 refitem::findRefItem<C, T, F, key_type>(product_,
handle.product(), itemKey);
449 template <
typename E>
454 refitem::findRefItem<product_type, value_type, finder_type, key_type>(
455 product_.toRefCore(),
handle.product(), itemKey);
459 template <
typename C,
typename T,
typename F>
461 : product_(
handle.
id(), nullptr, nullptr,
false), index_(itemKey) {
464 refitem::findRefItem<C, T, F, key_type>(product_,
handle.product(), itemKey);
468 template <
typename E>
473 refitem::findRefItem<product_type, value_type, finder_type, key_type>(
474 product_.toRefCore(),
handle.product(), itemKey);
484 template <
typename C,
typename T,
typename F>
488 if (iProduct !=
nullptr) {
489 refitem::findRefItem<C, T, F, key_type>(product_, iProduct, itemKey);
493 template <
typename E>
496 if (iProduct !=
nullptr) {
497 refitem::findRefItem<product_type, value_type, finder_type, key_type>(product_.toRefCore(), iProduct, itemKey);
503 template <
typename C,
typename T,
typename F>
505 : product_(
handle.
id(), nullptr, nullptr,
true), index_(itemKey) {
508 refitem::findRefItem<C, T, F, key_type>(product_,
handle.product(), itemKey);
511 template <
typename E>
513 : product_(
handle.
id(), nullptr, nullptr,
true, itemKey) {
516 refitem::findRefItem<product_type, value_type, finder_type, key_type>(
517 product_.toRefCore(),
handle.product(), itemKey);
521 template <
typename C,
typename T,
typename F>
523 : product_(refProd.
id(), nullptr, refProd.refCore().
productGetter(), refProd.refCore().isTransient()),
526 refitem::findRefItem<C, T, F, key_type>(
531 template <
typename E>
533 : product_(refProd.
id(), nullptr, refProd.refCore().
productGetter(), refProd.refCore().isTransient(), itemKey) {
535 refitem::findRefItem<product_type, value_type, finder_type, key_type>(
536 product_.toRefCore(),
static_cast<product_type
const*
>(refProd.refCore().productPtr()), itemKey);
540 template <
typename C,
typename T,
typename F>
542 if (product_.isAvailable()) {
545 return isThinnedAvailable<C>(product_, index_);
548 template <
typename E>
550 if (product_.isAvailable()) {
553 return isThinnedAvailable<std::vector<E>>(product_.toRefCore(),
key());
557 template <
typename C,
typename T,
typename F>
559 return *getRefPtr<C, T, F>(product_, index_);
561 template <
typename E>
563 return *getRefPtr<REF_FOR_VECTOR_ARGS>(product_.toRefCore(),
key());
567 template <
typename C,
typename T,
typename F>
569 return getRefPtr<C, T, F>(product_, index_);
571 template <
typename E>
573 return getRefPtr<REF_FOR_VECTOR_ARGS>(product_.toRefCore(),
key());
576 template <
typename C,
typename T,
typename F>
578 return lhs.key() == rhs.key() && lhs.refCore() == rhs.refCore();
581 template <
typename C,
typename T,
typename F>
583 return !(lhs == rhs);
586 template <
typename C,
typename T,
typename F>
587 inline bool operator<(Ref<C, T, F>
const& lhs,
Ref<C, T, F> const& rhs) {
590 return (lhs.refCore() == rhs.refCore() ? compare_key<C>(lhs.key(), rhs.key()) : lhs.refCore() < rhs.refCore());
bool hasProductCache() const
Returns true if container referenced by the Ref has been cached.
RefCore const & refCore() const
refhelper::ValueTrait< std::vector< E > >::value T
std::remove_cv< typename std::remove_reference< argument_type >::type >::type key_type
edm::Ref< Container > Ref
ProductID id() const
Accessor for product ID.
void checkTypeAtCompileTime(C const *)
EDProductGetter const * productGetter() const
Accessor for product getter.
bool operator!=(Ref< C, T, F > const &lhs, Ref< C, T, F > const &rhs)
T const & operator*() const
Dereference operator.
refhelper::FindRefVectorUsingAdvance< RefVector< std::vector< E >, T, F > > VF
Ref(ProductID const &iProductID, T const *item, key_type itemKey, product_type const *)
Constructor for use in the various X::fillView(...) functions.
bool operator!() const
Checks for null.
bool operator==(Ref< C, T, F > const &lhs, Ref< C, T, F > const &rhs)
boost::binary_traits< F >::second_argument_type argument_type
void checkTypeAtCompileTime(product_type const *)
bool isNonnull() const
Checks for non-null.
T const * operator->() const
Member dereference operator.
Ref(ProductID const &iProductID, T const *item, key_type itemKey, bool transient)
Ref()
Default constructor needed for reading from persistent store. Not for direct use. ...
EDProductGetter const * mustBeNonZero(EDProductGetter const *prodGetter, std::string refType, ProductID const &productID)
#define REF_FOR_VECTOR_ARGS
#define CMS_CLASS_VERSION(_version_)
void const * productPtr() const
EDProductGetter const * productGetter() const
Accessor for product getter.
key_type key() const
Accessor for product key.
Ref(ProductID const &iId)
value_type const element_type
RefCore const & refCore() const
bool isTransient() const
Checks if this ref is transient (i.e. not persistable).
bool operator!() const
Checks for null.
bool compare_key(K const &lhs, K const &rhs)
bool isNonnull() const
Checks for non-null.
Ref(ProductID const &productID, key_type itemKey, EDProductGetter const *prodGetter)
std::vector< E > product_type
for export
key_type key() const
Accessor for product key.
static key_type invalidKey()
Ref(ProductID const &iProductID, T const *item, key_type itemKey)
RefCore const & refCore() const
refhelper::FindRefVectorUsingAdvance< RefToBaseVector< T > > VBF
bool isTransient() const
Checks if this ref is transient (i.e. not persistable).
bool isNull() const
Checks for null.
refhelper::FindTrait< std::vector< E >, typename refhelper::ValueTrait< std::vector< E > >::value >::value F
refhelper::FindRefVectorUsingAdvance< RefVector< C, T, F > > VF
refhelper::ValueTrait< std::vector< E > >::value value_type
refhelper::FindRefVectorUsingAdvance< RefToBaseVector< T > > VBF
boost::binary_traits< F >::second_argument_type argument_type
Ref(ProductID const &iProductID, T const *item, key_type itemKey, bool transient)
bool isNull() const
Checks for null.
Ref(ProductID const &iId)
Ref(ProductID const &iProductID, T const *item, key_type itemKey)
Ref(ProductID const &productID, key_type itemKey, EDProductGetter const *prodGetter)
Ref()
Default constructor needed for reading from persistent store. Not for direct use. ...
bool hasProductCache() const
Returns true if container referenced by the Ref has been cached.
RefCoreWithIndex product_
EDProductGetter const * productGetter(std::atomic< void const *> const &iCache)
MatrixMeschach operator*(const MatrixMeschach &mat1, const MatrixMeschach &mat2)
FindUsingAdvance< C, T > value
static uInt32 F(BLOWFISH_CTX *ctx, uInt32 x)
Ref(ProductID const &iProductID, T const *item, key_type itemKey, C const *)
Constructor for use in the various X::fillView(...) functions.
ProductID id() const
Accessor for product ID.
EDProductGetter const * productGetter() const
edm::RefVector< Container > RefVector