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){
471 assert(
key() == itemKey);
477 template <
typename E>
482 assert(
key() == itemKey);
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) {
493 assert(
key() == itemKey);
499 template <
typename E>
504 assert(
key() == itemKey);
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) {
515 assert(
key() == itemKey);
521 template <
typename E>
524 product_(refvector.id(), refvector.product(), 0, refvector.isTransient(),itemKey) {
526 assert(
key() == 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) {
565 assert(
key() == itemKey);
570 template <
typename E>
575 assert(
key() == itemKey);
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) {
585 assert(
index() == itemKey);
588 template <
typename E>
591 product_(refProd.id(), refProd.refCore().productPtr(), refProd.refCore().productGetter(), refProd.refCore().isTransient(),itemKey) {
592 assert(
index() == 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());
612 template <
typename C,
typename T,
typename F>
616 return *getPtr<C, T, F>(product_, index_);
618 template <
typename E>
622 return *getPtr<REF_FOR_VECTOR_ARGS>(product_.toRefCore(),
key());
626 template <
typename C,
typename T,
typename F>
630 return getPtr<C, T, F>(product_, index_);
632 template <
typename E>
636 return getPtr<REF_FOR_VECTOR_ARGS>(product_.toRefCore(),
key());
639 template <
typename C,
typename T,
typename F>
643 return lhs.key() == rhs.key() && lhs.refCore() == rhs.refCore() ;
646 template <
typename C,
typename T,
typename F>
650 return !(lhs == rhs);
653 template <
typename C,
typename T,
typename F>
659 return (lhs.refCore() == rhs.refCore() ? compare_key<C>(lhs.key(), rhs.key()) : lhs.refCore() < rhs.refCore());
670 namespace reftobase {
672 template <
typename T,
typename REF>
675 typedef RefVector<
typename REF::product_type,
677 typename REF::finder_type> REFV;
681 typedef RefVector<
typename REF::product_type,
683 typename REF::finder_type> REFV;
688 template<
typename T1,
typename C,
typename T,
typename F>
693 template <
typename REF>
696 typedef RefVector<
typename REF::product_type,
698 typename REF::finder_type> REFV;
703 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
T const * operator->() const
Member dereference operator.
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
void checkTypeAtCompileTime(C const *)
void checkTypeAtCompileTime(product_type const *)
RefCore const & refCore() const
bool operator!() const
Checks for null.
bool operator!=(debugging_allocator< X > const &, debugging_allocator< Y > const &)
T const & operator*() const
Dereference operator.
bool isNull() const
Checks for null.
#define REF_FOR_VECTOR_ARGS
#define CMS_CLASS_VERSION(_version_)
Ref(ProductID const &iId)
value_type const element_type
static std::auto_ptr< RefVectorHolderBase > makeVectorHolder()
bool isNonnull() const
Checks for non-null.
bool isTransient() const
Checks if this ref is transient (i.e. not persistable).
bool isNull() const
Checks for null.
RefRefHolderToRefVector< Ref< C, T, F > > type
bool operator!() const
Checks for null.
std::vector< E > product_type
etc. etc.: more nesting levels could be supported ...
boost::binary_traits< F >::second_argument_type argument_type
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.
Ref(ProductID const &productID, key_type itemKey, EDProductGetter const *prodGetter)
RefCore const & refCore() const
C product_type
etc. etc.: more nesting levels could be supported ...
Container::value_type value_type
Ref(ProductID const &iId)
refhelper::FindRefVectorUsingAdvance< RefVector< C, T, F > > VF
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.
Ref()
Default constructor needed for reading from persistent store. Not for direct use. ...
refhelper::FindRefVectorUsingAdvance< RefToBaseVector< T > > VBF
refhelper::ValueTrait< std::vector< E > >::value value_type
Ref(ProductID const &iProductID, T const *, key_type iItemKey, C const *iProduct)
Constructor for use in the various X::fillView(...) functions.
refhelper::FindRefVectorUsingAdvance< RefToBaseVector< T > > VBF
T const * product() const
boost::binary_traits< F >::second_argument_type argument_type
key_type key() const
Accessor for product key.
T const * product() const
EDProductGetter const * productGetter() const
Ref(ProductID const &productID, key_type itemKey, EDProductGetter const *prodGetter)
RefCoreWithIndex product_
bool hasProductCache() const
Returns true if container referenced by the Ref has been cached.
ProductID id() const
Accessor for product ID.
EDProductGetter const * productGetter() const
Accessor for product getter.
volatile std::atomic< bool > shutdown_flag false
static std::auto_ptr< RefVectorHolderBase > makeVectorBaseHolder()
boost::remove_cv< typename boost::remove_reference< argument_type >::type >::type key_type
static uInt32 F(BLOWFISH_CTX *ctx, uInt32 x)
C const * product() const
Accessor for product collection.
edm::RefVector< Container > RefVector
bool isTransient() const
Checks if this ref is transient (i.e. not persistable).
key_type key() const
Accessor for product key.