1 #ifndef DataFormats_Common_AssociationVector_h
2 #define DataFormats_Common_AssociationVector_h
25 #if !defined(__CINT__) && !defined(__MAKECINT__) && !defined(__REFLEX__)
29 #include "boost/static_assert.hpp"
44 template<
typename REFPROD>
58 template<
typename KeyRefProd,
typename CVal,
60 typename SizeType =
unsigned int,
68 typedef typename KeyRefProd::product_type
CKey;
71 typedef typename std::pair<KeyRef, typename CVal::value_type>
value_type;
82 typename CVal::const_reference
operator[](KeyRef
const&
k)
const;
88 void swap(
self& other);
94 std::vector<void const*>& pointers,
109 #if !defined(__CINT__) && !defined(__MAKECINT__) && !defined(__REFLEX__)
119 #if !defined(__CINT__) && !defined(__MAKECINT__) && !defined(__REFLEX__)
120 template<
typename KeyRefProd,
typename CVal,
typename KeyRef,
typename SizeType,
typename KeyReferenceHelper>
124 return *(transientVector_.load(std::memory_order_acquire)); }
127 template<
typename KeyRefProd,
typename CVal,
typename KeyRef,
typename SizeType,
typename KeyReferenceHelper>
129 data_(), ref_(), transientVector_(
nullptr) { }
131 template<
typename KeyRefProd,
typename CVal,
typename KeyRef,
typename SizeType,
typename KeyReferenceHelper>
134 data_(coll == 0 ? ref->
size() : coll->
size()), ref_(ref),
137 #if !defined(__CINT__) && !defined(__MAKECINT__) && !defined(__REFLEX__)
138 template<
typename KeyRefProd,
typename CVal,
typename KeyRef,
typename SizeType,
typename KeyReferenceHelper>
141 data_(o.data_), ref_(o.ref_), transientVector_() {
149 #if !defined(__CINT__) && !defined(__MAKECINT__) && !defined(__REFLEX__)
150 template<
typename KeyRefProd,
typename CVal,
typename KeyRef,
typename SizeType,
typename KeyReferenceHelper>
152 delete transientVector_.load(std::memory_order_acquire);
156 template<
typename KeyRefProd,
typename CVal,
typename KeyRef,
typename SizeType,
typename KeyReferenceHelper>
159 return transientVector()[
n ];
162 template<
typename KeyRefProd,
typename CVal,
typename KeyRef,
typename SizeType,
typename KeyReferenceHelper>
163 inline typename CVal::const_reference
167 return data_[ keyRef.key() ];
171 #if !defined(__CINT__) && !defined(__MAKECINT__) && !defined(__REFLEX__)
172 template<
typename KeyRefProd,
typename CVal,
typename KeyRef,
typename SizeType,
typename KeyReferenceHelper>
176 auto t = transientVector_.exchange(
nullptr,std::memory_order_acq_rel);
179 return data_[ keyRef.key() ];
183 #if !defined(__CINT__) && !defined(__MAKECINT__) && !defined(__REFLEX__)
184 template<
typename KeyRefProd,
typename CVal,
typename KeyRef,
typename SizeType,
typename KeyReferenceHelper>
192 auto t =transientVector_.exchange(
nullptr, std::memory_order_acq_rel);
197 template<
typename KeyRefProd,
typename CVal,
typename KeyRef,
typename SizeType,
typename KeyReferenceHelper>
201 auto t = transientVector_.load(std::memory_order_acquire);
202 (*t)[
i ].first = ref;
203 (*t)[
i ].second = data_[
i ];
207 template<
typename KeyRefProd,
typename CVal,
typename KeyRef,
typename SizeType,
typename KeyReferenceHelper>
213 template<
typename KeyRefProd,
typename CVal,
typename KeyRef,
typename SizeType,
typename KeyReferenceHelper>
215 return data_.empty();
218 #if !defined(__CINT__) && !defined(__MAKECINT__) && !defined(__REFLEX__)
219 template<
typename KeyRefProd,
typename CVal,
typename KeyRef,
typename SizeType,
typename KeyReferenceHelper>
222 auto t = transientVector_.load(std::memory_order_acquire);
227 template<
typename KeyRefProd,
typename CVal,
typename KeyRef,
typename SizeType,
typename KeyReferenceHelper>
229 data_.swap(other.data_);
230 other.transientVector_.store(transientVector_.exchange(other.transientVector_.load(std::memory_order_acquire),std::memory_order_acq_rel),std::memory_order_release);
231 ref_.swap(other.ref_);
234 template<
typename KeyRefProd,
typename CVal,
typename KeyRef,
typename SizeType,
typename KeyReferenceHelper>
236 if (
nullptr == transientVector_.load(std::memory_order_acquire)) {
239 (*newT)[
i ] = std::make_pair(KeyRef(ref_,
i), data_[
i ]);
242 if(transientVector_.compare_exchange_strong(expected, newT.get()) ) {
249 template<
typename KeyRefProd,
typename CVal,
typename KeyRef,
typename SizeType,
typename KeyReferenceHelper>
251 std::vector<void const*>& pointers,
262 template<
typename KeyRefProd,
typename CVal,
typename KeyRef,
typename SizeType,
typename KeyReferenceHelper>
272 template <
typename KeyRefProd,
typename CVal,
typename KeyRef,
typename SizeType,
typename KeyReferenceHelper>
277 std::vector<void const*>& pointers,
279 obj.
fillView(
id, pointers, helpers);
282 template <
typename KeyRefProd,
typename CVal,
typename KeyRef,
typename SizeType,
typename KeyReferenceHelper>
void checkForWrongProduct(ProductID const &keyID, ProductID const &refID)
void fillView(AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper > const &obj, ProductID const &id, std::vector< void const * > &pointers, helper_vector &helpers)
transient_vector_type::const_iterator const_iterator
Ref< typename RefProd< C >::product_type > ref_type
void reallyFillView(COLLECTION const &coll, ProductID const &id, std::vector< void const * > &ptrs, helper_vector &helpers)
void fillView(ProductID const &id, std::vector< void const * > &pointers, helper_vector &helpers) const
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))
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
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
tuple size
Write out results.
T get(const Candidate &c)