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_CONCEPT_SITE_ITERATOR_HH 00027 # define MLN_CORE_CONCEPT_SITE_ITERATOR_HH 00028 00034 00035 00036 # include <mln/core/concept/site_proxy.hh> 00037 # include <mln/core/concept/iterator.hh> // To fetch the macros. 00038 00039 00040 namespace mln 00041 { 00042 00052 template <typename E> 00053 struct Site_Iterator : public Site_Proxy<E> 00054 { 00055 /* 00056 bool is_valid_() const; 00057 void invalidate_(); 00058 void start_(); 00059 void next_(); 00060 const ..& target_() const; 00061 */ 00062 00071 void next(); // final 00072 00073 // FIXME: Doc!!! 00074 bool is_valid() const; 00075 void invalidate(); 00076 void start(); 00077 00078 // Defined in site_iterator_base: 00079 // void change_target(s); 00080 00081 protected: 00082 Site_Iterator(); 00083 }; 00084 00085 00086 00087 # ifndef MLN_INCLUDE_ONLY 00088 00089 template <typename E> 00090 inline 00091 void 00092 Site_Iterator<E>::next() 00093 { 00094 mln_precondition(is_valid()); 00095 exact(this)->next_(); 00096 } 00097 00098 template <typename E> 00099 inline 00100 bool 00101 Site_Iterator<E>::is_valid() const 00102 { 00103 E *const this_ = const_cast<E*const>(exact(this)); // Unconst. 00104 if (this_->target_() == 0) 00105 return false; 00106 return exact(this)->is_valid_(); 00107 } 00108 00109 template <typename E> 00110 inline 00111 void 00112 Site_Iterator<E>::invalidate() 00113 { 00114 if (exact(this)->target_() == 0) 00115 return; // No-op. 00116 exact(this)->invalidate_(); 00117 mln_postcondition(is_valid() == false); 00118 } 00119 00120 template <typename E> 00121 inline 00122 void 00123 Site_Iterator<E>::start() 00124 { 00125 mln_precondition(exact(this)->target_() != 0); 00126 exact(this)->start_(); 00127 } 00128 00129 template <typename E> 00130 inline 00131 Site_Iterator<E>::Site_Iterator() 00132 { 00133 bool m0 = (& E::target_) == (& E::target_); // FIXME: Find a better test. 00134 m0 = 0; 00135 bool (E::*m1)() const = & E::is_valid_; 00136 m1 = 0; 00137 void (E::*m2)() = & E::invalidate_; 00138 m2 = 0; 00139 void (E::*m3)() = & E::start_; 00140 m3 = 0; 00141 void (E::*m4)() = & E::next_; 00142 m4 = 0; 00143 bool m5 = (& E::change_target) == (& E::change_target); 00144 m5 = 0; 00145 } 00146 00147 # endif // ! MLN_INCLUDE_ONLY 00148 00149 } // end of namespace mln 00150 00151 00152 #endif // ! MLN_CORE_CONCEPT_SITE_ITERATOR_HH