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_SITE_SET_P_TRANSFORMED_PITER_HH
00027 # define MLN_CORE_SITE_SET_P_TRANSFORMED_PITER_HH
00028
00032
00033 # include <mln/core/internal/site_set_iterator_base.hh>
00034 # include <mln/core/site_set/p_transformed.hh>
00035 # include <mln/convert/to.hh>
00036
00037
00038 namespace mln
00039 {
00040
00041
00048
00049 template <typename Pi, typename S, typename F>
00050 struct p_transformed_piter
00051 : public internal::site_set_iterator_base< p_transformed<S,F>,
00052 p_transformed_piter<Pi,S,F> >
00053 {
00055 p_transformed_piter();
00056
00058 p_transformed_piter(const p_transformed<S,F>& s);
00059
00061 bool is_valid_() const;
00062
00064 void invalidate_();
00065
00067 void start_();
00068
00070 void next_();
00071
00073 void change_target(const p_transformed<S,F>& s);
00074
00075 private:
00076 typedef p_transformed_piter<Pi,S,F> self_;
00077 typedef internal::site_set_iterator_base<p_transformed<S,F>, self_> super_;
00078
00079 protected:
00080 using super_::s_;
00081 using super_::p_;
00082
00083
00084 Pi pi_;
00085 };
00086
00087
00088
00089 # ifndef MLN_INCLUDE_ONLY
00090
00091 template <typename Pi, typename S, typename F>
00092 inline
00093 p_transformed_piter<Pi,S,F>::p_transformed_piter()
00094 {
00095 }
00096
00097 template <typename Pi, typename S, typename F>
00098 inline
00099 p_transformed_piter<Pi,S,F>::p_transformed_piter(const p_transformed<S,F>& s)
00100 {
00101 this->change_target(s);
00102 }
00103
00104 template <typename Pi, typename S, typename F>
00105 inline
00106 bool
00107 p_transformed_piter<Pi,S,F>::is_valid_() const
00108 {
00109 return pi_.is_valid();
00110 }
00111
00112 template <typename Pi, typename S, typename F>
00113 inline
00114 void
00115 p_transformed_piter<Pi,S,F>::invalidate_()
00116 {
00117 pi_.invalidate();
00118 }
00119
00120 template <typename Pi, typename S, typename F>
00121 inline
00122 void
00123 p_transformed_piter<Pi,S,F>::start_()
00124 {
00125 pi_.start();
00126 if (pi_.is_valid())
00127 p_ = s_->function()(convert::to<mln_argument(F)>(pi_));
00128 }
00129
00130 template <typename Pi, typename S, typename F>
00131 inline
00132 void
00133 p_transformed_piter<Pi,S,F>::next_()
00134 {
00135 pi_.next();
00136 if (pi_.is_valid())
00137 p_ = s_->function()(convert::to<mln_argument(F)>(pi_));
00138 }
00139
00140 template <typename Pi, typename S, typename F>
00141 inline
00142 void
00143 p_transformed_piter<Pi,S,F>::change_target(const p_transformed<S,F>& s)
00144 {
00145 s_ = & s;
00146
00147
00148 pi_.change_target(s.primary_set());
00149
00150 this->invalidate();
00151 }
00152
00153 # endif // ! MLN_INCLUDE_ONLY
00154
00155 }
00156
00157
00158 #endif // ! MLN_CORE_SITE_SET_P_TRANSFORMED_PITER_HH