Milena (Olena)  User documentation 2.0a Id
 All Classes Namespaces Functions Variables Typedefs Enumerator Groups Pages
neighb_niter_base.hh
1 // Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
2 //
3 // This file is part of Olena.
4 //
5 // Olena is free software: you can redistribute it and/or modify it under
6 // the terms of the GNU General Public License as published by the Free
7 // Software Foundation, version 2 of the License.
8 //
9 // Olena is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with Olena. If not, see <http://www.gnu.org/licenses/>.
16 //
17 // As a special exception, you may use this file as part of a free
18 // software project without restriction. Specifically, if other files
19 // instantiate templates or use macros or inline functions from this
20 // file, or you compile this file and link it with other files to produce
21 // an executable, this file does not by itself cause the resulting
22 // executable to be covered by the GNU General Public License. This
23 // exception does not however invalidate any other reasons why the
24 // executable file might be covered by the GNU General Public License.
25 
26 #ifndef MLN_CORE_INTERNAL_NEIGHB_NITER_BASE_HH
27 # define MLN_CORE_INTERNAL_NEIGHB_NITER_BASE_HH
28 
32 
33 # include <mln/core/internal/site_relative_iterator_base.hh>
34 # include <mln/core/internal/neighb_niter_impl.hh>
35 
36 namespace mln
37 {
38 
39  namespace internal
40  {
41 
42  // neighb_niter_base<W,I,E>
43 
44  template <typename W, typename N, typename I, typename E>
45  class neighb_niter_base
46  : public internal::site_relative_iterator_base< N,
47  E,
48  mln_psite(N) >,
49  public internal::neighb_niter_impl<W,E>
50  {
51  public:
52 
54  neighb_niter_base();
55 
56  template <typename P>
57  neighb_niter_base(const N& nbh, const P& c);
58 
60  bool is_valid_() const;
61 
63  void invalidate_();
64 
66  void do_start_();
67 
69  void do_next_();
70 
72  mln_psite(W) compute_p_() const;
73 
74  protected:
75 
76  I i_;
77  };
78 
79 
80 
81 # ifndef MLN_INCLUDE_ONLY
82 
83 
84  // neighb_niter_base<W,N,I,E>
85 
86  template <typename W, typename N, typename I, typename E>
87  inline
88  neighb_niter_base<W,N,I,E>::neighb_niter_base()
89  {
90  }
91 
92  template <typename W, typename N, typename I, typename E>
93  template <typename P>
94  inline
95  neighb_niter_base<W,N,I,E>::neighb_niter_base(const N& nbh, const P& c)
96  {
97  this->change_target(nbh);
98  this->center_at(c);
99 
100  }
101 
102  template <typename W, typename N, typename I, typename E>
103  inline
104  bool
105  neighb_niter_base<W,N,I,E>::is_valid_() const
106  {
107  return i_.is_valid();
108  }
109 
110  template <typename W, typename N, typename I, typename E>
111  inline
112  void
113  neighb_niter_base<W,N,I,E>::invalidate_()
114  {
115  i_.invalidate();
116  }
117 
118  template <typename W, typename N, typename I, typename E>
119  inline
120  void
121  neighb_niter_base<W,N,I,E>::do_start_()
122  {
123  i_.start();
124  }
125 
126  template <typename W, typename N, typename I, typename E>
127  inline
128  void
129  neighb_niter_base<W,N,I,E>::do_next_()
130  {
131  i_.next();
132  }
133 
134  template <typename W, typename N, typename I, typename E>
135  inline
136  mln_psite(W)
137  neighb_niter_base<W,N,I,E>::compute_p_() const
138  {
139  return i_.compute_p_();
140  }
141 
142 
143 # endif // ! MLN_INCLUDE_ONLY
144 
145 
146  } // end of namespace mln::internal
147 
148 } // end of namespace mln
149 
150 
151 #endif // ! MLN_CORE_INTERNAL_NEIGHB_NITER_BASE_HH