$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
p_vertices_psite.hh
1 // Copyright (C) 2008, 2009, 2012, 2013 EPITA Research and Development
2 // Laboratory (LRDE)
3 //
4 // This file is part of Olena.
5 //
6 // Olena is free software: you can redistribute it and/or modify it under
7 // the terms of the GNU General Public License as published by the Free
8 // Software Foundation, version 2 of the License.
9 //
10 // Olena is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with Olena. If not, see <http://www.gnu.org/licenses/>.
17 //
18 // As a special exception, you may use this file as part of a free
19 // software project without restriction. Specifically, if other files
20 // instantiate templates or use macros or inline functions from this
21 // file, or you compile this file and link it with other files to produce
22 // an executable, this file does not by itself cause the resulting
23 // executable to be covered by the GNU General Public License. This
24 // exception does not however invalidate any other reasons why the
25 // executable file might be covered by the GNU General Public License.
26 
27 #ifndef MLN_CORE_SITE_SET_P_VERTICES_PSITE_HH
28 # define MLN_CORE_SITE_SET_P_VERTICES_PSITE_HH
29 
33 
34 # include <mln/core/concept/pseudo_site.hh>
35 # include <mln/core/internal/graph_psite_base.hh>
36 # include <mln/util/vertex.hh>
37 
38 
39 namespace mln
40 {
41 
42  // Forward declarations.
43  template <typename G, typename F> class p_vertices;
44  namespace internal
45  {
46 
47  template <typename Subject, typename E> struct subject_impl;
48 
49  }
50 
51 
52  template <typename G, typename F>
54  public internal::graph_psite_base< p_vertices<G,F>, p_vertices_psite<G,F> >
55  {
58 
59  public:
60 
62 
65  p_vertices_psite(const p_vertices<G,F>& s, unsigned id);
66 
67  const util::vertex<G>& v() const;
68  };
69 
70 
72  template <typename G, typename F>
73  bool
75 
77  template <typename G, typename F>
78  bool
80 
82  template <typename G, typename F>
83  bool
84  operator<(const p_vertices_psite<G,F>& lhs, const p_vertices_psite<G,F>& rhs);
85 
86 
87  namespace internal
88  {
89 
93  template <typename G, typename F, typename E>
94  struct subject_impl< const p_vertices_psite<G,F>&, E >
96  p_vertices_psite<G,F> >&, E >
97  {
98  const util::vertex<G>& v() const;
99 
100  private:
101  const E& exact_() const;
102  };
103 
104  template <typename G, typename F, typename E>
105  struct subject_impl< p_vertices_psite<G,F>&, E >
108  p_vertices_psite<G,F> >&, E >
109  {
110  };
111 
112  } // end of namespace mln::internal
113 
114 
115 
116 # ifndef MLN_INCLUDE_ONLY
117 
118  template <typename G, typename F>
119  inline
121  {
122  }
123 
124  template <typename G, typename F>
125  inline
126  p_vertices_psite<G, F>::p_vertices_psite(const p_vertices<G,F>& s)
127  : super_(s)
128  {
129  }
130 
131  template <typename G, typename F>
132  inline
133  p_vertices_psite<G, F>::p_vertices_psite(const p_vertices<G,F>& s, unsigned i)
134  : super_(s, i)
135  {
136  }
137 
138  template <typename G, typename F>
139  inline
140  const util::vertex<G>&
142  {
143  return this->elt_;
144  }
145 
146  /*--------------.
147  | Comparisons. |
148  `--------------*/
149 
150  template <typename G, typename F>
151  bool
152  operator==(const p_vertices_psite<G,F>& lhs, const p_vertices_psite<G,F>& rhs)
153  {
154  mln_assertion(lhs.target_() == rhs.target_());
155  return lhs.id() == rhs.id();
156  }
157 
158  template <typename G, typename F>
159  bool
160  operator!=(const p_vertices_psite<G,F>& lhs, const p_vertices_psite<G,F>& rhs)
161  {
162  mln_assertion(lhs.target_() == rhs.target_());
163  return lhs.id() != rhs.id();
164  }
165 
166  template <typename G, typename F>
167  bool
168  operator<(const p_vertices_psite<G,F>& lhs, const p_vertices_psite<G,F>& rhs)
169  {
170  mln_assertion(lhs.target_() == rhs.target_());
171  return lhs.id() < rhs.id();
172  }
173 
174 
175 
176 
177  namespace internal
178  {
179 
181 
182  template <typename G, typename F, typename E>
183  inline
184  const E&
185  subject_impl< const p_vertices_psite<G,F>&, E >::exact_() const
186  {
187  return internal::force_exact<const E>(*this);
188  }
189 
190  template <typename G, typename F, typename E>
191  inline
192  const util::vertex<G>&
194  {
195  return exact_().get_subject().v();
196  }
197 
198  } // end of namespace mln::internal
199 
200 
201 # endif // ! MLN_INCLUDE_ONLY
202 
203 } // end of namespace mln
204 
205 
206 #endif // ! MLN_CORE_SITE_SET_P_VERTICES_PSITE_HH