Milena (Olena)
User documentation 2.0a Id
|
00001 // Copyright (C) 2008, 2009 EPITA Research and Development Laboratory (LRDE) 00002 // 00003 // This file is part of Olena. 00004 // 00005 // Olena is free software: you can redistribute it and/or modify it under 00006 // the terms of the GNU General Public License as published by the Free 00007 // Software Foundation, version 2 of the License. 00008 // 00009 // Olena is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 // General Public License for more details. 00013 // 00014 // You should have received a copy of the GNU General Public License 00015 // along with Olena. If not, see <http://www.gnu.org/licenses/>. 00016 // 00017 // As a special exception, you may use this file as part of a free 00018 // software project without restriction. Specifically, if other files 00019 // instantiate templates or use macros or inline functions from this 00020 // file, or you compile this file and link it with other files to produce 00021 // an executable, this file does not by itself cause the resulting 00022 // executable to be covered by the GNU General Public License. This 00023 // exception does not however invalidate any other reasons why the 00024 // executable file might be covered by the GNU General Public License. 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 /* FIXME: Rename internal::p_complex_piter_base_ to something else, as 00036 it is also used for p_faces piters. Maybe 00037 internal::complex_piter_base_, but it is really close to 00038 internal::complex_iter_base_... */ 00039 00040 namespace mln 00041 { 00042 00043 namespace internal 00044 { 00045 00046 /*------------------------------------. 00047 | p_complex_piter_base_<I, S, P, E>. | 00048 `------------------------------------*/ 00049 00050 // FIXME: P could probably be deduced from S. 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 | p_complex_piter_base_<I, S, P, E>. | 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 // Update psite_. 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 } // end of mln::internal 00200 00201 } // end of mln 00202 00203 00204 #endif // ! MLN_CORE_INTERNAL_P_COMPLEX_PITER_BASE_HH