STIR  6.2.0
NestedIterator.h
Go to the documentation of this file.
1 //
2 //
3 /*
4  Copyright (C) 2000 PARAPET partners
5  Copyright (C) 2000- 2011, Hammersmith Imanet Ltd
6  This file is part of STIR.
7 
8  SPDX-License-Identifier: Apache-2.0 AND License-ref-PARAPET-license
9 
10  See STIR/LICENSE.txt for details
11 */
12 #ifndef __stir_NestedIterator__H__
13 #define __stir_NestedIterator__H__
14 
28 #include "boost/iterator/iterator_traits.hpp"
29 
30 START_NAMESPACE_STIR
31 
92 template <typename topleveliterT, class GetRestRangeFunctionT = BeginEndFunction<topleveliterT>>
94 {
95 private:
96  typedef typename GetRestRangeFunctionT::rest_iter_type rest_iter_type;
97 
98 public:
99  typedef std::forward_iterator_tag iterator_category;
100  typedef typename boost::iterator_difference<rest_iter_type>::type difference_type;
101  typedef typename boost::iterator_value<rest_iter_type>::type value_type;
102  typedef typename boost::iterator_reference<rest_iter_type>::type reference;
103  typedef typename boost::iterator_pointer<rest_iter_type>::type pointer;
104 
105 public:
107  inline NestedIterator();
108 
110  inline NestedIterator(const topleveliterT& top_level_iter, const topleveliterT& end_top_level_iter);
111 
113 
116  template <typename othertopleveliterT, typename otherGetRestRangeFunctionT>
119  typename boost::enable_if_convertible<othertopleveliterT, topleveliterT>::type* = 0,
120  typename boost::enable_if_convertible<typename otherGetRestRangeFunctionT::rest_iter_type, rest_iter_type>::type* = 0)
121  : _current_top_level_iter(other._current_top_level_iter),
122  _end_top_level_iter(other._end_top_level_iter),
123  _current_rest_iter(other._current_rest_iter),
124  _end_rest_iter(other._end_rest_iter)
125  {}
126 
127  // inline NestedIterator& operator=(const NestedIterator&);
128 
130  inline NestedIterator& operator++();
131 
133  inline NestedIterator operator++(int);
134 
136  inline bool operator==(const NestedIterator&) const;
138  inline bool operator!=(const NestedIterator&) const;
139 
141  inline reference operator*() const;
142 
144  inline pointer operator->() const;
145 
146 #ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
147 public:
148 #else
149 private:
150  // needed for conversion constructor
151  template <class, class>
152  friend class NestedIterator;
153 #endif
154 
156  topleveliterT _current_top_level_iter;
157 
159  topleveliterT _end_top_level_iter;
160 
162  rest_iter_type _current_rest_iter;
163 
165  rest_iter_type _end_rest_iter;
166 
167 private:
169  void _set_rest_iters_for_current_top_level_iter();
170 };
171 
172 END_NAMESPACE_STIR
173 
174 #include "stir/NestedIterator.inl"
175 
176 #endif
NestedIterator(NestedIterator< othertopleveliterT, otherGetRestRangeFunctionT > other, typename boost::enable_if_convertible< othertopleveliterT, topleveliterT >::type *=0, typename boost::enable_if_convertible< typename otherGetRestRangeFunctionT::rest_iter_type, rest_iter_type >::type *=0)
constructor to convert between nested iterators using convertible top and next level iterators ...
Definition: NestedIterator.h:117
This file defines supporting function objects for stir::NestedIterator.
Class NestedIterator implements a (forward) iterator using a pair of &#39;nested&#39; iterators.
Definition: NestedIterator.h:93
inline implementations for stir::NestedIterator.