$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
plain.hh
1 // Copyright (C) 2007, 2008, 2009, 2011, 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_IMAGE_IMORPH_PLAIN_HH
28 # define MLN_CORE_IMAGE_IMORPH_PLAIN_HH
29 
34 
35 # include <mln/core/internal/image_identity.hh>
36 # include <mln/core/routine/duplicate.hh>
37 # include <mln/metal/is_not_const.hh>
38 
39 
40 namespace mln
41 {
42 
43  // Forward declaration.
44  template <typename I> class plain;
45 
46 
47  namespace internal
48  {
49 
53  template <typename I>
54  struct data< plain<I> >
55  {
56  data(const I& ima);
57  I ima_;
58  };
59 
60  } // end of namespace mln::internal
61 
62 
63  namespace trait
64  {
65 
66  template <typename I>
67  struct image_< plain<I> > : image_< I > // Same as I except...
68  {
69  // ...these changes:
70  typedef trait::image::category::identity_morpher category;
71  typedef mln_internal_trait_image_speed_from(I) speed; // Un-fastest.
72  };
73 
74  } // end of namespace mln::trait
75 
76 
77 
83  //
84  template <typename I>
85  class plain
86 
87  : public mln::internal::image_identity< I, mln_domain(I), plain<I> >,
88  private mlc_is_not_const(I)::check_t
89  {
90  typedef plain<I> self_;
92 
93  public:
94 
97 
99  plain();
100 
102  plain(const plain<I>& rhs);
103 
105  plain(const I& ima);
106 
109  void init_(const I& ima);
111 
113  plain<I>& operator=(const plain<I>& rhs);
114 
116  plain<I>& operator=(const I& ima);
117 
119  operator I () const;
120  };
121 
122 
123 
124 # ifndef MLN_INCLUDE_ONLY
125 
126 
127  // internal::data< plain<I> >
128 
129  namespace internal
130  {
131 
132  template <typename I>
133  inline
134  data< plain<I> >::data(const I& ima)
135  : ima_(duplicate(ima))
136  {
137  }
138 
139  } // end of namespace mln::internal
140 
141 
142  // plain<I>
143 
144  template <typename I>
145  inline
146  plain<I>::plain()
147  {
148  }
149 
150  template <typename I>
151  inline
152  plain<I>::plain(const plain<I>& rhs)
153  : super_()
154  {
155  mln_precondition(rhs.is_valid());
156  init_(rhs.data_->ima_);
157  }
158 
159  template <typename I>
160  inline
161  plain<I>::plain(const I& ima)
162  {
163  mln_precondition(ima.is_valid());
164  init_(ima);
165  }
166 
167  template <typename I>
168  inline
169  void
170  plain<I>::init_(const I& ima)
171  {
172  mln_precondition(ima.is_valid());
173  this->data_ = new internal::data< plain<I> >(ima);
174  }
175 
176  template <typename I>
177  inline
178  plain<I>&
179  plain<I>::operator=(const plain<I>& rhs)
180  {
181  mln_precondition(rhs.is_valid());
182  if (&rhs == this)
183  return *this;
184  this->destroy();
185  init_(rhs.data_->ima_);
186  return *this;
187  }
188 
189  template <typename I>
190  inline
191  plain<I>&
192  plain<I>::operator=(const I& ima)
193  {
194  mln_precondition(ima.is_valid());
195  this->destroy();
196  init_(ima);
197  return *this;
198  }
199 
200  template <typename I>
201  inline
202  plain<I>::operator I () const
203  {
204  mln_precondition(this->is_valid());
205  return duplicate(this->data_->ima_);
206  }
207 
208 # endif // ! MLN_INCLUDE_ONLY
209 
210 } // end of namespace mln
211 
212 
213 #endif // ! MLN_CORE_IMAGE_IMORPH_PLAIN_HH