Milena (Olena)
User documentation 2.0a Id
|
00001 // Copyright (C) 2008, 2009 EPITA Research and Development Laboratory 00002 // (LRDE) 00003 // 00004 // This file is part of Olena. 00005 // 00006 // Olena is free software: you can redistribute it and/or modify it under 00007 // the terms of the GNU General Public License as published by the Free 00008 // Software Foundation, version 2 of the License. 00009 // 00010 // Olena is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 // General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License 00016 // along with Olena. If not, see <http://www.gnu.org/licenses/>. 00017 // 00018 // As a special exception, you may use this file as part of a free 00019 // software project without restriction. Specifically, if other files 00020 // instantiate templates or use macros or inline functions from this 00021 // file, or you compile this file and link it with other files to produce 00022 // an executable, this file does not by itself cause the resulting 00023 // executable to be covered by the GNU General Public License. This 00024 // exception does not however invalidate any other reasons why the 00025 // executable file might be covered by the GNU General Public License. 00026 00027 #ifndef MLN_CORE_INTERNAL_SITE_ITERATOR_BASE_HH 00028 # define MLN_CORE_INTERNAL_SITE_ITERATOR_BASE_HH 00029 00033 00034 00035 # include <mln/core/concept/site_iterator.hh> 00036 # include <mln/core/concept/pseudo_site.hh> // Use of if_possible::change_target. 00037 00038 00039 00040 namespace mln 00041 { 00042 00043 namespace internal 00044 { 00045 00056 template <typename S, typename E> 00057 struct site_iterator_base : Site_Iterator<E>, 00058 proxy_impl< const mln_psite(S)&, E> 00059 { 00061 typedef S target; 00062 00064 typedef mln_site(S) site; 00065 00067 const mln_site(S)& to_site() const; 00068 00069 00070 // Technical note: 00071 // 00072 // A conversion operator towards the site it designates is 00073 // not required since it is inherited from 'proxy_impl'. 00074 // Defining '::operator mln_site(S)() const' here can lead to 00075 // ambiguities in very special cases since we inherit a couple 00076 // of conversions (const and non-const) 00077 00078 00080 const mln_psite(S)& subj_(); 00081 00083 const S*& target_(); 00084 00085 protected: 00086 00087 site_iterator_base(); 00088 00090 const S* s_; 00091 00092 private: 00093 00094 typedef proxy_impl< const mln_psite(S)&, E> super_; 00095 }; 00096 00097 00098 #ifndef MLN_INCLUDE_ONLY 00099 00100 template <typename S, typename E> 00101 inline 00102 site_iterator_base<S, E>::site_iterator_base() 00103 : s_(0) 00104 { 00105 } 00106 00107 template <typename S, typename E> 00108 inline 00109 const mln_site(S)& 00110 site_iterator_base<S, E>::to_site() const 00111 { 00112 mln_precondition(exact(*this).is_valid()); 00113 return this->get_subject(); 00114 } 00115 00116 template <typename S, typename E> 00117 inline 00118 const mln_psite(S)& 00119 site_iterator_base<S, E>::subj_() 00120 { 00121 return exact(this)->p_hook_(); 00122 } 00123 00124 template <typename S, typename E> 00125 inline 00126 const S*& 00127 site_iterator_base<S, E>::target_() 00128 { 00129 return s_; 00130 } 00131 00132 #endif // ! MLN_INCLUDE_ONLY 00133 00134 } // end of namespace internal 00135 00136 } // end of namespace mln 00137 00138 00139 #endif // ! MLN_CORE_INTERNAL_SITE_ITERATOR_BASE_HH