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_SITE_SET_P_VERTICES_PSITE_HH 00028 # define MLN_CORE_SITE_SET_P_VERTICES_PSITE_HH 00029 00033 00034 # include <mln/core/concept/pseudo_site.hh> 00035 # include <mln/core/internal/graph_psite_base.hh> 00036 # include <mln/util/vertex.hh> 00037 00038 00039 namespace mln 00040 { 00041 00042 // Forward declarations. 00043 template <typename G, typename F> class p_vertices; 00044 namespace internal 00045 { 00046 00047 template <typename Subject, typename E> struct subject_impl; 00048 00049 } 00050 00051 00052 template <typename G, typename F> 00053 class p_vertices_psite : 00054 public internal::graph_psite_base< p_vertices<G,F>, p_vertices_psite<G,F> > 00055 { 00056 typedef p_vertices_psite<G,F> self_; 00057 typedef internal::graph_psite_base<p_vertices<G,F>, self_> super_; 00058 00059 public: 00060 00061 typedef p_vertices<G,F> target_t; 00062 00063 p_vertices_psite(); 00064 p_vertices_psite(const p_vertices<G,F>& s); 00065 p_vertices_psite(const p_vertices<G,F>& s, unsigned id); 00066 00067 const util::vertex<G>& v() const; 00068 }; 00069 00070 00071 template <typename G, typename F> 00072 bool 00073 operator==(const p_vertices_psite<G,F>& lhs, const p_vertices_psite<G,F>& rhs); 00074 00075 template <typename G, typename F> 00076 bool 00077 operator!=(const p_vertices_psite<G,F>& lhs, const p_vertices_psite<G,F>& rhs); 00078 00079 template <typename G, typename F> 00080 bool 00081 operator<(const p_vertices_psite<G,F>& lhs, const p_vertices_psite<G,F>& rhs); 00082 00083 00084 namespace internal 00085 { 00086 00088 00089 template <typename G, typename F, typename E> 00090 struct subject_impl< const p_vertices_psite<G,F>&, E > 00091 : subject_impl< const graph_psite_base< p_vertices<G,F>, 00092 p_vertices_psite<G,F> >&, E > 00093 { 00094 const util::vertex<G>& v() const; 00095 00096 private: 00097 const E& exact_() const; 00098 }; 00099 00100 template <typename G, typename F, typename E> 00101 struct subject_impl< p_vertices_psite<G,F>&, E > 00102 : subject_impl< const p_vertices_psite<G,F>&, E >, 00103 subject_impl< graph_psite_base< p_vertices<G,F>, 00104 p_vertices_psite<G,F> >&, E > 00105 { 00106 }; 00107 00108 } // end of namespace mln::internal 00109 00110 00111 00112 # ifndef MLN_INCLUDE_ONLY 00113 00114 template <typename G, typename F> 00115 inline 00116 p_vertices_psite<G, F>::p_vertices_psite() 00117 { 00118 } 00119 00120 template <typename G, typename F> 00121 inline 00122 p_vertices_psite<G, F>::p_vertices_psite(const p_vertices<G,F>& s) 00123 : super_(s) 00124 { 00125 } 00126 00127 template <typename G, typename F> 00128 inline 00129 p_vertices_psite<G, F>::p_vertices_psite(const p_vertices<G,F>& s, unsigned i) 00130 : super_(s, i) 00131 { 00132 } 00133 00134 template <typename G, typename F> 00135 inline 00136 const util::vertex<G>& 00137 p_vertices_psite<G, F>::v() const 00138 { 00139 return this->elt_; 00140 } 00141 00142 /*--------------. 00143 | Comparisons. | 00144 `--------------*/ 00145 00146 template <typename G, typename F> 00147 bool 00148 operator==(const p_vertices_psite<G,F>& lhs, const p_vertices_psite<G,F>& rhs) 00149 { 00150 mln_assertion(lhs.target_() == rhs.target_()); 00151 return lhs.id() == rhs.id(); 00152 } 00153 00154 template <typename G, typename F> 00155 bool 00156 operator!=(const p_vertices_psite<G,F>& lhs, const p_vertices_psite<G,F>& rhs) 00157 { 00158 mln_assertion(lhs.target_() == rhs.target_()); 00159 return lhs.id() != rhs.id(); 00160 } 00161 00162 template <typename G, typename F> 00163 bool 00164 operator<(const p_vertices_psite<G,F>& lhs, const p_vertices_psite<G,F>& rhs) 00165 { 00166 mln_assertion(lhs.target_() == rhs.target_()); 00167 return lhs.id() < rhs.id(); 00168 } 00169 00170 00171 00172 00173 namespace internal 00174 { 00175 00177 00178 template <typename G, typename F, typename E> 00179 inline 00180 const E& 00181 subject_impl< const p_vertices_psite<G,F>&, E >::exact_() const 00182 { 00183 return internal::force_exact<const E>(*this); 00184 } 00185 00186 template <typename G, typename F, typename E> 00187 inline 00188 const util::vertex<G>& 00189 subject_impl< const p_vertices_psite<G,F>&, E >::v() const 00190 { 00191 return exact_().get_subject().v(); 00192 } 00193 00194 } // end of namespace mln::internal 00195 00196 00197 # endif // ! MLN_INCLUDE_ONLY 00198 00199 } // end of namespace mln 00200 00201 00202 #endif // ! MLN_CORE_SITE_SET_P_VERTICES_PSITE_HH