ATLAS Offline Software
SelectAllObjectMT.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef EVENTCONTAINERS_SELECTALLOBJECTMT_H
6 #define EVENTCONTAINERS_SELECTALLOBJECTMT_H
7 
8 //after SelectAllObjectMT is destroyed all iterators become invalid!
9 template < class DCC, typename OBJECT = typename DCC::IDENTIFIABLE::DIGIT >
11 {
12 public:
13  typedef typename DCC::IDENTIFIABLE DC;
14 // typedef typename DC::OBJECT OBJECT;
15 // typedef OBJECT OBJECT;
17  typedef typename DC::const_iterator Object_const_iterator;
18  typedef typename DCC::const_iterator Cont_iterator;
19 // typedef typename DCC::Hash_Container::const_iterator Hash_iterator;
20 
22  {
26  const DC* m_dc; // cache DC
27  friend class SelectAllObjectMT<DCC,OBJECT>;
28 
30 
31 SKIPNEXT:
32 
33  ++m_cont_itr;
34  if(m_cont_itr != m_Parent->m_dcc->end()) {
35  m_dc = *m_cont_itr;
36  m_digit_it = m_dc->begin();
37  if(m_digit_it == m_dc->end()) goto SKIPNEXT;
38  } else {
39  m_dc = nullptr;
41  }
42  }
43 
44  public:
45 
47  :
48  m_cont_itr(),
49  m_Parent(nullptr),
50  m_digit_it(),
51  m_dc(nullptr)
52  {}
53 
55  Object_const_iterator digitit, const DC* dc )
56  :
57  m_cont_itr(itr),
59  m_digit_it(digitit),
60  m_dc(dc)
61  {}
62 
63  const OBJECT* operator * ()
64  {
65  return *m_digit_it;
66  }
67 
68 
69 
70 
71  const_iterator& operator ++ () // pre increment
72  {
73  ++m_digit_it;
74  if(m_digit_it != m_dc->end()) {
75  // OK
76  } else
77  {
78  // reached end of a collection,
80  }
81  return *this;
82 
83  }
84 
85 
86  const_iterator operator ++ ( int ) // post increment
87  { const_iterator tmp = *this;
88  ++*this;
89  return tmp;
90  }
91 
92 
93  bool operator != ( const const_iterator it ) const
94  {
95  if( it.m_cont_itr != m_cont_itr || it.m_digit_it != m_digit_it )
96  return true;
97 
98  return false;
99  }
100 
101  bool operator == ( const const_iterator it ) const
102  {
103  return( it.m_cont_itr == m_cont_itr && it.m_digit_it == m_digit_it );
104  }
105 
106 
107 
108  };
109 
110  SelectAllObjectMT(const DCC* dcc) : m_dcc(dcc)
111  { }
112 
113  SelectAllObjectMT( ) = delete;
114 
116  auto b = m_dcc->begin();
117 NEXT:
118  const DC* dc = nullptr;
119  Object_const_iterator digit_it;
120  if(b!= m_dcc->end()) {
121  dc = *b;
122  digit_it = dc->begin();
123  if(digit_it == dc->end()){
124  ++b;
125  goto NEXT;
126  }
127  }
128  return const_iterator(b, this, digit_it, dc);
129  }
130 
132  auto b = m_dcc->end();
133  const DC* dc = nullptr;
134  Object_const_iterator digit_it;
135  return const_iterator(b, this, digit_it, dc);
136  }
137 
138  //Compatability with C++11
140  return begin();
141  }
143  return end();
144  }
145 
146 
147 private:
148  // pointer to the container it is processing.
149  const DCC* m_dcc;
150 };
151 
152 
153 #endif
SelectAllObjectMT::Cont_iterator
DCC::const_iterator Cont_iterator
Definition: SelectAllObjectMT.h:18
SelectAllObjectMT::const_iterator::operator==
bool operator==(const const_iterator it) const
Definition: SelectAllObjectMT.h:101
SelectAllObjectMT::end
const_iterator end()
Definition: SelectAllObjectMT.h:131
skel.it
it
Definition: skel.GENtoEVGEN.py:396
SelectAllObjectMT::DC
DCC::IDENTIFIABLE DC
Definition: SelectAllObjectMT.h:13
SelectAllObjectMT::Object_const_iterator
DC::const_iterator Object_const_iterator
Definition: SelectAllObjectMT.h:17
SelectAllObjectMT::begin
const_iterator begin()
Definition: SelectAllObjectMT.h:115
SelectAllObjectMT
Definition: SelectAllObjectMT.h:11
SelectAllObjectMT::cbegin
const_iterator cbegin()
Definition: SelectAllObjectMT.h:139
SelectAllObjectMT::m_dcc
const DCC * m_dcc
Definition: SelectAllObjectMT.h:149
test_pyathena.parent
parent
Definition: test_pyathena.py:15
SelectAllObjectMT::const_iterator::const_iterator
const_iterator(const Cont_iterator &itr, const SelectAllObjectMT< DCC, OBJECT > *parent, Object_const_iterator digitit, const DC *dc)
Definition: SelectAllObjectMT.h:54
SelectAllObjectMT::const_iterator
Definition: SelectAllObjectMT.h:22
DeMoUpdate.tmp
string tmp
Definition: DeMoUpdate.py:1167
SelectAllObjectMT::const_iterator::m_digit_it
Object_const_iterator m_digit_it
Definition: SelectAllObjectMT.h:25
SelectAllObjectMT::cend
const_iterator cend()
Definition: SelectAllObjectMT.h:142
SelectAllObjectMT::const_iterator::const_iterator
const_iterator()
Definition: SelectAllObjectMT.h:46
SelectAllObjectMT::const_iterator::operator++
const_iterator & operator++()
Definition: SelectAllObjectMT.h:71
SelectAllObjectMT::SelectAllObjectMT
SelectAllObjectMT()=delete
SelectAllObjectMT::MyType
SelectAllObjectMT< DCC, OBJECT > MyType
Definition: SelectAllObjectMT.h:16
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
SelectAllObjectMT::const_iterator::AdvanceCollection
void AdvanceCollection()
Definition: SelectAllObjectMT.h:29
SelectAllObjectMT::const_iterator::operator*
const OBJECT * operator*()
Definition: SelectAllObjectMT.h:63
SelectAllObjectMT::const_iterator::m_cont_itr
Cont_iterator m_cont_itr
Definition: SelectAllObjectMT.h:23
SelectAllObjectMT::const_iterator::m_dc
const DC * m_dc
Definition: SelectAllObjectMT.h:26
SelectAllObjectMT::const_iterator::m_Parent
const SelectAllObjectMT< DCC, OBJECT > * m_Parent
Definition: SelectAllObjectMT.h:24
SelectAllObjectMT::const_iterator::operator!=
bool operator!=(const const_iterator it) const
Definition: SelectAllObjectMT.h:93
SelectAllObjectMT::SelectAllObjectMT
SelectAllObjectMT(const DCC *dcc)
Definition: SelectAllObjectMT.h:110