$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
piter_adaptor.hh
1 // Copyright (C) 2007, 2008, 2009, 2012, 2013 EPITA Research and
2 // Development 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_INTERNAL_PITER_ADAPTOR_HH
28 # define MLN_CORE_INTERNAL_PITER_ADAPTOR_HH
29 
38 
39 # include <mln/core/internal/site_iterator_base.hh>
40 
41 
42 namespace mln
43 {
44 
45  namespace internal
46  {
47 
54  template <typename Pi, typename S, typename E>
56  {
57  public:
58 
61 
63  piter_adaptor_(const Pi& piter);
64 
67  bool is_valid_() const;
68 
70  void invalidate_();
71 
73  void start_();
74 
76  void next_();
77 
79  const mln_psite(S)& p_hook_() const;
80 
83  void pi_change_target_(const S& s);
85 
87  void change_target(const S& s);
88 
89  protected:
90 
92  Pi pi_;
93  };
94 
95 
96 # ifndef MLN_INCLUDE_ONLY
97 
98  template <typename Pi, typename S, typename E>
99  inline
101  {
102  }
103 
104  template <typename Pi, typename S, typename E>
105  inline
107  : pi_(pi)
108  {
109  invalidate_();
110  }
111 
112  template <typename Pi, typename S, typename E>
113  inline
114  bool
115  piter_adaptor_<Pi,S,E>::is_valid_() const
116  {
117  return pi_.is_valid();
118  }
119 
120  template <typename Pi, typename S, typename E>
121  inline
122  void
123  piter_adaptor_<Pi,S,E>::invalidate_()
124  {
125  pi_.invalidate();
126  }
127 
128  template <typename Pi, typename S, typename E>
129  inline
130  void
131  piter_adaptor_<Pi,S,E>::start_()
132  {
133  pi_.start();
134  }
135 
136  template <typename Pi, typename S, typename E>
137  inline
138  void
139  piter_adaptor_<Pi,S,E>::next_()
140  {
141  pi_.next();
142  }
143 
144  template <typename Pi, typename S, typename E>
145  inline
146  const mln_psite(S)&
147  piter_adaptor_<Pi,S,E>::p_hook_() const
148  {
149  return pi_.p_hook_();
150  }
151 
152  template <typename Pi, typename S, typename E>
153  inline
154  void
155  piter_adaptor_<Pi,S,E>::change_target(const S& s)
156  {
157  this->s_ = & s;
158  // p might be also updated since it can hold a pointer towards
159  // the set it designates, so:
160  exact(this)->pi_change_target_(s);
161  // Last:
162  this->invalidate();
163  }
164 
165  template <typename Pi, typename S, typename E>
166  inline
167  void
168  piter_adaptor_<Pi,S,E>::pi_change_target_(const S& s)
169  {
170  this->pi_.change_target(s);
171  }
172 
173 # endif // ! MLN_INCLUDE_ONLY
174 
175  } // end of namespace mln::internal
176 
177 } // end of namespace mln
178 
179 
180 #endif // ! MLN_CORE_INTERNAL_PITER_ADAPTOR_HH