00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef MLN_CORE_CONCEPT_SITE_ITERATOR_HH
00027 # define MLN_CORE_CONCEPT_SITE_ITERATOR_HH
00028
00034
00035
00036 # include <mln/core/concept/site_proxy.hh>
00037 # include <mln/core/concept/iterator.hh>
00038
00039
00040 namespace mln
00041 {
00042
00052 template <typename E>
00053 struct Site_Iterator : public Site_Proxy<E>
00054 {
00055
00056
00057
00058
00059
00060
00061
00062
00071 void next();
00072
00073
00074 bool is_valid() const;
00075 void invalidate();
00076 void start();
00077
00078
00079
00080
00081 protected:
00082 Site_Iterator();
00083 };
00084
00085
00086
00087 # ifndef MLN_INCLUDE_ONLY
00088
00089 template <typename E>
00090 inline
00091 void
00092 Site_Iterator<E>::next()
00093 {
00094 mln_precondition(is_valid());
00095 exact(this)->next_();
00096 }
00097
00098 template <typename E>
00099 inline
00100 bool
00101 Site_Iterator<E>::is_valid() const
00102 {
00103 E *const this_ = const_cast<E*const>(exact(this));
00104 if (this_->target_() == 0)
00105 return false;
00106 return exact(this)->is_valid_();
00107 }
00108
00109 template <typename E>
00110 inline
00111 void
00112 Site_Iterator<E>::invalidate()
00113 {
00114 if (exact(this)->target_() == 0)
00115 return;
00116 exact(this)->invalidate_();
00117 mln_postcondition(is_valid() == false);
00118 }
00119
00120 template <typename E>
00121 inline
00122 void
00123 Site_Iterator<E>::start()
00124 {
00125 mln_precondition(exact(this)->target_() != 0);
00126 exact(this)->start_();
00127 }
00128
00129 template <typename E>
00130 inline
00131 Site_Iterator<E>::Site_Iterator()
00132 {
00133 bool m0 = (& E::target_) == (& E::target_);
00134 m0 = 0;
00135 bool (E::*m1)() const = & E::is_valid_;
00136 m1 = 0;
00137 void (E::*m2)() = & E::invalidate_;
00138 m2 = 0;
00139 void (E::*m3)() = & E::start_;
00140 m3 = 0;
00141 void (E::*m4)() = & E::next_;
00142 m4 = 0;
00143 bool m5 = (& E::change_target) == (& E::change_target);
00144 m5 = 0;
00145 }
00146
00147 # endif // ! MLN_INCLUDE_ONLY
00148
00149 }
00150
00151
00152 #endif // ! MLN_CORE_CONCEPT_SITE_ITERATOR_HH