Milena (Olena)  User documentation 2.0a Id
 All Classes Namespaces Functions Variables Typedefs Enumerator Groups Pages
ch_piter.hh
1 // Copyright (C) 2008, 2009, 2011 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_IMAGE_CH_PITER_HH
28 # define MLN_CORE_IMAGE_CH_PITER_HH
29 
36 # include <mln/core/internal/image_identity.hh>
37 
38 
39 
40 namespace mln
41 {
42 
43  // Forward declaration.
44  template <typename I, typename Fwd> class ch_piter_image;
45 
46 
47  namespace internal
48  {
49 
51  template <typename I, typename Fwd>
52  struct data< ch_piter_image<I,Fwd> >
53  {
54  data(I& ima);
55  I ima_;
56  };
57 
58  } // end of namespace mln::internal
59 
60 
61  namespace trait
62  {
63 
64  template <typename I, typename Fwd>
65  struct image_< ch_piter_image<I,Fwd> > : image_< I > // Same as I except...
66  {
67  // ...theis change.
68  typedef trait::image::category::identity_morpher category;
69  };
70 
71  } // end of namespace mln::trait
72 
73 
74 
75  // FIXME: Doc!
76 
77  template <typename I, typename Fwd>
78  class ch_piter_image : public internal::image_identity< I,
79  mln_domain(I),
80  ch_piter_image<I,Fwd> >
81  {
82  public:
83 
85  typedef ch_piter_image< tag::image_<I>, Fwd > skeleton;
86 
87  typedef Fwd fwd_piter;
88  typedef Fwd bkd_piter; // FIXME
89  typedef fwd_piter piter;
90 
91  ch_piter_image();
92  ch_piter_image(I& ima);
93 
94  // Deferred initialization.
95  void init_(I& ima);
96  };
97 
98 
99 
100  template <typename Fwd, typename I>
101  ch_piter_image<I,Fwd>
102  ch_piter(Image<I>& ima);
103 
104 
105 
106 # ifndef MLN_INCLUDE_ONLY
107 
108 
109  // internal::data< ch_piter_image<I,S> >
110 
111  namespace internal
112  {
113 
114  template <typename I, typename Fwd>
115  inline
117  : ima_(ima)
118  {
119  }
120 
121  } // end of namespace mln::internal
122 
123 
124  // ch_piter_image<I,Fwd>
125 
126  template <typename I, typename Fwd>
127  inline
128  ch_piter_image<I,Fwd>::ch_piter_image()
129  {
130  }
131 
132  template <typename I, typename Fwd>
133  inline
134  ch_piter_image<I,Fwd>::ch_piter_image(I& ima)
135  {
136  mln_precondition(ima.is_valid());
137  init_(ima);
138  }
139 
140  template <typename I, typename Fwd>
141  inline
142  void
143  ch_piter_image<I,Fwd>::init_(I& ima)
144  {
145  mln_precondition(ima.is_valid());
146  this->data_ = new internal::data< ch_piter_image<I,Fwd> >(ima);
147  }
148 
149 
150  // ch_piter
151 
152  template <typename Fwd, typename I>
153  inline
154  ch_piter_image<I,Fwd>
155  ch_piter(Image<I>& ima)
156  {
157  ch_piter_image<I,Fwd> tmp(exact(ima));
158  return tmp;
159  }
160 
161 # endif // ! MLN_INCLUDE_ONLY
162 
163 } // end of namespace mln
164 
165 
166 #endif // ! MLN_CORE_IMAGE_CH_PITER_HH