1 #ifndef DataFormats_Common_AssociationVector_h
2 #define DataFormats_Common_AssociationVector_h
25 #if !defined(__CINT__) && !defined(__MAKECINT__) && !defined(__REFLEX__)
27 #include <type_traits>
32 template<
class T>
class Ptr;
46 template<
typename REFPROD>
60 template<
typename KeyRefProd,
typename CVal,
62 typename SizeType =
unsigned int,
70 typedef typename KeyRefProd::product_type
CKey;
73 typedef typename std::pair<KeyRef, typename CVal::value_type>
value_type;
84 typename CVal::const_reference
operator[](KeyRef
const&
k)
const;
95 void swap(
self& other);
101 std::vector<void const*>& pointers,
116 #if !defined(__CINT__) && !defined(__MAKECINT__) && !defined(__REFLEX__)
126 #if !defined(__CINT__) && !defined(__MAKECINT__) && !defined(__REFLEX__)
127 template<
typename KeyRefProd,
typename CVal,
typename KeyRef,
typename SizeType,
typename KeyReferenceHelper>
131 return *(transientVector_.load(std::memory_order_acquire)); }
134 template<
typename KeyRefProd,
typename CVal,
typename KeyRef,
typename SizeType,
typename KeyReferenceHelper>
136 data_(), ref_(), transientVector_(
nullptr) { }
138 template<
typename KeyRefProd,
typename CVal,
typename KeyRef,
typename SizeType,
typename KeyReferenceHelper>
141 data_(coll == 0 ? ref->
size() : coll->
size()), ref_(ref),
144 #if !defined(__CINT__) && !defined(__MAKECINT__) && !defined(__REFLEX__)
145 template<
typename KeyRefProd,
typename CVal,
typename KeyRef,
typename SizeType,
typename KeyReferenceHelper>
148 data_(o.data_), ref_(o.ref_), transientVector_() {
156 #if !defined(__CINT__) && !defined(__MAKECINT__) && !defined(__REFLEX__)
157 template<
typename KeyRefProd,
typename CVal,
typename KeyRef,
typename SizeType,
typename KeyReferenceHelper>
159 delete transientVector_.load(std::memory_order_acquire);
163 template<
typename KeyRefProd,
typename CVal,
typename KeyRef,
typename SizeType,
typename KeyReferenceHelper>
166 return transientVector()[
n ];
169 template<
typename KeyRefProd,
typename CVal,
typename KeyRef,
typename SizeType,
typename KeyReferenceHelper>
170 inline typename CVal::const_reference
174 return data_[ keyRef.key() ];
177 template<
typename KeyRefProd,
typename CVal,
typename KeyRef,
typename SizeType,
typename KeyReferenceHelper>
178 template<
typename K>
179 inline typename CVal::const_reference
181 #if !defined(__CINT__) && !defined(__MAKECINT__) && !defined(__REFLEX__)
185 return data_[ k.
key() ];
188 template<
typename KeyRefProd,
typename CVal,
typename KeyRef,
typename SizeType,
typename KeyReferenceHelper>
189 template<
typename K>
190 typename CVal::const_reference
192 #if !defined(__CINT__) && !defined(__MAKECINT__) && !defined(__REFLEX__)
196 return data_[ k.
key() ];
200 #if !defined(__CINT__) && !defined(__MAKECINT__) && !defined(__REFLEX__)
201 template<
typename KeyRefProd,
typename CVal,
typename KeyRef,
typename SizeType,
typename KeyReferenceHelper>
205 auto t = transientVector_.exchange(
nullptr,std::memory_order_acq_rel);
208 return data_[ keyRef.key() ];
212 #if !defined(__CINT__) && !defined(__MAKECINT__) && !defined(__REFLEX__)
213 template<
typename KeyRefProd,
typename CVal,
typename KeyRef,
typename SizeType,
typename KeyReferenceHelper>
221 auto t =transientVector_.exchange(
nullptr, std::memory_order_acq_rel);
226 template<
typename KeyRefProd,
typename CVal,
typename KeyRef,
typename SizeType,
typename KeyReferenceHelper>
230 auto t = transientVector_.load(std::memory_order_acquire);
231 (*t)[
i ].first = ref;
232 (*t)[
i ].second = data_[
i ];
236 template<
typename KeyRefProd,
typename CVal,
typename KeyRef,
typename SizeType,
typename KeyReferenceHelper>
242 template<
typename KeyRefProd,
typename CVal,
typename KeyRef,
typename SizeType,
typename KeyReferenceHelper>
244 return data_.empty();
247 #if !defined(__CINT__) && !defined(__MAKECINT__) && !defined(__REFLEX__)
248 template<
typename KeyRefProd,
typename CVal,
typename KeyRef,
typename SizeType,
typename KeyReferenceHelper>
251 auto t = transientVector_.load(std::memory_order_acquire);
256 template<
typename KeyRefProd,
typename CVal,
typename KeyRef,
typename SizeType,
typename KeyReferenceHelper>
258 data_.swap(other.data_);
259 other.transientVector_.store(transientVector_.exchange(other.transientVector_.load(std::memory_order_acquire),std::memory_order_acq_rel),std::memory_order_release);
260 ref_.swap(other.ref_);
263 template<
typename KeyRefProd,
typename CVal,
typename KeyRef,
typename SizeType,
typename KeyReferenceHelper>
265 if (
nullptr == transientVector_.load(std::memory_order_acquire)) {
268 (*newT)[
i ] = std::make_pair(KeyRef(ref_,
i), data_[
i ]);
271 if(transientVector_.compare_exchange_strong(expected, newT.get()) ) {
278 template<
typename KeyRefProd,
typename CVal,
typename KeyRef,
typename SizeType,
typename KeyReferenceHelper>
280 std::vector<void const*>& pointers,
291 template<
typename KeyRefProd,
typename CVal,
typename KeyRef,
typename SizeType,
typename KeyReferenceHelper>
301 template <
typename KeyRefProd,
typename CVal,
typename KeyRef,
typename SizeType,
typename KeyReferenceHelper>
306 std::vector<void const*>& pointers,
308 obj.
fillView(
id, pointers, helpers);
311 template <
typename KeyRefProd,
typename CVal,
typename KeyRef,
typename SizeType,
typename KeyReferenceHelper>
void checkForWrongProduct(ProductID const &keyID, ProductID const &refID)
void fillView(ProductID const &id, std::vector< void const * > &pointers, FillViewHelperVector &helpers) const
transient_vector_type::const_iterator const_iterator
void reallyFillView(COLLECTION const &coll, ProductID const &id, std::vector< void const * > &ptrs, FillViewHelperVector &helpers)
Ref< typename RefProd< C >::product_type > ref_type
self & operator=(self const &)
const_iterator end() const
std::vector< value_type > transient_vector_type
#define CMS_CLASS_VERSION(_version_)
void swap(Association< C > &lhs, Association< C > &rhs)
AssociationIdenticalKeyReference type
value_type const & const_reference
const_reference operator[](size_type n) const
std::pair< KeyRef, typename CVal::value_type > value_type
BOOST_STATIC_ASSERT((boost::is_convertible< SizeType, typename CVal::size_type >::value))
void fillView(AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper > const &obj, ProductID const &id, std::vector< void const * > &pointers, FillViewHelperVector &helpers)
CVal::value_type const value(size_type i) const
KeyRefProd::product_type CKey
Container::transient_vector_type transient_vector_type
Container::value_type value_type
KeyRef key(size_type i) const
KeyRef::value_type key_type
ProductID id() const
Accessor for product ID.
std::atomic< transient_vector_type * > transientVector_
KeyRefProd const & keyProduct() const
transient_vector_type const & transientVector() const
void setValue(size_type i, typename CVal::value_type const &val)
const_iterator begin() const
std::vector< std::pair< edm::ProductID, unsigned long > > FillViewHelperVector
tuple size
Write out results.
T get(const Candidate &c)