Milena (Olena)
User documentation 2.0a Id
|
00001 // Copyright (C) 2007, 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_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 // p might be also updated since it can hold a pointer towards 00155 // the set it designates, so: 00156 exact(this)->pi_change_target_(s); 00157 // Last: 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 } // end of namespace mln::internal 00172 00173 } // end of namespace mln 00174 00175 00176 #endif // ! MLN_CORE_INTERNAL_PITER_ADAPTOR_HH