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_INTERNAL_P_COMPLEX_PITER_BASE_HH
00027 # define MLN_CORE_INTERNAL_P_COMPLEX_PITER_BASE_HH
00028 
00032 
00033 # include <mln/core/internal/site_set_iterator_base.hh>
00034 
00035 
00036 
00037 
00038 
00039 
00040 namespace mln
00041 {
00042 
00043   namespace internal
00044   {
00045 
00046     
00047 
00048 
00049 
00050     
00051 
00058     template <typename I, typename S, typename P, typename E>
00059     class p_complex_piter_base_
00060       : public internal::site_set_iterator_base< S, E >
00061     {
00062       typedef p_complex_piter_base_< I, S, P, E > self_;
00063       typedef internal::site_set_iterator_base< S, E > super_;
00064 
00066       typedef I iter;
00067 
00068     public:
00071       p_complex_piter_base_();
00072       p_complex_piter_base_(const S& pc);
00074 
00077     public:
00079       bool is_valid_() const;
00081       void invalidate_();
00082 
00084       void start_();
00086       void next_();
00087 
00089       void change_target_(const S& pc);
00090 
00091     private:
00093       void update_();
00095 
00096     protected:
00098       using super_::p_;
00100       iter iter_;
00101     };
00102 
00103 
00105     template <typename I, typename S, typename P, typename E>
00106     inline
00107     std::ostream&
00108     operator<<(std::ostream& ostr, const p_complex_piter_base_<I, S, P, E>& p);
00109 
00110 
00111 
00112 # ifndef MLN_INCLUDE_ONLY
00113 
00114     
00115 
00116 
00117 
00118     template <typename I, typename S, typename P, typename E>
00119     inline
00120     p_complex_piter_base_<I, S, P, E>::p_complex_piter_base_()
00121     {
00122       mln_postcondition(!this->is_valid());
00123     }
00124 
00125     template <typename I, typename S, typename P, typename E>
00126     inline
00127     p_complex_piter_base_<I, S, P, E>::p_complex_piter_base_(const S& pc)
00128     {
00129       this->change_target(pc);
00130       mln_postcondition(!this->is_valid());
00131     }
00132 
00133     template <typename I, typename S, typename P, typename E>
00134     inline
00135     void
00136     p_complex_piter_base_<I, S, P, E>::change_target_(const S& pc)
00137     {
00138       iter_.set_cplx(pc.cplx());
00139     }
00140 
00141     template <typename I, typename S, typename P, typename E>
00142     inline
00143     bool
00144     p_complex_piter_base_<I, S, P, E>::is_valid_() const
00145     {
00146       return iter_.is_valid();
00147     }
00148 
00149     template <typename I, typename S, typename P, typename E>
00150     inline
00151     void
00152     p_complex_piter_base_<I, S, P, E>::invalidate_()
00153     {
00154       iter_.invalidate();
00155     }
00156 
00157     template <typename I, typename S, typename P, typename E>
00158     inline
00159     void
00160     p_complex_piter_base_<I, S, P, E>::start_()
00161     {
00162       iter_.start();
00163       if (this->is_valid())
00164         update_();
00165     }
00166 
00167     template <typename I, typename S, typename P, typename E>
00168     inline
00169     void
00170     p_complex_piter_base_<I, S, P, E>::next_()
00171     {
00172       iter_.next_();
00173       if (this->is_valid())
00174         update_();
00175     }
00176 
00177     template <typename I, typename S, typename P, typename E>
00178     inline
00179     void
00180     p_complex_piter_base_<I, S, P, E>::update_()
00181     {
00182       mln_precondition(this->is_valid());
00183       
00184       typedef mln_psite(S) psite;
00185       p_ = psite(exact(this)->site_set(), iter_);
00186     }
00187 
00188 
00189     template <typename I, typename S, typename P, typename E>
00190     inline
00191     std::ostream&
00192     operator<<(std::ostream& ostr, const p_complex_piter_base_<I, S, P, E>& p)
00193     {
00194       return ostr << p.unproxy_();
00195     }
00196 
00197 # endif // ! MLN_INCLUDE_ONLY
00198 
00199   } 
00200 
00201 } 
00202 
00203 
00204 #endif // ! MLN_CORE_INTERNAL_P_COMPLEX_PITER_BASE_HH