CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 ()
 
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 ()
 

Private Types

typedef std::map< unsigned int,
Collection
TempValues
 

Private Attributes

MultiAssociationassoc_
 
bool fillOnExit_
 
ProductID id_
 
unsigned int size_
 
boost::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 241 of file MultiAssociation.h.

Member Typedef Documentation

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

Definition at line 268 of file MultiAssociation.h.

Constructor & Destructor Documentation

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

Definition at line 244 of file MultiAssociation.h.

244  :
245  assoc_(assoc),
246  id_(handle.id()), size_(handle->size()),
247  tempValues_(new TempValues()), fillOnExit_(fillOnExit) {}
boost::shared_ptr< TempValues > tempValues_
std::map< unsigned int, Collection > TempValues
tuple handle
Definition: patZpeak.py:22
template<typename C>
edm::MultiAssociation< C >::LazyFiller::~LazyFiller ( )
inline

Member Function Documentation

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

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 345 of file MultiAssociation.h.

References edm::MultiAssociation< C >::FastFiller::setValues(), and edm::size_().

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

345  {
346  if (id_ != ProductID()) { // protection against double filling
347  typename MultiAssociation<C>::FastFiller filler(assoc_, id_, size_);
348  for (typename TempValues::const_iterator it = tempValues_->begin(), ed = tempValues_->end(); it != ed; ++it) {
349  filler.setValues(id_, it->first, it->second);
350  }
351  id_ = ProductID(); // protection against double filling
352  }
353  }
boost::shared_ptr< TempValues > tempValues_
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 257 of file MultiAssociation.h.

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

257 { fillOnExit_ = fillOnExit; }
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 331 of file MultiAssociation.h.

References edm::helper::IndexRangeAssociation::throwUnexpectedProductID(), and create_public_pileup_plots::vals.

331  {
332  if (k.id() != id_) Indices::throwUnexpectedProductID(k.id(),id_,"LazyFiller::insert");
333  (*tempValues_)[k.key()] = vals;
334  }
static void throwUnexpectedProductID(ProductID found, ProductID expected, const char *where)
int k[5][pyjets_maxn]
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 338 of file MultiAssociation.h.

References edm::helper::IndexRangeAssociation::throwUnexpectedProductID().

338  {
339  if (k.id() != id_) Indices::throwUnexpectedProductID(k.id(),id_,"LazyFiller::insert");
340  vals.swap((*tempValues_)[k.key()]);
341  }
static void throwUnexpectedProductID(ProductID found, ProductID expected, const char *where)
boost::shared_ptr< TempValues > tempValues_
int k[5][pyjets_maxn]

Member Data Documentation

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

Definition at line 269 of file MultiAssociation.h.

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

Definition at line 270 of file MultiAssociation.h.

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

Definition at line 271 of file MultiAssociation.h.

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

Definition at line 272 of file MultiAssociation.h.