Milena (Olena)  User documentation 2.0a Id
 All Classes Namespaces Functions Variables Typedefs Enumerator Groups Pages
neighb_niter_impl.hh
1 // Copyright (C) 2008, 2009 EPITA Research and Development Laboratory
2 // (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_INTERNAL_NEIGHB_NITER_IMPL_HH
28 # define MLN_CORE_INTERNAL_NEIGHB_NITER_IMPL_HH
29 
33 
34 # include <mln/core/macros.hh>
35 # include <mln/core/internal/force_exact.hh>
36 
37 
38 namespace mln
39 {
40 
41  // Forward declaration.
42  template <typename P, typename W> class graph_window_base;
43  template <typename G, typename S> class graph_elt_window;
44  template <typename G, typename S, typename S2> class graph_elt_mixed_window;
45  template <typename G, typename F, typename I> class graph_elt_window_if;
46  template <typename G, typename F> class line_graph_elt_window;
47  namespace util
48  {
49  template <typename G> class vertex;
50  template <typename G> class edge;
51  }
52 
53 
54  namespace internal
55  {
56 
58  template <typename W, typename E>
59  struct neighb_niter_impl
60  {
61 
62  };
63 
76  template <typename P, typename E>
77  struct neighb_niter_impl_graph_window
78  {
79  unsigned id() const
80  {
81  return internal::force_exact<E>(*this).compute_p_().id();
82  }
83 
84  };
85 
91  template <typename G, typename E>
92  struct neighb_niter_impl_graph_window< util::vertex<G>, E >
93  {
94  };
95 
101  template <typename G, typename E>
102  struct neighb_niter_impl_graph_window< util::edge<G>, E >
103  {
104  };
105 
106 
109  template <typename P, typename T, typename E>
110  struct neighb_niter_impl< graph_window_base<P, T>, E >
111  : neighb_niter_impl_graph_window<P,E>
112  {
113  typedef typename T::target S;
114 
115  // Tech. note: A copy is returned since it actually is a
116  // temporary object; we cannot return a "const&" here for some
117  // compilers badly kills the temporary object...
118  mln_graph_element(S) element() const
119  {
120  return internal::force_exact<E>(*this).compute_p_().element();
121  }
122 
123  };
124 
125 
126 
129  template <typename G, typename S, typename E>
130  struct neighb_niter_impl<graph_elt_window<G,S>, E>
131  : public neighb_niter_impl< graph_window_base< mln_result(S::fun_t),
132  graph_elt_window<G,S> >,
133  E >
134  {
135 
136  };
137 
140  template <typename G, typename F, typename E>
141  struct neighb_niter_impl<line_graph_elt_window<G,F>, E>
142  : public neighb_niter_impl< graph_window_base< mln_result(F),
143  line_graph_elt_window<G, F> >,
144  E >
145  {
146 
147  };
148 
149 
152  template <typename G, typename S, typename I, typename E>
153  struct neighb_niter_impl<graph_elt_window_if<G,S,I>, E>
154  : public neighb_niter_impl< graph_window_base< mln_result(S::fun_t),
155  graph_elt_window_if<G,S,I> >,
156  E >
157  {
158 
159  };
160 
161 
164  template <typename G, typename S, typename S2, typename E>
165  struct neighb_niter_impl<graph_elt_mixed_window<G,S,S2>, E>
166  : public neighb_niter_impl< graph_window_base< mln_result(S2::fun_t),
167  graph_elt_mixed_window<G,S,S2> >,
168  E >
169  {
170 
171  };
172 
173 
174  } // end of namespace mln::internal
175 
176 } // end of namespace mln
177 
178 #endif // ! MLN_CORE_INTERNAL_NEIGHB_NITER_IMPL_HH