CMS 3D CMS Logo

List of all members | Public Member Functions | Private Types | Private Attributes
edm::MultiAssociation< C >::LazyFiller Class Reference

#include <MultiAssociation.h>

Public Member Functions

void fill () noexcept(false)
 
template<typename HandleType >
 LazyFiller (MultiAssociation &assoc, const HandleType &handle, bool fillOnExit=false)
 
void setFillOnExit (bool fillOnExit)
 If set to true, the LazyFiller wil call 'fill()' when it goes out of scope. More...
 
template<typename KeyRef >
void setValues (const KeyRef &k, const Collection &refs)
 Sets the Collection values associated to this key, making copies of those in refs. More...
 
template<typename KeyRef >
void swapValues (const KeyRef &k, Collection &refs)
 
 ~LazyFiller () noexcept(false)
 

Private Types

typedef std::map< unsigned int, CollectionTempValues
 

Private Attributes

MultiAssociationassoc_
 
bool fillOnExit_
 
ProductID id_
 
unsigned int size_
 
std::shared_ptr< TempValuestempValues_
 

Detailed Description

template<typename C>
class edm::MultiAssociation< C >::LazyFiller

LazyFiller for the MultiAssociation. It is slower than FastFiller, as it keeps a copy of the input before filling it (unless you use swapValues) Anyway it has no constraints on the order of the keys, or the number of fillers It can also be copied around by value without cloning its keys (e.g to put it into a std::vector) If you set fillOnExit to 'true', it will fill the MultiAssociation automatically when going out of scope

Definition at line 245 of file MultiAssociation.h.

Member Typedef Documentation

◆ TempValues

template<typename C>
typedef std::map<unsigned int, Collection> edm::MultiAssociation< C >::LazyFiller::TempValues
private

Definition at line 278 of file MultiAssociation.h.

Constructor & Destructor Documentation

◆ LazyFiller()

template<typename C>
template<typename HandleType >
edm::MultiAssociation< C >::LazyFiller::LazyFiller ( MultiAssociation assoc,
const HandleType &  handle,
bool  fillOnExit = false 
)
inline

Definition at line 248 of file MultiAssociation.h.

249  : assoc_(assoc),
250  id_(handle.id()),
251  size_(handle->size()),
252  tempValues_(new TempValues()),
253  fillOnExit_(fillOnExit) {}

◆ ~LazyFiller()

template<typename C>
edm::MultiAssociation< C >::LazyFiller::~LazyFiller ( )
inlinenoexcept

Member Function Documentation

◆ fill()

template<typename C >
void edm::MultiAssociation< C >::LazyFiller::fill ( void  )
noexcept

Does the real filling. Until this is called, the map is not modified at all. Calling this twice won't have any effect (but you can't modify a LazyFiller after calling 'fill()') Implementation note: inside, it just makes a FastFiller and uses it.

Definition at line 357 of file MultiAssociation.h.

357  {
358  if (id_ != ProductID()) { // protection against double filling
360  for (typename TempValues::const_iterator it = tempValues_->begin(), ed = tempValues_->end(); it != ed; ++it) {
361  filler.setValues(id_, it->first, it->second);
362  }
363  id_ = ProductID(); // protection against double filling
364  }
365  }

References trigObjTnPSource_cfi::filler.

Referenced by edm::MultiAssociation< C >::LazyFiller::~LazyFiller().

◆ setFillOnExit()

template<typename C>
void edm::MultiAssociation< C >::LazyFiller::setFillOnExit ( bool  fillOnExit)
inline

If set to true, the LazyFiller wil call 'fill()' when it goes out of scope.

Definition at line 266 of file MultiAssociation.h.

266 { fillOnExit_ = fillOnExit; }

References edm::MultiAssociation< C >::LazyFiller::fillOnExit_.

◆ setValues()

template<typename C >
template<typename KeyRef >
void edm::MultiAssociation< C >::LazyFiller::setValues ( const KeyRef &  k,
const Collection refs 
)

Sets the Collection values associated to this key, making copies of those in refs.

Definition at line 342 of file MultiAssociation.h.

342  {
343  if (k.id() != id_)
344  Indices::throwUnexpectedProductID(k.id(), id_, "LazyFiller::insert");
345  (*tempValues_)[k.key()] = vals;
346  }

References dqmdumpme::k, and edm::helper::IndexRangeAssociation::throwUnexpectedProductID().

◆ swapValues()

template<typename C >
template<typename KeyRef >
void edm::MultiAssociation< C >::LazyFiller::swapValues ( const KeyRef &  k,
Collection refs 
)

Swaps the Collection values associated to this key with the ones in 'ref' This is expected to be faster than 'setValues'.

Definition at line 350 of file MultiAssociation.h.

350  {
351  if (k.id() != id_)
352  Indices::throwUnexpectedProductID(k.id(), id_, "LazyFiller::insert");
353  vals.swap((*tempValues_)[k.key()]);
354  }

References dqmdumpme::k, and edm::helper::IndexRangeAssociation::throwUnexpectedProductID().

Member Data Documentation

◆ assoc_

template<typename C>
MultiAssociation& edm::MultiAssociation< C >::LazyFiller::assoc_
private

Definition at line 279 of file MultiAssociation.h.

◆ fillOnExit_

template<typename C>
bool edm::MultiAssociation< C >::LazyFiller::fillOnExit_
private

◆ id_

template<typename C>
ProductID edm::MultiAssociation< C >::LazyFiller::id_
private

Definition at line 280 of file MultiAssociation.h.

◆ size_

template<typename C>
unsigned int edm::MultiAssociation< C >::LazyFiller::size_
private

Definition at line 281 of file MultiAssociation.h.

◆ tempValues_

template<typename C>
std::shared_ptr<TempValues> edm::MultiAssociation< C >::LazyFiller::tempValues_
private

Definition at line 282 of file MultiAssociation.h.

edm::MultiAssociation::FastFiller
friend class FastFiller
Definition: MultiAssociation.h:233
patZpeak.handle
handle
Definition: patZpeak.py:23
edm::MultiAssociation::LazyFiller::id_
ProductID id_
Definition: MultiAssociation.h:280
trackingPlots.assoc
assoc
Definition: trackingPlots.py:183
edm::helper::IndexRangeAssociation::throwUnexpectedProductID
static void throwUnexpectedProductID(ProductID found, ProductID expected, const char *where)
Definition: MultiAssociation.cc:119
edm::MultiAssociation::LazyFiller::fillOnExit_
bool fillOnExit_
Definition: MultiAssociation.h:283
edm::MultiAssociation::LazyFiller::TempValues
std::map< unsigned int, Collection > TempValues
Definition: MultiAssociation.h:278
dqmdumpme.k
k
Definition: dqmdumpme.py:60
edm::MultiAssociation::LazyFiller::size_
unsigned int size_
Definition: MultiAssociation.h:281
trigObjTnPSource_cfi.filler
filler
Definition: trigObjTnPSource_cfi.py:21
edm::MultiAssociation::LazyFiller::tempValues_
std::shared_ptr< TempValues > tempValues_
Definition: MultiAssociation.h:282
edm::MultiAssociation::LazyFiller::fill
void fill() noexcept(false)
Definition: MultiAssociation.h:357
edm::MultiAssociation::LazyFiller::assoc_
MultiAssociation & assoc_
Definition: MultiAssociation.h:279