CMS 3D CMS Logo

List of all members | Classes | Public Types | Public Member Functions | Static Public Member Functions | Private Types | Private Attributes | Friends
edm::helper::IndexRangeAssociation Class Reference

#include <MultiAssociation.h>

Classes

class  FastFiller
 
struct  IDComparator
 

Public Types

typedef std::pair< unsigned int, unsigned int > range
 

Public Member Functions

bool contains (ProductID id) const
 True if this IndexRangeAssociation has info for this product id. More...
 
bool empty () const
 True if it's empty (no keys) More...
 
range get (const edm::ProductID &id, unsigned int t) const
 
 IndexRangeAssociation ()
 
template<typename RefKey >
range operator[] (const RefKey &r) const
 
unsigned int size () const
 Size of this collection (number of keys) More...
 
void swap (IndexRangeAssociation &other)
 

Static Public Member Functions

static void throwUnexpectedProductID (ProductID found, ProductID expected, const char *where)
 

Private Types

typedef std::pair< edm::ProductID, unsigned int > id_off_pair
 
typedef std::vector< id_off_pairid_offset_vector
 
typedef std::vector< int > offset_vector
 

Private Attributes

id_offset_vector id_offsets_
 
bool isFilling_
 
offset_vector ref_offsets_
 

Friends

class FastFiller
 

Detailed Description

Base class to map to items one a range within a target collection. All items in a target collection must be mapped to one and only one key. The target collection will normally be a RefVector (also PtrVector and std::vector could work) To be used by MultiAssociation. Any other usage beyond MultiAssociation is not supported. This class holds:

Definition at line 73 of file MultiAssociation.h.

Member Typedef Documentation

typedef std::pair<edm::ProductID,unsigned int> edm::helper::IndexRangeAssociation::id_off_pair
private

Definition at line 132 of file MultiAssociation.h.

Definition at line 133 of file MultiAssociation.h.

typedef std::vector<int> edm::helper::IndexRangeAssociation::offset_vector
private

Definition at line 134 of file MultiAssociation.h.

typedef std::pair<unsigned int, unsigned int> edm::helper::IndexRangeAssociation::range

Definition at line 75 of file MultiAssociation.h.

Constructor & Destructor Documentation

edm::helper::IndexRangeAssociation::IndexRangeAssociation ( )
inline

Definition at line 77 of file MultiAssociation.h.

Member Function Documentation

bool IndexRangeAssociation::contains ( ProductID  id) const

True if this IndexRangeAssociation has info for this product id.

Definition at line 31 of file MultiAssociation.cc.

References triggerObjects_cff::id, and id_offsets_.

Referenced by LumiList.LumiList::__contains__(), and operator[]().

31  {
32  typedef IndexRangeAssociation::id_offset_vector::const_iterator iter;
33  iter pos = std::lower_bound(id_offsets_.begin(), id_offsets_.end(), id, IDComparator());
34  return (pos != id_offsets_.end()) && (pos->first == id);
35 }
bool edm::helper::IndexRangeAssociation::empty ( ) const
inline

True if it's empty (no keys)

Definition at line 97 of file MultiAssociation.h.

References ref_offsets_.

Referenced by Vispa.Gui.VispaWidget.TextField::setAutosizeFont(), and Vispa.Gui.VispaWidget.TextField::setAutotruncate().

97 { return ref_offsets_.empty(); }
IndexRangeAssociation::range IndexRangeAssociation::get ( const edm::ProductID id,
unsigned int  t 
) const

Get a range of indices for this product id and key (non-template version) And end value of -1 means 'until the end of the other collection, AFAICT'

Definition at line 10 of file MultiAssociation.cc.

References Exception, triggerObjects_cff::id, id_offsets_, crabWrapper::key, ref_offsets_, and edm::second().

Referenced by Options.Options::__getitem__(), betterConfigParser.BetterConfigParser::__updateDict(), util.rrapi.RRApi::columns(), rrapi.RRApi::columns(), util.rrapi.RRApi::count(), rrapi.RRApi::count(), rrapi.RRApi::data(), util.rrapi.RRApi::data(), betterConfigParser.BetterConfigParser::getCompares(), betterConfigParser.BetterConfigParser::getGeneral(), betterConfigParser.BetterConfigParser::getResultingSection(), rrapi.RRApi::report(), util.rrapi.RRApi::report(), rrapi.RRApi::reports(), util.rrapi.RRApi::reports(), util.rrapi.RRApi::tables(), rrapi.RRApi::tables(), rrapi.RRApi::tags(), util.rrapi.RRApi::tags(), rrapi.RRApi::templates(), util.rrapi.RRApi::templates(), util.rrapi.RRApi::workspaces(), and rrapi.RRApi::workspaces().

10  {
11  typedef IndexRangeAssociation::id_offset_vector::const_iterator iter;
12  iter pos = std::lower_bound(id_offsets_.begin(), id_offsets_.end(), id, IDComparator());
13  if ((pos == id_offsets_.end()) || (pos->first != id)) {
14  throw cms::Exception("Bad Key") << "Product ID " << id << " not found in this IndexRangeAssociation\n";
15  }
16  // === Do we want this check ? I would say yes, even if it costs some extra CPU cycles
17  if ((pos + 1 != id_offsets_.end()) && (pos->second + key >= (pos+1)->second)) {
18  throw cms::Exception("Bad Offset") << "Key " << key << " goes beyond bounds "
19  << ((pos+1)->second - pos->second)
20  << " of this key collection within IndexRangeAssociation\n";
21  }
22  // === End check
23  offset_vector::const_iterator offs = ref_offsets_.begin() + pos->second + key;
24  if (offs >= ref_offsets_.end()-1) {
25  throw cms::Exception("Bad Offset") << "Key " << key << " goes beyond bounds " << ref_offsets_.size()-1 << " of this IndexRangeAssociation\n";
26  }
27  return range(*offs,*(offs+1));
28 }
U second(std::pair< T, U > const &p)
std::pair< unsigned int, unsigned int > range
template<typename RefKey >
range edm::helper::IndexRangeAssociation::operator[] ( const RefKey &  r) const
inline

Get a range of indices for this key. RefKey can be edm::Ref, edm::Ptr, edm::RefToBase And end value of -1 means 'until the end of the other collection, AFAICT'

Definition at line 82 of file MultiAssociation.h.

References contains(), triggerObjects_cff::id, and lumiQTWidget::t.

82  {
83  return get(r.id(), r.key());
84  }
unsigned int edm::helper::IndexRangeAssociation::size ( void  ) const
inline
void IndexRangeAssociation::swap ( IndexRangeAssociation other)

Definition at line 38 of file MultiAssociation.cc.

References Exception, id_offsets_, isFilling_, and ref_offsets_.

Referenced by edm::helper::swap().

38  {
39  if (isFilling_ || other.isFilling_) throw cms::Exception("Busy") << "Can't swap an IndexRangeAssociation while it's being filled!\n";
40  id_offsets_.swap(other.id_offsets_);
41  ref_offsets_.swap(other.ref_offsets_);
42 }
void IndexRangeAssociation::throwUnexpectedProductID ( ProductID  found,
ProductID  expected,
const char *  where 
)
static

Definition at line 115 of file MultiAssociation.cc.

References Exception.

Referenced by edm::helper::IndexRangeAssociation::FastFiller::insert().

115  {
116  throw cms::Exception("Unexpected ProductID") << where <<
117  ": found product id " << found << ", while expecting " << expected << ".\n" <<
118  "Make sure you're not mismatching references from different collections.\n";
119 }

Friends And Related Function Documentation

friend class FastFiller
friend

Definition at line 126 of file MultiAssociation.h.

Member Data Documentation

id_offset_vector edm::helper::IndexRangeAssociation::id_offsets_
private
bool edm::helper::IndexRangeAssociation::isFilling_
private
offset_vector edm::helper::IndexRangeAssociation::ref_offsets_
private