PolyBoRi

CCuddFirstIter.h

Go to the documentation of this file.
00001 // -*- c++ -*-
00002 //*****************************************************************************
00054 //*****************************************************************************
00055 
00056 // include basic definitions
00057 #include "CCuddNavigator.h"
00058 
00059 // include boost's interator facade
00060 #include <boost/iterator/iterator_facade.hpp>
00061 
00062 #ifndef CCuddFirstIter_h_
00063 #define CCuddFirstIter_h_
00064 
00065 BEGIN_NAMESPACE_PBORI
00066 
00073 class CCuddFirstIter : 
00074   public boost::iterator_facade<
00075   CCuddFirstIter,
00076   CCuddNavigator::value_type,
00077   std::forward_iterator_tag,
00078   CCuddNavigator::reference
00079   > {
00080 
00081 public:
00082 
00084   typedef std::forward_iterator_tag iterator_category;
00085 
00087   typedef CCuddFirstIter self;
00088 
00090   typedef CCuddNavigator navigator;
00091 
00093   typedef navigator::const_access_type const_access_type;
00094 
00096   typedef navigator::bool_type bool_type;
00097 
00099   CCuddFirstIter(): m_navi() {}
00100 
00102   CCuddFirstIter(navigator rhs): m_navi(rhs) { terminateConstant(); }
00103 
00105   ~CCuddFirstIter() {}
00106 
00108   void increment() {
00109     m_navi.incrementThen();
00110     terminateConstant();
00111   }
00112 
00114   bool_type equal (const self& rhs) const { return (m_navi == rhs.m_navi); }
00115 
00117   navigator::reference dereference() const { return *m_navi; }
00118 
00120   bool_type isEnd() const { return !m_navi.isValid(); }
00121 
00122 protected:
00124   void terminateConstant() {
00125     if (m_navi.isConstant()) 
00126       *this = self();           // mark end of path reached
00127 
00128   }
00129 
00131   navigator m_navi;
00132 };
00133 
00134 END_NAMESPACE_PBORI
00135 
00136 #endif