1 #ifndef DataFormats_Common_Ref_h 2 #define DataFormats_Common_Ref_h 115 #include "boost/functional.hpp" 116 #include "boost/call_traits.hpp" 117 #include "boost/type_traits.hpp" 118 #include "boost/mpl/has_xxx.hpp" 119 #include "boost/utility/enable_if.hpp" 122 #include <type_traits> 124 BOOST_MPL_HAS_XXX_TRAIT_DEF(key_compare)
127 typename
boost::enable_if<has_key_compare<C>,
bool>::
type 129 typedef typename C::key_compare comparison_functor;
130 return comparison_functor()(lhs, rhs);
133 template <
typename C,
typename K>
134 typename boost::disable_if<has_key_compare<C>,
bool>
::type 142 template<
typename C,
typename T,
typename F>
148 template <
typename C,
166 typedef typename boost::binary_traits<F>::second_argument_type
argument_type;
187 Ref(
C const* product, key_type itemKey,
bool setNow=
true);
208 Ref(
ProductID const& iProductID, T
const* item, key_type itemKey,
C const* ) :
216 Ref(
ProductID const& iProductID, T
const* item, key_type itemKey,
bool transient) :
243 T
const*
get()
const {
301 #define REF_FOR_VECTOR_ARGS std::vector<E>,typename refhelper::ValueTrait<std::vector<E> >::value,typename refhelper::FindTrait<std::vector<E>, typename refhelper::ValueTrait<std::vector<E> >::value>::value 303 template <
typename E>
313 friend class
RefVector<RefVector<std::vector<E>, T, F>, T, VF>;
314 friend class
RefVector<RefVector<std::vector<E>, T, F>, T, VBF>;
323 typedef typename boost::binary_traits<F>::second_argument_type
argument_type;
400 T
const*
get()
const {
461 template <
typename C,
typename T,
typename F>
466 refitem::findRefItem<C, T, F, key_type>(
product_, handle.
product(), itemKey);
470 template <
typename E>
475 refitem::findRefItem<product_type, value_type, finder_type, key_type>(
product_.toRefCore(),
481 template <
typename C,
typename T,
typename F>
486 refitem::findRefItem<C, T, F, key_type>(
product_, handle.
product(), itemKey);
490 template <
typename E>
495 refitem::findRefItem<product_type, value_type, finder_type, key_type>(
product_.toRefCore(),
507 template <
typename C,
typename T,
typename F>
511 if(iProduct !=
nullptr) {
512 refitem::findRefItem<C, T, F, key_type>(
product_, iProduct, itemKey);
516 template <
typename E>
520 if(iProduct !=
nullptr) {
521 refitem::findRefItem<product_type, value_type, finder_type, key_type>(
product_.toRefCore(), iProduct, itemKey);
527 template <
typename C,
typename T,
typename F>
531 if(itemKey == key_traits<key_type>::value)
return;
532 refitem::findRefItem<C, T, F, key_type>(
product_, handle.
product(), itemKey);
535 template <
typename E>
539 if(itemKey == key_traits<key_type>::value)
return;
540 refitem::findRefItem<product_type, value_type, finder_type, key_type>(
product_.toRefCore(),
546 template <
typename C,
typename T,
typename F>
552 if(refProd.
refCore().productPtr() !=
nullptr && itemKey != key_traits<key_type>::value) {
553 refitem::findRefItem<C, T, F, key_type>(
product_,
559 template <
typename E>
562 product_(refProd.id(),
nullptr, refProd.refCore().productGetter(), refProd.refCore().isTransient(), itemKey) {
564 if(refProd.refCore().productPtr() !=
nullptr && itemKey != key_traits<key_type>::value) {
565 refitem::findRefItem<product_type, value_type, finder_type, key_type>(
567 static_cast<product_type const*
>(refProd.refCore().productPtr()),
572 template <
typename C,
typename T,
typename F>
582 template <
typename E>
589 return isThinnedAvailable<std::vector<E> >(
product_.toRefCore(),
key());
593 template <
typename C,
typename T,
typename F>
599 template <
typename E>
603 return *getRefPtr<REF_FOR_VECTOR_ARGS>(
product_.toRefCore(),
key());
607 template <
typename C,
typename T,
typename F>
613 template <
typename E>
617 return getRefPtr<REF_FOR_VECTOR_ARGS>(
product_.toRefCore(),
key());
620 template <
typename C,
typename T,
typename F>
624 return lhs.key() == rhs.key() && lhs.refCore() == rhs.refCore() ;
627 template <
typename C,
typename T,
typename F>
631 return !(lhs == rhs);
634 template <
typename C,
typename T,
typename F>
640 return (lhs.refCore() == rhs.refCore() ? compare_key<C>(lhs.key(), rhs.key()) : lhs.refCore() < rhs.refCore());
T const * product() const
refhelper::ValueTrait< std::vector< E > >::value T
EDProductGetter const * mustBeNonZero(EDProductGetter const *prodGetter, std::string refType, ProductID const &productID)
std::remove_cv< typename std::remove_reference< argument_type >::type >::type key_type
edm::Ref< Container > Ref
bool isNonnull() const
Checks for non-null.
void checkTypeAtCompileTime(C const *)
boost::enable_if< has_key_compare< C >, bool >::type compare_key(K const &lhs, K const &rhs)
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.
boost::binary_traits< F >::second_argument_type argument_type
void checkTypeAtCompileTime(product_type const *)
bool isTransient() const
Checks if this ref is transient (i.e. not persistable).
bool hasProductCache() const
Returns true if container referenced by the Ref has been cached.
RefCore const & refCore() const
RefCore const & refCore() const
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. ...
key_type key() const
Accessor for product key.
bool isNull() const
Checks for null.
#define REF_FOR_VECTOR_ARGS
#define CMS_CLASS_VERSION(_version_)
Ref(ProductID const &iId)
ProductID id() const
Accessor for product ID.
value_type const element_type
bool isTransient() const
Checks if this ref is transient (i.e. not persistable).
bool operator==(debugging_allocator< X > const &, debugging_allocator< Y > const &) noexcept
bool operator!() const
Checks for null.
Ref(ProductID const &productID, key_type itemKey, EDProductGetter const *prodGetter)
std::vector< E > product_type
for export
EDProductGetter const * productGetter() const
Accessor for product getter.
bool isNonnull() const
Checks for non-null.
void const * productPtr() const
static key_type invalidKey()
bool hasProductCache() const
Returns true if container referenced by the Ref has been cached.
Ref(ProductID const &iProductID, T const *item, key_type itemKey)
ProductID id() const
Accessor for product ID.
RefCore const & refCore() const
def template(fileName, svg, replaceme="REPLACEME")
refhelper::FindRefVectorUsingAdvance< RefToBaseVector< T > > VBF
bool operator!=(debugging_allocator< X > const &, debugging_allocator< Y > const &) noexcept
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
T const * product() const
refhelper::ValueTrait< std::vector< E > >::value value_type
refhelper::FindRefVectorUsingAdvance< RefToBaseVector< T > > VBF
T const * product() const
boost::binary_traits< F >::second_argument_type argument_type
Ref(ProductID const &iProductID, T const *item, key_type itemKey, bool transient)
Ref(ProductID const &iId)
Ref(ProductID const &iProductID, T const *item, key_type itemKey)
EDProductGetter const * productGetter() const
bool operator!() const
Checks for null.
Ref(ProductID const &productID, key_type itemKey, EDProductGetter const *prodGetter)
Ref()
Default constructor needed for reading from persistent store. Not for direct use. ...
RefCoreWithIndex product_
EDProductGetter const * productGetter() const
Accessor for product getter.
T const * operator->() const
Member dereference operator.
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.
edm::RefVector< Container > RefVector
T const & operator*() const
Dereference operator.
key_type key() const
Accessor for product key.