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*
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>
bool isNonnull() const
Checks for non-null.
Ref(ProductID const &iId)
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.
key_type key() const
Accessor for product key.
static std::auto_ptr< BaseVectorHolder< T > > makeVectorHolder()
C const * product() const
Accessor for product collection.
T const * product() const
bool hasProductCache() const
Returns true if container referenced by the Ref has been cached.
RefCoreWithIndex product_
boost::enable_if< has_key_compare< C >, bool >::type compare_key(K const &lhs, K const &rhs)
refhelper::FindRefVectorUsingAdvance< RefToBaseVector< T > > VBF
void checkTypeAtCompileTime(C const *)
Ref(ProductID const &iProductID, T const *, key_type iItemKey, product_type const *iProduct)
Constructor for use in the various X::fillView(...) functions.
bool isNull() const
Checks for null.
refhelper::FindRefVectorUsingAdvance< RefVector< std::vector< E >, T, F > > VF
bool operator!() const
Checks for null.
bool operator!=(debugging_allocator< X > const &, debugging_allocator< Y > const &)
RefCore const & refCore() const
T const & operator*() const
Dereference operator.
#define REF_FOR_VECTOR_ARGS
#define CMS_CLASS_VERSION(_version_)
refhelper::ValueTrait< std::vector< E > >::value T
Ref(ProductID const &productID, key_type itemKey, EDProductGetter const *prodGetter)
static std::auto_ptr< RefVectorHolderBase > makeVectorHolder()
refhelper::ValueTrait< std::vector< E > >::value value_type
bool isNonnull() const
Checks for non-null.
bool isNull() const
Checks for null.
RefRefHolderToRefVector< Ref< C, T, F > > type
boost::binary_traits< F >::second_argument_type argument_type
refhelper::FindTrait< std::vector< E >, typename refhelper::ValueTrait< std::vector< E > >::value >::value F
boost::binary_traits< F >::second_argument_type argument_type
bool operator==(debugging_allocator< X > const &, debugging_allocator< Y > const &)
void const * productPtr() const
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
Ref()
Default constructor needed for reading from persistent store. Not for direct use. ...
refhelper::FindRefVectorUsingAdvance< RefToBaseVector< T > > VBF
EDProductGetter const * productGetter() const
Accessor for product getter.
Ref(ProductID const &iProductID, T const *, key_type iItemKey, C const *iProduct)
Constructor for use in the various X::fillView(...) functions.
T const * product() const
key_type key() const
Accessor for product key.
T const * product() const
EDProductGetter const * productGetter() const
bool isTransient() const
Checks if this ref is transient (i.e. not persistable).
std::vector< E > product_type
etc. etc.: more nesting levels could be supported ...
bool hasProductCache() const
Returns true if container referenced by the Ref has been cached.
void checkTypeAtCompileTime(product_type const *)
ProductID id() const
Accessor for product ID.
EDProductGetter const * productGetter() const
Accessor for product getter.
static std::auto_ptr< RefVectorHolderBase > makeVectorBaseHolder()
value_type const element_type
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).
bool operator!() const
Checks for null.