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_PITER_ADAPTOR_HH
00027 # define MLN_CORE_INTERNAL_PITER_ADAPTOR_HH
00028 
00037 
00038 # include <mln/core/internal/site_iterator_base.hh>
00039 
00040 
00041 namespace mln
00042 {
00043 
00044   namespace internal
00045   {
00046 
00052     template <typename Pi, typename S, typename E>
00053     class piter_adaptor_ : public internal::site_iterator_base< S, E >
00054     {
00055     public:
00056 
00058       piter_adaptor_();
00059 
00061       piter_adaptor_(const Pi& piter);
00062 
00064       bool is_valid_() const;
00065 
00067       void invalidate_();
00068 
00070       void start_();
00071 
00073       void next_();
00074 
00076       const mln_psite(S)& p_hook_() const;
00077 
00079       void change_target(const S& s);
00080 
00083       void pi_change_target_(const S& s);
00084 
00085     protected:
00086 
00088       Pi pi_;
00089     };
00090 
00091 
00092 # ifndef MLN_INCLUDE_ONLY
00093 
00094     template <typename Pi, typename S, typename E>
00095     inline
00096     piter_adaptor_<Pi,S,E>::piter_adaptor_()
00097     {
00098     }
00099 
00100     template <typename Pi, typename S, typename E>
00101     inline
00102     piter_adaptor_<Pi,S,E>::piter_adaptor_(const Pi& pi)
00103       : pi_(pi)
00104     {
00105       invalidate_();
00106     }
00107 
00108     template <typename Pi, typename S, typename E>
00109     inline
00110     bool
00111     piter_adaptor_<Pi,S,E>::is_valid_() const
00112     {
00113       return pi_.is_valid();
00114     }
00115 
00116     template <typename Pi, typename S, typename E>
00117     inline
00118     void
00119     piter_adaptor_<Pi,S,E>::invalidate_()
00120     {
00121       pi_.invalidate();
00122     }
00123 
00124     template <typename Pi, typename S, typename E>
00125     inline
00126     void
00127     piter_adaptor_<Pi,S,E>::start_()
00128     {
00129       pi_.start();
00130     }
00131 
00132     template <typename Pi, typename S, typename E>
00133     inline
00134     void
00135     piter_adaptor_<Pi,S,E>::next_()
00136     {
00137       pi_.next();
00138     }
00139 
00140     template <typename Pi, typename S, typename E>
00141     inline
00142     const mln_psite(S)&
00143     piter_adaptor_<Pi,S,E>::p_hook_() const
00144     {
00145       return pi_.p_hook_();
00146     }
00147 
00148     template <typename Pi, typename S, typename E>
00149     inline
00150     void
00151     piter_adaptor_<Pi,S,E>::change_target(const S& s)
00152     {
00153       this->s_ = & s;
00154       
00155       
00156       exact(this)->pi_change_target_(s);
00157       
00158       this->invalidate();
00159     }
00160 
00161     template <typename Pi, typename S, typename E>
00162     inline
00163     void
00164     piter_adaptor_<Pi,S,E>::pi_change_target_(const S& s)
00165     {
00166       this->pi_.change_target(s);
00167     }
00168 
00169 # endif // ! MLN_INCLUDE_ONLY
00170 
00171   } 
00172 
00173 } 
00174 
00175 
00176 #endif // ! MLN_CORE_INTERNAL_PITER_ADAPTOR_HH