ATLAS Offline Software
Loading...
Searching...
No Matches
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!
9template < class DCC, typename OBJECT = typename DCC::IDENTIFIABLE::DIGIT >
11{
12public:
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
31SKIPNEXT:
32
33 ++m_cont_itr;
34 if(m_cont_itr != m_Parent->m_dcc->end()) {
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),
58 m_Parent(parent),
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
115 const_iterator begin() {
116 auto b = m_dcc->begin();
117NEXT:
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
131 const_iterator end() {
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
139 const_iterator cbegin() {
140 return begin();
141 }
142 const_iterator cend() {
143 return end();
144 }
145
146
147private:
148 // pointer to the container it is processing.
149 const DCC* m_dcc;
150};
151
152
153#endif
bool operator==(const const_iterator it) const
bool operator!=(const const_iterator it) const
const_iterator(const Cont_iterator &itr, const SelectAllObjectMT< DCC, OBJECT > *parent, Object_const_iterator digitit, const DC *dc)
const SelectAllObjectMT< DCC, OBJECT > * m_Parent
SelectAllObjectMT< DCC, OBJECT > MyType
SelectAllObjectMT(const DCC *dcc)