1 #ifndef DataFormats_Common_Ref_h
2 #define DataFormats_Common_Ref_h
118 #include "boost/functional.hpp"
119 #include "boost/call_traits.hpp"
120 #include "boost/type_traits.hpp"
121 #include "boost/mpl/has_xxx.hpp"
122 #include "boost/utility/enable_if.hpp"
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,
169 typedef typename boost::binary_traits<F>::second_argument_type
argument_type;
242 T const*
get()
const {
304 #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
306 template <
typename E>
315 friend class
RefVector<RefVector<std::vector<E>, T, F>, T, VF>;
316 friend class
RefVector<RefVector<RefVector<std::vector<E>, T, F>, T, VF>, T, VF>;
317 friend class
RefVector<RefVector<std::vector<E>, T, F>, T, VBF>;
318 friend class
RefVector<RefVector<RefVector<std::vector<E>, T, F>, T, VBF>, T, VBF>;
327 typedef typename boost::binary_traits<F>::second_argument_type
argument_type;
400 T const*
get()
const {
466 template <
typename C,
typename T,
typename F>
469 product_(handle.id(), handle.product(), 0,
false), index_(itemKey){
477 template <
typename E>
484 if (setNow) {getPtr_<REF_FOR_VECTOR_ARGS>(
product_.toRefCore(),
index());}
488 template <
typename C,
typename T,
typename F>
491 product_(handle.id(), handle.product(), 0,
false), index_(itemKey) {
499 template <
typename E>
506 if (setNow) {getPtr_<REF_FOR_VECTOR_ARGS>(
product_.toRefCore(),
key());}
510 template <
typename C,
typename T,
typename F>
513 product_(refvector.id(), refvector.product(), 0, refvector.isTransient()), index_(itemKey) {
521 template <
typename E>
524 product_(refvector.id(), refvector.product(), 0, refvector.isTransient(),itemKey) {
528 if (setNow) {getPtr_<REF_FOR_VECTOR_ARGS>(
product_.toRefCore(),
key());}
538 template <
typename C,
typename T,
typename F>
545 if (iSetNow && iProduct != 0) {getPtr_<C, T, F>(
product_,
index_);}
548 template <
typename E>
555 if (iSetNow && iProduct != 0) {getPtr_<REF_FOR_VECTOR_ARGS>(
product_.toRefCore(),
key());}
560 template <
typename C,
typename T,
typename F>
563 product_(handle.id(), handle.product(), 0,
true), index_(itemKey) {
570 template <
typename E>
577 if (setNow) {getPtr_<REF_FOR_VECTOR_ARGS>(
product_.toRefCore(),
key());}
581 template <
typename C,
typename T,
typename F>
584 product_(refProd.id(), refProd.refCore().productPtr(), refProd.refCore().productGetter(), refProd.refCore().isTransient()), index_(itemKey) {
588 template <
typename E>
591 product_(refProd.id(), refProd.refCore().productPtr(), refProd.refCore().productGetter(), refProd.refCore().isTransient(),itemKey) {
598 template <
typename C,
typename T,
typename F>
604 template <
typename E>
606 std::vector<E>
const*
608 return isNull() ? 0 :
edm::template getProduct<std::vector<E> >(product_.toRefCore());
611 template <
typename C,
typename T,
typename F>
615 if(product_.isAvailable()) {
618 return isThinnedAvailable<C>(product_, index_);
621 template <
typename E>
625 if(product_.isAvailable()) {
628 return isThinnedAvailable<std::vector<E> >(product_.toRefCore(),
key());
632 template <
typename C,
typename T,
typename F>
636 return *getPtr<C, T, F>(product_, index_);
638 template <
typename E>
642 return *getPtr<REF_FOR_VECTOR_ARGS>(product_.toRefCore(),
key());
646 template <
typename C,
typename T,
typename F>
650 return getPtr<C, T, F>(product_, index_);
652 template <
typename E>
656 return getPtr<REF_FOR_VECTOR_ARGS>(product_.toRefCore(),
key());
659 template <
typename C,
typename T,
typename F>
663 return lhs.key() == rhs.key() && lhs.refCore() == rhs.refCore() ;
666 template <
typename C,
typename T,
typename F>
670 return !(lhs == rhs);
673 template <
typename C,
typename T,
typename F>
679 return (lhs.refCore() == rhs.refCore() ? compare_key<C>(lhs.key(), rhs.key()) : lhs.refCore() < rhs.refCore());
690 namespace reftobase {
692 template <
typename T,
typename REF>
695 typedef RefVector<
typename REF::product_type,
697 typename REF::finder_type> REFV;
701 typedef RefVector<
typename REF::product_type,
703 typename REF::finder_type> REFV;
708 template<
typename T1,
typename C,
typename T,
typename F>
713 template <
typename REF>
716 typedef RefVector<
typename REF::product_type,
718 typename REF::finder_type> REFV;
723 template<
typename C,
typename T,
typename F>
refhelper::ValueTrait< std::vector< E > >::value T
EDProductGetter const * mustBeNonZero(EDProductGetter const *prodGetter, std::string refType, ProductID const &productID)
RefHolderToVector< T1, Ref< C, T, F > > type
edm::Ref< Container > Ref
bool isNonnull() const
Checks for non-null.
void checkTypeAtCompileTime(C const *)
static std::auto_ptr< BaseVectorHolder< T > > makeVectorHolder()
C const * product() const
Accessor for product collection.
T const * product() 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
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
bool operator!=(debugging_allocator< X > const &, debugging_allocator< Y > const &)
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
static std::auto_ptr< RefVectorHolderBase > makeVectorHolder()
bool isTransient() const
Checks if this ref is transient (i.e. not persistable).
RefRefHolderToRefVector< Ref< C, T, F > > type
bool operator!() const
Checks for null.
Ref(ProductID const &productID, key_type itemKey, EDProductGetter const *prodGetter)
std::vector< E > product_type
etc. etc.: more nesting levels could be supported ...
EDProductGetter const * productGetter() const
Accessor for product getter.
bool isNonnull() const
Checks for non-null.
bool operator==(debugging_allocator< X > const &, debugging_allocator< Y > const &)
void const * productPtr() const
bool hasProductCache() const
Returns true if container referenced by the Ref has been cached.
ProductID id() const
Accessor for product ID.
refhelper::FindRefVectorUsingAdvance< RefToBaseVector< T > > VBF
Container::value_type value_type
bool isNull() const
Checks for null.
refhelper::FindTrait< std::vector< E >, typename refhelper::ValueTrait< std::vector< E > >::value >::value F
Ref(ProductID const &iProductID, T const *, key_type iItemKey, product_type const *iProduct)
Constructor for use in the various X::fillView(...) functions.
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
C product_type
etc. etc.: more nesting levels could be supported ...
Ref(ProductID const &iId)
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. ...
Ref(ProductID const &iProductID, T const *, key_type iItemKey, C const *iProduct)
Constructor for use in the various X::fillView(...) functions.
RefCoreWithIndex product_
EDProductGetter const * productGetter() const
Accessor for product getter.
T const * operator->() const
Member dereference operator.
volatile std::atomic< bool > shutdown_flag false
static std::auto_ptr< RefVectorHolderBase > makeVectorBaseHolder()
static uInt32 F(BLOWFISH_CTX *ctx, uInt32 x)
edm::RefVector< Container > RefVector
boost::remove_cv< typename boost::remove_reference< argument_type >::type >::type key_type
C const * product() const
Accessor for product collection.
T const & operator*() const
Dereference operator.
key_type key() const
Accessor for product key.