CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DetSet.h
Go to the documentation of this file.
1 #ifndef DataFormats_Common_DetSet_h
2 #define DataFormats_Common_DetSet_h
3 
4 /*----------------------------------------------------------------------
5 
6 DetSet: A struct which combines a collection of homogeneous objects
7 associated with a common DetId with a DetId instance, holding the
8 common DetId value. The collected objects may or may not contain their
9 own copy of the common DetId.
10 
11 $Id: DetSet.h,v 1.14 2011/03/08 14:01:16 innocent Exp $
12 
13 ----------------------------------------------------------------------*/
14 
15 #include <vector>
16 #include <stdint.h>
18 
19 namespace edm {
20  typedef uint32_t det_id_type;
21 
22  template <class T>
23  struct DetSet
24  {
25  typedef std::vector<T> collection_type;
26  // We don't just use T as value-type, in case we switch to a
27  // fancier underlying container.
29  typedef typename collection_type::reference reference;
30  typedef typename collection_type::const_reference const_reference;
31  typedef typename collection_type::iterator iterator;
32  typedef typename collection_type::const_iterator const_iterator;
34 
36  DetSet() : id(0), data() { }
38  explicit DetSet(det_id_type i) : id(i), data() { }
39 
40 #if defined( __GXX_EXPERIMENTAL_CXX0X__)
41  DetSet(DetSet<T> const & rh) : id(rh.id), data(rh.data){}
42 
43  DetSet<T> & operator=(DetSet<T> const & rh) {
44  id = rh.id;
45  data = rh.data;
46  return * this;
47  }
48 
49  DetSet(DetSet<T> && rh) : id(rh.id), data(std::move(rh.data)){}
50 
51  DetSet<T> & operator=(DetSet<T> && rh) {
52  id = rh.id;
53  data.swap(rh.data);
54  return * this;
55  }
56 #endif
57 
58  iterator begin() { return data.begin(); }
59  iterator end() { return data.end(); }
60  const_iterator begin() const { return data.begin(); }
61  const_iterator end() const { return data.end(); }
62  size_type size() const { return data.size(); }
63  bool empty() const { return data.empty(); }
65  const_reference operator[](size_type i) const { return data[ i ]; }
66  void reserve(size_t s) { data.reserve(s); }
67  void push_back(const T & t) { data.push_back(t); }
68  void clear() { data.clear(); }
69  void swap(DetSet<T> & other);
70 
71  det_id_type detId() const { return id; }
72 
73  //Used by ROOT storage
75 
78  }; // template struct DetSet
79 
80 
81  // TODO: If it turns out that it is confusing to have operator<
82  // defined for DetSet, because this op< ignores the data member
83  // 'data', we could instead specialize the std::less class template
84  // directly.
85 
86  template <class T>
87  inline
88  bool
90  return x.detId() < y.detId();
91  }
92 
93  template <class T>
94  inline
95  bool
96  operator< (DetSet<T> const& x, det_id_type y) {
97  return x.detId() < y;
98  }
99 
100  template <class T>
101  inline
102  bool
103  operator< (det_id_type x, DetSet<T> const& y) {
104  return x < y.detId();
105  }
106 
107  template <class T>
108  inline
109  void
111  data.swap(other.data);
112  std::swap(id, other.id);
113  }
114 
115  template <class T>
116  inline
117  void
119  a.swap(b);
120  }
121 
122 } // namespace edm;
123 
124 #endif
iterator end()
Definition: DetSet.h:59
std::vector< T > collection_type
Definition: DetSet.h:25
nocap nocap const skelname & operator=(const skelname &)
int i
Definition: DBlmapReader.cc:9
void push_back(const T &t)
Definition: DetSet.h:67
collection_type::iterator iterator
Definition: DetSet.h:31
det_id_type detId() const
Definition: DetSet.h:71
const_iterator begin() const
Definition: DetSet.h:60
reference operator[](size_type i)
Definition: DetSet.h:64
#define CMS_CLASS_VERSION(_version_)
uint16_t size_type
size_type size() const
Definition: DetSet.h:62
DetSet(det_id_type i)
constructor by detector identifier
Definition: DetSet.h:38
void reserve(size_t s)
Definition: DetSet.h:66
collection_type::value_type value_type
Definition: DetSet.h:28
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
collection_type::reference reference
Definition: DetSet.h:29
Container::value_type value_type
iterator begin()
Definition: DetSet.h:58
const_iterator end() const
Definition: DetSet.h:61
uint32_t det_id_type
Definition: DetSet.h:20
DetSet()
default constructor
Definition: DetSet.h:36
double b
Definition: hdecay.h:120
string const
Definition: compareJSON.py:14
collection_type data
Definition: DetSet.h:77
bool empty() const
Definition: DetSet.h:63
const_reference operator[](size_type i) const
Definition: DetSet.h:65
collection_type::size_type size_type
Definition: DetSet.h:33
double a
Definition: hdecay.h:121
det_id_type id
Definition: DetSet.h:76
collection_type::const_reference const_reference
Definition: DetSet.h:30
void clear()
Definition: DetSet.h:68
string s
Definition: asciidump.py:422
Definition: DDAxes.h:10
collection_type::const_iterator const_iterator
Definition: DetSet.h:32
void swap(DetSet< T > &other)
Definition: DetSet.h:110
long double T
def template
Definition: svgfig.py:520