00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
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
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 }
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
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 }
00195
00196
00197 # endif // ! MLN_INCLUDE_ONLY
00198
00199 }
00200
00201
00202 #endif // ! MLN_CORE_SITE_SET_P_VERTICES_PSITE_HH