$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
p_edges_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_EDGES_PSITE_HH
28 # define MLN_CORE_SITE_SET_P_EDGES_PSITE_HH
29 
33 
34 # include <mln/core/internal/graph_psite_base.hh>
35 # include <mln/util/edge.hh>
36 
37 
38 namespace mln
39 {
40 
41  // Forward declaration.
42  template <typename G, typename F> class p_edges;
43  namespace util { template <typename G> class vertex; }
44  namespace internal { template <typename T, typename E> struct subject_impl; }
45 
46 
47  template <typename G, typename F>
48  class p_edges_psite :
49  public internal::graph_psite_base< p_edges<G,F>, p_edges_psite<G,F> >
50  {
51  typedef p_edges_psite<G,F> self_;
53 
54  public:
55 
57 
60  p_edges_psite();
61  p_edges_psite(const p_edges<G,F>& s);
62  p_edges_psite(const p_edges<G,F>& s, unsigned);
64 
68  const util::edge<G>& e() const;
69  util::vertex<G> v1() const;
70  util::vertex<G> v2() const;
72  };
73 
74 
76  template <typename G, typename F>
77  bool
79 
81  template <typename G, typename F>
82  bool
84 
86  template <typename G, typename F>
87  bool
88  operator<(const p_edges_psite<G,F>& lhs, const p_edges_psite<G,F>& rhs);
89 
90 
91 
92  namespace internal
93  {
94 
99  template <typename G, typename F, typename E>
100  struct subject_impl< const p_edges_psite<G,F>&, E >
102  p_edges_psite<G,F> >&, E >
103  {
104  const util::edge<G>& e() const;
105  util::vertex<G> v1() const;
106  util::vertex<G> v2() const;
107 
108  private:
109  const E& exact_() const;
110  };
111 
112  template <typename G, typename F, typename E>
113  struct subject_impl< p_edges_psite<G,F>&, E >
116  p_edges_psite<G,F> >&, E >
117  {
118  };
119 
120  } // end of namespace mln::internal
121 
122 
123 
124 
125 # ifndef MLN_INCLUDE_ONLY
126 
127  template <typename G, typename F>
128  inline
130  {
131  }
132 
133  template <typename G, typename F>
134  inline
135  p_edges_psite<G, F>::p_edges_psite(const p_edges<G,F>& s)
136  : super_(s)
137  {
138  }
139 
140  template <typename G, typename F>
141  inline
142  p_edges_psite<G, F>::p_edges_psite(const p_edges<G,F>& s, unsigned id)
143  : super_(s, id)
144  {
145  }
146 
147  template <typename G, typename F>
148  inline
149  const util::edge<G>&
150  p_edges_psite<G, F>::e() const
151  {
152  return this->elt_;
153  }
154 
155  template <typename G, typename F>
156  inline
157  util::vertex<G>
159  {
160  return this->elt_.graph().vertex(this->elt_.v1());
161  }
162 
163  template <typename G, typename F>
164  inline
165  util::vertex<G>
167  {
168  return this->elt_.graph().vertex(this->elt_.v2());
169  }
170 
171 
172  /*--------------.
173  | Comparisons. |
174  `--------------*/
175 
176  template <typename G, typename F>
177  bool
178  operator==(const p_edges_psite<G,F>& lhs, const p_edges_psite<G,F>& rhs)
179  {
180  mln_assertion(lhs.target_() == rhs.target_());
181  return lhs.id() == rhs.id();
182  }
183 
184  template <typename G, typename F>
185  bool
186  operator!=(const p_edges_psite<G,F>& lhs, const p_edges_psite<G,F>& rhs)
187  {
188  mln_assertion(lhs.target_() == rhs.target_());
189  return lhs.id() != rhs.id();
190  }
191 
192  template <typename G, typename F>
193  bool
194  operator<(const p_edges_psite<G,F>& lhs, const p_edges_psite<G,F>& rhs)
195  {
196  mln_assertion(lhs.target_() == rhs.target_());
197  return lhs.id() < rhs.id();
198  }
199 
200 
201 
202  namespace internal
203  {
204 
206 
207  template <typename G, typename F, typename E>
208  inline
209  const E&
210  subject_impl< const p_edges_psite<G,F>&, E >::exact_() const
211  {
212  return internal::force_exact<const E>(*this);
213  }
214 
215  template <typename G, typename F, typename E>
216  inline
217  const util::edge<G>&
219  {
220  return exact_().get_subject().e();
221  }
222 
223  template <typename G, typename F, typename E>
224  inline
225  util::vertex<G>
227  {
228  return exact_().get_subject().v1();
229  }
230 
231  template <typename G, typename F, typename E>
232  inline
233  util::vertex<G>
235  {
236  return exact_().get_subject().v2();
237  }
238 
239  } // end of namespace mln::internal
240 
241 # endif // ! MLN_INCLUDE_ONLY
242 
243 } // end of namespace mln
244 
245 
246 #endif // ! MLN_CORE_SITE_SET_P_EDGES_PSITE_HH