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_SITE_SET_P_EDGES_PSITE_HH 00027 # define MLN_CORE_SITE_SET_P_EDGES_PSITE_HH 00028 00032 00033 # include <mln/core/internal/graph_psite_base.hh> 00034 # include <mln/util/edge.hh> 00035 00036 00037 namespace mln 00038 { 00039 00040 // Forward declaration. 00041 template <typename G, typename F> class p_edges; 00042 namespace util { template <typename G> class vertex; } 00043 namespace internal { template <typename T, typename E> struct subject_impl; } 00044 00045 00046 template <typename G, typename F> 00047 class p_edges_psite : 00048 public internal::graph_psite_base< p_edges<G,F>, p_edges_psite<G,F> > 00049 { 00050 typedef p_edges_psite<G,F> self_; 00051 typedef internal::graph_psite_base<p_edges<G,F>, self_> super_; 00052 00053 public: 00054 00055 typedef p_edges<G,F> target_t; 00056 00059 p_edges_psite(); 00060 p_edges_psite(const p_edges<G,F>& s); 00061 p_edges_psite(const p_edges<G,F>& s, unsigned); 00063 00067 const util::edge<G>& e() const; 00068 util::vertex<G> v1() const; 00069 util::vertex<G> v2() const; 00071 }; 00072 00073 00074 00075 template <typename G, typename F> 00076 bool 00077 operator==(const p_edges_psite<G,F>& lhs, const p_edges_psite<G,F>& rhs); 00078 00079 template <typename G, typename F> 00080 bool 00081 operator!=(const p_edges_psite<G,F>& lhs, const p_edges_psite<G,F>& rhs); 00082 00083 template <typename G, typename F> 00084 bool 00085 operator<(const p_edges_psite<G,F>& lhs, const p_edges_psite<G,F>& rhs); 00086 00087 00088 00089 namespace internal 00090 { 00091 00093 00094 template <typename G, typename F, typename E> 00095 struct subject_impl< const p_edges_psite<G,F>&, E > 00096 : subject_impl< const graph_psite_base< p_edges<G,F>, 00097 p_edges_psite<G,F> >&, E > 00098 { 00099 const util::edge<G>& e() const; 00100 util::vertex<G> v1() const; 00101 util::vertex<G> v2() const; 00102 00103 private: 00104 const E& exact_() const; 00105 }; 00106 00107 template <typename G, typename F, typename E> 00108 struct subject_impl< p_edges_psite<G,F>&, E > 00109 : subject_impl< const p_edges_psite<G,F>&, E >, 00110 subject_impl< graph_psite_base< p_edges<G,F>, 00111 p_edges_psite<G,F> >&, E > 00112 { 00113 }; 00114 00115 } // end of namespace mln::internal 00116 00117 00118 00119 00120 # ifndef MLN_INCLUDE_ONLY 00121 00122 template <typename G, typename F> 00123 inline 00124 p_edges_psite<G, F>::p_edges_psite() 00125 { 00126 } 00127 00128 template <typename G, typename F> 00129 inline 00130 p_edges_psite<G, F>::p_edges_psite(const p_edges<G,F>& s) 00131 : super_(s) 00132 { 00133 } 00134 00135 template <typename G, typename F> 00136 inline 00137 p_edges_psite<G, F>::p_edges_psite(const p_edges<G,F>& s, unsigned id) 00138 : super_(s, id) 00139 { 00140 } 00141 00142 template <typename G, typename F> 00143 inline 00144 const util::edge<G>& 00145 p_edges_psite<G, F>::e() const 00146 { 00147 return this->elt_; 00148 } 00149 00150 template <typename G, typename F> 00151 inline 00152 util::vertex<G> 00153 p_edges_psite<G, F>::v1() const 00154 { 00155 return this->elt_.graph().vertex(this->elt_.v1()); 00156 } 00157 00158 template <typename G, typename F> 00159 inline 00160 util::vertex<G> 00161 p_edges_psite<G, F>::v2() const 00162 { 00163 return this->elt_.graph().vertex(this->elt_.v2()); 00164 } 00165 00166 00167 /*--------------. 00168 | Comparisons. | 00169 `--------------*/ 00170 00171 template <typename G, typename F> 00172 bool 00173 operator==(const p_edges_psite<G,F>& lhs, const p_edges_psite<G,F>& rhs) 00174 { 00175 mln_assertion(lhs.target_() == rhs.target_()); 00176 return lhs.id() == rhs.id(); 00177 } 00178 00179 template <typename G, typename F> 00180 bool 00181 operator!=(const p_edges_psite<G,F>& lhs, const p_edges_psite<G,F>& rhs) 00182 { 00183 mln_assertion(lhs.target_() == rhs.target_()); 00184 return lhs.id() != rhs.id(); 00185 } 00186 00187 template <typename G, typename F> 00188 bool 00189 operator<(const p_edges_psite<G,F>& lhs, const p_edges_psite<G,F>& rhs) 00190 { 00191 mln_assertion(lhs.target_() == rhs.target_()); 00192 return lhs.id() < rhs.id(); 00193 } 00194 00195 00196 00197 namespace internal 00198 { 00199 00201 00202 template <typename G, typename F, typename E> 00203 inline 00204 const E& 00205 subject_impl< const p_edges_psite<G,F>&, E >::exact_() const 00206 { 00207 return internal::force_exact<const E>(*this); 00208 } 00209 00210 template <typename G, typename F, typename E> 00211 inline 00212 const util::edge<G>& 00213 subject_impl< const p_edges_psite<G,F>&, E >::e() const 00214 { 00215 return exact_().get_subject().e(); 00216 } 00217 00218 template <typename G, typename F, typename E> 00219 inline 00220 util::vertex<G> 00221 subject_impl< const p_edges_psite<G,F>&, E >::v1() const 00222 { 00223 return exact_().get_subject().v1(); 00224 } 00225 00226 template <typename G, typename F, typename E> 00227 inline 00228 util::vertex<G> 00229 subject_impl< const p_edges_psite<G,F>&, E >::v2() const 00230 { 00231 return exact_().get_subject().v2(); 00232 } 00233 00234 } // end of namespace mln::internal 00235 00236 # endif // ! MLN_INCLUDE_ONLY 00237 00238 } // end of namespace mln 00239 00240 00241 #endif // ! MLN_CORE_SITE_SET_P_EDGES_PSITE_HH