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