1 #ifndef DataFormats_Common_MultiAssociation_h 2 #define DataFormats_Common_MultiAssociation_h 54 #include <boost/utility.hpp> 55 #include <boost/range.hpp> 75 typedef std::pair<unsigned int, unsigned int>
range;
81 template<
typename RefKey>
83 return get(r.id(), r.key());
112 template<
typename RefKey>
113 void insert(
const RefKey &
r,
unsigned int startingOffset,
unsigned int size) {
114 insert(r.id(), r.key(), startingOffset,
size);
156 typedef boost::sub_range<Collection>
range;
161 template<
typename RefKey>
163 return get(r.id(), r.key());
167 template<
typename RefKey>
169 return get(r.id(), r.key());
173 template<
typename RefKey>
175 return getValues(r.id(), r.key());
192 data_.swap(other.
data_);
196 unsigned int dataSize()
const {
return data_.size(); }
199 unsigned int size()
const {
return indices_.size(); }
202 bool empty()
const {
return indices_.empty(); }
210 template<
typename HandleType>
220 template<
typename KeyRef>
224 void setValues(
const edm::ProductID &
id,
unsigned int key,
const Collection &refs);
233 template<
typename HandleType>
243 template<
typename HandleType>
246 id_(handle.id()), size_(handle->
size()),
247 tempValues_(new
TempValues()), fillOnExit_(fillOnExit) {}
260 template<
typename KeyRef>
261 void setValues(
const KeyRef &
k,
const Collection &refs) ;
265 template<
typename KeyRef>
266 void swapValues(
const KeyRef &k, Collection &refs) ;
277 template<
typename HandleType>
299 return const_range(data_.begin()+idxrange.first, data_.begin()+idxrange.second);
306 return range(data_.begin()+idxrange.first, data_.begin()+idxrange.second);
315 for (
typename const_range::const_iterator it = values.begin(), ed = values.end(); it != ed; ++it) {
323 indexFiller_->insert(
id, key,
assoc_.data_.
size(), vals.size());
324 for (
typename Collection::const_iterator it = vals.begin(), ed = vals.end(); it != ed; ++it) {
325 assoc_.data_.push_back(*it);
330 template<
typename KeyRef>
332 if (k.id() !=
id_) Indices::throwUnexpectedProductID(k.id(),
id_,
"LazyFiller::insert");
333 (*tempValues_)[k.key()] =
vals;
337 template<
typename KeyRef>
339 if (k.id() !=
id_) Indices::throwUnexpectedProductID(k.id(),
id_,
"LazyFiller::insert");
340 vals.swap((*tempValues_)[k.key()]);
348 for (
typename TempValues::const_iterator it = tempValues_->begin(), ed = tempValues_->end(); it != ed; ++it) {
unsigned int dataSize() const
Returns the number of values.
static void throwUnexpectedProductID(ProductID found, ProductID expected, const char *where)
boost::sub_range< const Collection > const_range
range operator[](const RefKey &r)
Get a range of values for this key (fast)
FastFiller(MultiAssociation &assoc, edm::ProductID id, unsigned int size)
void swapValues(const KeyRef &k, Collection &refs)
const_range get(const edm::ProductID &id, unsigned int t) const
Get a range of values for this product id and index (fast)
offset_vector ref_offsets_
Collection getValues(const RefKey &r) const
Get a copy of the values for this key (slow!)
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
bool empty() const
True if it's empty (no keys)
LazyFiller(MultiAssociation &assoc, const HandleType &handle, bool fillOnExit=false)
unsigned int size() const
Returns the number of keys.
FastFiller(IndexRangeAssociation &assoc, ProductID id, unsigned int size)
Make a filler for a collection with a given product id and size.
std::map< unsigned int, Collection > TempValues
LazyFiller lazyFiller(const HandleType &h, bool fillOnExit=false)
#define CMS_CLASS_VERSION(_version_)
boost::sub_range< Collection > range
void swap(IndexRangeAssociation &other)
std::shared_ptr< TempValues > tempValues_
edm::helper::IndexRangeAssociation::FastFiller IndexFiller
unsigned int size() const
Size of this collection (number of keys)
MultiAssociation & assoc_
int lastKey_
last key used to fill (to check that the new key must be strictly greater than lastKey_) ...
~FastFiller()
When the FastFiller goes out of scope, it unlocks the map so you can make a new one.
range operator[](const RefKey &r) const
IndexRangeAssociation & assoc_
def template(fileName, svg, replaceme="REPLACEME")
bool contains(ProductID id) const
True if this IndexRangeAssociation has info for this product id.
const_range operator[](const RefKey &r) const
Get a range of values for this key (fast)
std::pair< unsigned int, unsigned int > range
void insert(const RefKey &r, unsigned int startingOffset, unsigned int size)
Sets the starting offset for this key.
std::shared_ptr< IndexFiller > indexFiller_
FastFiller fastFiller(const HandleType &handle)
void setFillOnExit(bool fillOnExit)
If set to true, the LazyFiller wil call 'fill()' when it goes out of scope.
std::vector< int > offset_vector
bool operator()(const id_off_pair &p, const edm::ProductID &id) const
id_offset_vector id_offsets_
FastFiller(MultiAssociation &assoc, const HandleType &handle)
void swap(MultiAssociation &other)
bool contains(const edm::ProductID &id) const
True if there are keys from this product id.
MultiAssociation & assoc_
bool empty() const
Returns true if there are no keys.
std::pair< edm::ProductID, unsigned int > id_off_pair
std::vector< id_off_pair > id_offset_vector
void setValues(const KeyRef &k, const Collection &refs)
Sets the Collection values associated to this key, making copies of those in refs.
void setValues(const KeyRef &k, const Collection &refs)
Sets the Collection values associated to this key, making copies of those in refs.