$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
site_iterator.hh
1 // Copyright (C) 2007, 2008, 2009, 2011, 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_CONCEPT_SITE_ITERATOR_HH
28 # define MLN_CORE_CONCEPT_SITE_ITERATOR_HH
29 
35 
36 
37 # include <mln/core/concept/site_proxy.hh>
38 # include <mln/core/concept/iterator.hh> // To fetch the macros.
39 
40 
41 namespace mln
42 {
43 
53  template <typename E>
54  struct Site_Iterator : public Site_Proxy<E>
55  {
56  /*
57  bool is_valid_() const;
58  void invalidate_();
59  void start_();
60  void next_();
61  const ..& target_() const;
62  */
63 
72  void next(); // final
73 
74  // FIXME: Doc!!!
75  bool is_valid() const;
76  void invalidate();
77  void start();
78 
79  // Defined in site_iterator_base:
80  // void change_target(s);
81 
82  protected:
83  Site_Iterator();
84  };
85 
86 
87 
88 # ifndef MLN_INCLUDE_ONLY
89 
90  template <typename E>
91  inline
92  void
94  {
95  mln_precondition(is_valid());
96  exact(this)->next_();
97  }
98 
99  template <typename E>
100  inline
101  bool
103  {
104  E *const this_ = const_cast<E*const>(exact(this)); // Unconst.
105  if (this_->target_() == 0)
106  return false;
107  return exact(this)->is_valid_();
108  }
109 
110  template <typename E>
111  inline
112  void
114  {
115  if (exact(this)->target_() == 0)
116  return; // No-op.
117  exact(this)->invalidate_();
118  mln_postcondition(is_valid() == false);
119  }
120 
121  template <typename E>
122  inline
123  void
125  {
126  mln_precondition(exact(this)->target_() != 0);
127  exact(this)->start_();
128  }
129 
130  template <typename E>
131  inline
133  {
134  bool m0 = (& E::target_) == (& E::target_); // FIXME: Find a better test.
135  (void) m0;
136  bool (E::*m1)() const = & E::is_valid_;
137  (void) m1;
138  void (E::*m2)() = & E::invalidate_;
139  (void) m2;
140  void (E::*m3)() = & E::start_;
141  (void) m3;
142  void (E::*m4)() = & E::next_;
143  (void) m4;
144  bool m5 = (& E::change_target) == (& E::change_target);
145  (void) m5;
146  }
147 
148 # endif // ! MLN_INCLUDE_ONLY
149 
150 } // end of namespace mln
151 
152 
153 #endif // ! MLN_CORE_CONCEPT_SITE_ITERATOR_HH