ATLAS Offline Software
NavigableIterator.h
Go to the documentation of this file.
1 // Hey emacs --- this is -*- C++ -*-
2 
3 /*
4  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
5 */
6 
7 #ifndef NAVIGATION_NAVIGABLEITERATOR_H
8 #define NAVIGATION_NAVIGABLEITERATOR_H
9 
11 
12 
13 // Normally, i'd want to use iterator_adaptor here.
14 // But this causes dictionary problems:
15 // - We'd need to add this to the selection (or use an auto-select).
16 // - More importantly, it causes cint to crash because type names
17 // get too long.
18 //
19 // Note also that we need to use member functions rather than free functions
20 // for operators, or pyroot gets confused.
21 
22 template <typename CONT, typename RPAR, typename COLL>
24 {
25 public:
26  // Iterator trait typedefs.
27  typedef typename COLL::const_iterator::iterator_category iterator_category;
28  typedef const typename CONT::base_value_type* value_type;
29  typedef typename COLL::const_iterator::difference_type difference_type;
30  typedef value_type* pointer;
32 
33  typedef typename CONT::base_value_type child_type;
35 
36 
37 public:
39  // Constructor //
41 
43  : m_collection (0)
44  {}
45 
46  NavigableIterator(const COLL& theCollection)
47  : m_actual (theCollection.begin()),
48  m_collection(&theCollection)
49  {
50  }
51 
52  // Use implicit copy ctor, dtor, and assignment.
53 
54 
56 
58  {
59  ++m_actual;
60  return *this;
61  }
62 
64  {
65  NavigableIterator tmp = *this;
66  ++m_actual;
67  return tmp;
68  }
69 
71  {
72  --m_actual;
73  return *this;
74  }
75 
77  {
78  NavigableIterator tmp = *this;
79  --m_actual;
80  return tmp;
81  }
82 
84  {
85  m_actual += n;
86  return *this;
87  }
88 
90  {
91  m_actual -= n;
92  return *this;
93  }
94 
96  {
97  NavigableIterator tmp = *this;
98  tmp += n;
99  return tmp;
100  }
101 
103  {
104  NavigableIterator tmp = *this;
105  tmp -= n;
106  return tmp;
107  }
108 
110  {
111  return m_actual - other.m_actual;
112  }
113 
114 
116 
117  const child_type* operator*() const
118  {
120  }
121 
122  const child_type* operator->() const
123  {
125  }
126 
128  {
130  }
131 
133  {
135  }
136 
137 
139 
141  {
142  return m_actual == other.m_actual;
143  }
144 
146  {
147  return m_actual != other.m_actual;
148  }
149 
150  bool operator< (const NavigableIterator& other) const
151  {
152  return m_actual < other.m_actual;
153  }
154 
155  bool operator> (const NavigableIterator& other) const
156  {
157  return m_actual > other.m_actual;
158  }
159 
161  {
162  return m_actual <= other.m_actual;
163  }
164 
166  {
167  return m_actual >= other.m_actual;
168  }
169 
170 
172 
174  {
175  m_actual = m_collection->begin();
176  return *this;
177  }
178 
180  {
181  m_actual = m_collection->end();
182  return *this;
183  }
184 
186  {
187  ++m_actual;
188  return *this;
189  }
190 
192  {
193  --m_actual;
194  return *this;
195  }
196 
197  RPAR getParameter() const
198  {
200  }
201 
202  // access to internal iterator
203  typename COLL::const_iterator getInternalIterator() const
204  {
205  return m_actual;
206  }
207 
208 
209 
210 protected:
211 
212  typename COLL::const_iterator m_actual;
213  const COLL* m_collection;
214 };
215 
216 
217 template <typename CONT, typename RPAR, typename COLL>
221 
222 {
223  a += n;
224  return a;
225 }
226 
227 #endif
NavigableIterator::m_collection
const COLL * m_collection
Definition: NavigableIterator.h:213
NavigableIterator::operator-=
NavigableIterator & operator-=(difference_type n)
Definition: NavigableIterator.h:89
NavigableIterator::operator<=
bool operator<=(const NavigableIterator &other) const
Definition: NavigableIterator.h:160
NavigableIterator::operator[]
const child_type * operator[](difference_type n) const
Definition: NavigableIterator.h:127
NavigableIterator::operator-
NavigableIterator operator-(difference_type n) const
Definition: NavigableIterator.h:102
NavigableIterator::difference_type
COLL::const_iterator::difference_type difference_type
Definition: NavigableIterator.h:29
NavigableIterator::helper_type
NavigationDefaults::DefaultChildColl< CONT, RPAR > helper_type
Definition: NavigableIterator.h:34
NavigableIterator::reference
value_type reference
Definition: NavigableIterator.h:31
NavigableIterator::m_actual
COLL::const_iterator m_actual
Definition: NavigableIterator.h:212
NavigableIterator
Definition: NavigableIterator.h:24
NavigableIterator::operator+=
NavigableIterator & operator+=(difference_type n)
Definition: NavigableIterator.h:83
NavigableIterator::operator+
NavigableIterator operator+(difference_type n) const
Definition: NavigableIterator.h:95
NavigableIterator::NavigableIterator
NavigableIterator()
Definition: NavigableIterator.h:42
NavigationDefaults::DefaultChildColl::getChildPar
static RPAR getChildPar(type_const_iterator thisIter)
Definition: NavigationDefaults.h:91
NavigableIterator::iterator_category
COLL::const_iterator::iterator_category iterator_category
Definition: NavigableIterator.h:27
NavigableIterator::next
NavigableIterator next()
Definition: NavigableIterator.h:185
NavigableIterator::getInternalIterator
COLL::const_iterator getInternalIterator() const
Definition: NavigableIterator.h:203
NavigableIterator::getElement
const ElementLink< CONT > & getElement() const
Definition: NavigableIterator.h:132
NavigationDefaults.h
operator+
NavigableIterator< CONT, RPAR, COLL > operator+(typename NavigableIterator< CONT, RPAR, COLL >::difference_type n, NavigableIterator< CONT, RPAR, COLL > a)
Definition: NavigableIterator.h:219
beamspotman.n
n
Definition: beamspotman.py:731
NavigableIterator::operator->
const child_type * operator->() const
Definition: NavigableIterator.h:122
NavigableIterator::operator>=
bool operator>=(const NavigableIterator &other) const
Definition: NavigableIterator.h:165
DeMoUpdate.tmp
string tmp
Definition: DeMoUpdate.py:1167
NavigableIterator::operator>
bool operator>(const NavigableIterator &other) const
Definition: NavigableIterator.h:155
NavigableIterator::value_type
const CONT::base_value_type * value_type
Definition: NavigableIterator.h:28
NavigableIterator::child_type
CONT::base_value_type child_type
Definition: NavigableIterator.h:33
NavigableIterator::NavigableIterator
NavigableIterator(const COLL &theCollection)
Definition: NavigableIterator.h:46
NavigableIterator::operator==
bool operator==(const NavigableIterator &other) const
Definition: NavigableIterator.h:140
a
TList * a
Definition: liststreamerinfos.cxx:10
NavigableIterator::begin
NavigableIterator begin()
Definition: NavigableIterator.h:173
InDetDD::other
@ other
Definition: InDetDD_Defs.h:16
NavigationDefaults::DefaultChildColl
Definition: NavigationDefaults.h:69
NavigableIterator::getParameter
RPAR getParameter() const
Definition: NavigableIterator.h:197
NavigationDefaults::DefaultChildColl::getChildPtr
static const_child_ptr getChildPtr(type_const_iterator thisIter)
Definition: NavigationDefaults.h:82
NavigableIterator::operator--
NavigableIterator & operator--()
Definition: NavigableIterator.h:70
NavigableIterator::operator!=
bool operator!=(const NavigableIterator &other) const
Definition: NavigableIterator.h:145
NavigableIterator::previous
NavigableIterator previous()
Definition: NavigableIterator.h:191
NavigableIterator::operator<
bool operator<(const NavigableIterator &other) const
Definition: NavigableIterator.h:150
value_type
Definition: EDM_MasterSearch.h:11
NavigableIterator::operator++
NavigableIterator & operator++()
Definition: NavigableIterator.h:57
NavigableIterator::end
NavigableIterator end()
Definition: NavigableIterator.h:179
NavigableIterator::operator*
const child_type * operator*() const
Definition: NavigableIterator.h:117
NavigationDefaults::DefaultChildColl::getElementPtr
static const ElementLink< CONT > * getElementPtr(type_const_iterator thisIter)
Definition: NavigationDefaults.h:95
NavigableIterator::pointer
value_type * pointer
Definition: NavigableIterator.h:30