source: molecuilder/src/Descriptors/SelectiveIterator.hpp@ 0f55b2

Last change on this file since 0f55b2 was 5738177, checked in by Tillmann Crueger <crueger@…>, 15 years ago

Added a generic Iterator that can be used to iterate only over certain parts of an internal data structure

  • Property mode set to 100644
File size: 1.7 KB
Line 
1/*
2 * SelectiveIterator.hpp
3 *
4 * Created on: Mar 17, 2010
5 * Author: crueger
6 */
7
8#ifndef SELECTIVEITERATOR_HPP_
9#define SELECTIVEITERATOR_HPP_
10
11#include <iterator>
12
13template<class _Target,
14 class _Container,
15 class _Descriptor>
16class SelectiveIterator :
17 public std::iterator<typename std::iterator_traits<typename _Container::iterator>::difference_type,
18 typename std::iterator_traits<typename _Container::iterator>::value_type,
19 typename std::iterator_traits<typename _Container::iterator>::pointer,
20 typename std::iterator_traits<typename _Container::iterator>::reference>
21{
22public:
23 typedef typename _Container::iterator Iter;
24 typedef _Target Target;
25 typedef typename Iter::value_type value_type;
26 typedef typename Iter::difference_type difference_type;
27 typedef typename Iter::pointer pointer;
28 typedef typename Iter::reference reference;
29 typedef typename Iter::iterator_category iterator_category;
30
31
32 SelectiveIterator(_Descriptor, _Container&);
33 SelectiveIterator(_Descriptor, _Container&, Iter);
34 SelectiveIterator(const SelectiveIterator&);
35 SelectiveIterator& operator=(const SelectiveIterator&);
36 SelectiveIterator& operator++(); // prefix
37 SelectiveIterator operator++(int); // postfix with dummy parameter
38 bool operator==(const SelectiveIterator&);
39 bool operator!=(const SelectiveIterator&);
40 Target operator*();
41
42 int getCount();
43protected:
44 void advanceState();
45 Iter state;
46 typename _Descriptor::impl_ptr descr;
47 int index;
48
49 _Container &content;
50};
51
52#endif /* SELECTIVEITERATOR_HPP_ */
Note: See TracBrowser for help on using the repository browser.