00001
00002
00013
00014
00015 #ifndef polybori_iterators_CTermIter_h_
00016 #define polybori_iterators_CTermIter_h_
00017
00018
00019 #include <polybori/pbori_defs.h>
00020
00021
00022 #include <polybori/routines/pbori_func.h>
00023
00024
00025 #include <polybori/common/traits.h>
00026
00027
00028
00029 #include <boost/iterator/iterator_facade.hpp>
00030
00031 #include <polybori/BooleEnv.h>
00032
00033
00034 BEGIN_NAMESPACE_PBORI
00035
00036
00043 template <class StackType, class TermGeneratorType>
00044 class CTermIter:
00045 public boost::iterator_facade<
00046 CTermIter<StackType, TermGeneratorType>,
00047 typename TermGeneratorType::value_type,
00048 typename StackType::iterator_category,
00049 typename TermGeneratorType::result_type
00050 > {
00051
00052 public:
00053
00055 typedef StackType stack_type;
00056
00058 typedef typename stack_type::navigator navigator;
00059
00061 typedef typename navigator::idx_type idx_type;
00062
00064 typedef typename navigator::bool_type bool_type;
00065
00067 typedef typename navigator::size_type size_type;
00068
00070 typedef typename navigator::deg_type deg_type;
00071
00073 typedef TermGeneratorType term_generator;
00074
00076
00077 typedef typename stack_type::const_iterator const_iterator;
00078 typedef typename stack_type::const_reverse_iterator
00079 const_reverse_iterator;
00081
00083 CTermIter(const CTermIter& rhs):
00084 m_getTerm(rhs.m_getTerm), m_stack(rhs.m_stack) {
00085 }
00086
00088 template <class MgrType>
00089 CTermIter(navigator navi, const MgrType& mgr):
00090 m_getTerm(mgr), m_stack(navi, mgr) {
00091 m_stack.init();
00092 }
00093
00095 ~CTermIter() {}
00096
00098 void increment() {
00099 m_stack.increment();
00100 }
00101
00103 void decrement() {
00104 m_stack.decrement();
00105 }
00106
00108 bool_type equal (const CTermIter& rhs) const {
00109 return m_stack.equal(rhs.m_stack);
00110 }
00111
00113 typename term_generator::result_type dereference() const {
00114 return m_getTerm(m_stack);
00115 }
00116
00118
00119 const_iterator begin() const { return m_stack.begin(); }
00120 const_iterator end() const { return m_stack.end(); }
00121 const_reverse_iterator rbegin() const { return m_stack.rbegin(); }
00122 const_reverse_iterator rend() const { return m_stack.rend(); }
00124
00126 bool_type isOne() const { return m_stack.isOne(); }
00127
00129 bool_type isZero() const { return m_stack.isZero(); }
00130
00132 bool_type isEnd() const { return isZero(); }
00133
00135 deg_type deg() const { return m_stack.deg(); }
00136
00138 idx_type firstIndex() const {
00139 PBORI_ASSERT(!m_stack.empty());
00140 return *begin();
00141 }
00142
00144 navigator navigation() const {
00145 return m_stack.navigation();
00146 }
00147
00148 protected:
00150 term_generator m_getTerm;
00151
00153 stack_type m_stack;
00154 };
00155
00156
00157 END_NAMESPACE_PBORI
00158
00159 #endif
00160