PolyBoRi
CVariableIter.h
Go to the documentation of this file.
1 // -*- c++ -*-
2 //*****************************************************************************
13 //*****************************************************************************
14 
15 #ifndef polybori_iterators_CVariableIter_h_
16 #define polybori_iterators_CVariableIter_h_
17 
18 // include basic definitions
19 #include <polybori/pbori_defs.h>
20 
22 
31 template <class Iterator, class VariableType>
32 class CVariableIter :
33  public boost::iterator_facade<
34  CVariableIter<Iterator, VariableType>,
35  VariableType,
36  typename Iterator::iterator_category,
37  VariableType
38  > {
39 
40 public:
42  typedef Iterator iterator_type;
43 
45  typedef VariableType var_type;
46 
48  typedef typename var_type::ring_type ring_type;
49 
52 
54  CVariableIter(): m_iter(), m_ring() {}
55 
57  CVariableIter(const iterator_type& rhs, const ring_type& ring):
58  m_iter(rhs), m_ring(ring) {}
59 
61  bool isEnd() const { return m_iter.isEnd(); }
62 
64  void increment() { ++m_iter; }
65 
67  var_type dereference() const { return var_type(*m_iter, m_ring); }
68 
70  bool equal(const self& rhs) const { return m_iter == rhs.m_iter; }
71 
72 private:
74  iterator_type m_iter;
75 
77  ring_type m_ring;
78 };
79 
81 
82 
83 #endif // CVariableIter_h_