]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | <!-- Copyright 2008 Lubomir Bourdev and Hailin Jin |
2 | ||
3 | Distributed under the Boost Software License, Version 1.0. | |
4 | (See accompanying file LICENSE_1_0.txt or copy at | |
5 | http://www.boost.org/LICENSE_1_0.txt) | |
6 | --> | |
7 | ||
8 | <!-- | |
9 | Copyright 2005-2007 Adobe Systems Incorporated | |
10 | Distributed under the MIT License (see accompanying file LICENSE_1_0_0.txt | |
11 | or a copy at http://stlab.adobe.com/licenses.html) | |
12 | ||
13 | Some files are held under additional license. | |
14 | Please see "http://stlab.adobe.com/licenses.html" for more information. | |
15 | --> | |
16 | ||
17 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" | |
18 | "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
19 | <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> | |
20 | ||
21 | <head> | |
22 | <TITLE>Generic Image Library: step_iterator.hpp Source File</TITLE> | |
23 | <META HTTP-EQUIV="content-type" CONTENT="text/html;charset=ISO-8859-1"/> | |
24 | <LINK TYPE="text/css" REL="stylesheet" HREF="adobe_source.css"/> | |
25 | </head> | |
26 | <body> | |
27 | <table border="0" cellspacing="0" cellpadding="0" style='width: 100%; margin: 0; padding: 0'><tr> | |
28 | <td width="100%" valign="top" style='padding-left: 10px; padding-right: 10px; padding-bottom: 10px'> | |
29 | <div class="qindex"><a class="qindex" href="index.html">Modules</a> | |
30 | | <a class="qindex" href="classes.html">Alphabetical List</a> | |
31 | | <a class="qindex" href="annotated.html">Class List</a> | |
32 | | <a class="qindex" href="dirs.html">Directories</a> | |
33 | | <a class="qindex" href="files.html">File List</a> | |
34 | | <a class="qindex" href="../index.html">GIL Home Page</a> | |
35 | </div> | |
36 | <!-- End Header --> | |
37 | <!-- Generated by Doxygen 1.5.6 --> | |
38 | <div class="navpath"><a class="el" href="g_i_l_0076.html">boost</a> » <a class="el" href="g_i_l_0079.html">gil</a> | |
39 | </div> | |
40 | <div class="contents"> | |
41 | <h1>step_iterator.hpp</h1><a href="g_i_l_0260.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span> | |
42 | <a name="l00002"></a>00002 <span class="comment"> Copyright 2005-2007 Adobe Systems Incorporated</span> | |
43 | <a name="l00003"></a>00003 <span class="comment"> </span> | |
44 | <a name="l00004"></a>00004 <span class="comment"> Use, modification and distribution are subject to the Boost Software License,</span> | |
45 | <a name="l00005"></a>00005 <span class="comment"> Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at</span> | |
46 | <a name="l00006"></a>00006 <span class="comment"> http://www.boost.org/LICENSE_1_0.txt).</span> | |
47 | <a name="l00007"></a>00007 <span class="comment"></span> | |
48 | <a name="l00008"></a>00008 <span class="comment"> See http://opensource.adobe.com/gil for most recent version including documentation.</span> | |
49 | <a name="l00009"></a>00009 <span class="comment">*/</span> | |
50 | <a name="l00010"></a>00010 | |
51 | <a name="l00011"></a>00011 <span class="comment">/*************************************************************************************************/</span> | |
52 | <a name="l00012"></a>00012 | |
53 | <a name="l00013"></a>00013 <span class="preprocessor">#ifndef GIL_STEP_ITERATOR_H</span> | |
54 | <a name="l00014"></a>00014 <span class="preprocessor"></span><span class="preprocessor">#define GIL_STEP_ITERATOR_H</span> | |
55 | <a name="l00015"></a>00015 <span class="preprocessor"></span> | |
56 | <a name="l00024"></a>00024 | |
57 | <a name="l00025"></a>00025 <span class="preprocessor">#include <cstddef></span> | |
58 | <a name="l00026"></a>00026 <span class="preprocessor">#include <iterator></span> | |
59 | <a name="l00027"></a>00027 <span class="preprocessor">#include <boost/iterator/iterator_facade.hpp></span> | |
60 | <a name="l00028"></a>00028 <span class="preprocessor">#include "<a class="code" href="g_i_l_0094.html" title="GIL configuration file.">gil_config.hpp</a>"</span> | |
61 | <a name="l00029"></a>00029 <span class="preprocessor">#include "<a class="code" href="utilities_8hpp.html" title="Various utilities not specific to the image library. Some are non-standard STL extensions...">utilities.hpp</a>"</span> | |
62 | <a name="l00030"></a>00030 <span class="preprocessor">#include "<a class="code" href="g_i_l_0243.html" title="pixel iterator support">pixel_iterator.hpp</a>"</span> | |
63 | <a name="l00031"></a>00031 <span class="preprocessor">#include "<a class="code" href="g_i_l_0245.html" title="pixel step iterator, pixel image iterator and pixel dereference iterator">pixel_iterator_adaptor.hpp</a>"</span> | |
64 | <a name="l00032"></a>00032 | |
65 | <a name="l00033"></a>00033 <span class="keyword">namespace </span>boost { <span class="keyword">namespace </span>gil { | |
66 | <a name="l00034"></a>00034 | |
67 | <a name="l00038"></a>00038 | |
68 | <a name="l00039"></a>00039 | |
69 | <a name="l00040"></a>00040 <span class="keyword">namespace </span>detail { | |
70 | <a name="l00041"></a>00041 | |
71 | <a name="l00048"></a>00048 | |
72 | <a name="l00049"></a>00049 <span class="keyword">template</span> <<span class="keyword">typename</span> Derived, <span class="comment">// type of the derived class</span> | |
73 | <a name="l00050"></a>00050 <span class="keyword">typename</span> Iterator, <span class="comment">// Models Iterator</span> | |
74 | <a name="l00051"></a>00051 <span class="keyword">typename</span> SFn> <span class="comment">// A policy object that can compute the distance between two iterators of type Iterator</span> | |
75 | <a name="l00052"></a>00052 <span class="comment">// and can advance an iterator of type Iterator a given number of Iterator's units </span> | |
76 | <a name="l00053"></a><a class="code" href="g_i_l_0036.html">00053</a> <span class="keyword">class </span><a class="code" href="g_i_l_0036.html" title="An adaptor over an existing iterator that changes the step unit.">step_iterator_adaptor</a> : <span class="keyword">public</span> iterator_adaptor<Derived, Iterator, use_default, use_default, use_default, typename SFn::difference_type> { | |
77 | <a name="l00054"></a>00054 <span class="keyword">public</span>: | |
78 | <a name="l00055"></a>00055 <span class="keyword">typedef</span> iterator_adaptor<Derived, Iterator, use_default, use_default, use_default, typename SFn::difference_type> parent_t; | |
79 | <a name="l00056"></a>00056 <span class="keyword">typedef</span> <span class="keyword">typename</span> std::iterator_traits<Iterator>::difference_type base_difference_type; | |
80 | <a name="l00057"></a>00057 <span class="keyword">typedef</span> <span class="keyword">typename</span> SFn::difference_type difference_type; | |
81 | <a name="l00058"></a>00058 <span class="keyword">typedef</span> <span class="keyword">typename</span> std::iterator_traits<Iterator>::reference reference; | |
82 | <a name="l00059"></a>00059 | |
83 | <a name="l00060"></a>00060 <a class="code" href="g_i_l_0036.html" title="An adaptor over an existing iterator that changes the step unit.">step_iterator_adaptor</a>() {} | |
84 | <a name="l00061"></a>00061 <a class="code" href="g_i_l_0036.html" title="An adaptor over an existing iterator that changes the step unit.">step_iterator_adaptor</a>(<span class="keyword">const</span> Iterator& it, SFn step_fn=SFn()) : parent_t(it), _step_fn(step_fn) {} | |
85 | <a name="l00062"></a>00062 | |
86 | <a name="l00063"></a>00063 difference_type step()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> _step_fn.step(); } | |
87 | <a name="l00064"></a>00064 | |
88 | <a name="l00065"></a>00065 <span class="keyword">protected</span>: | |
89 | <a name="l00066"></a>00066 SFn _step_fn; | |
90 | <a name="l00067"></a>00067 <span class="keyword">private</span>: | |
91 | <a name="l00068"></a>00068 <span class="keyword">friend</span> <span class="keyword">class </span>boost::iterator_core_access; | |
92 | <a name="l00069"></a>00069 | |
93 | <a name="l00070"></a>00070 <span class="keywordtype">void</span> increment() { _step_fn.advance(this->base_reference(),1); } | |
94 | <a name="l00071"></a>00071 <span class="keywordtype">void</span> decrement() { _step_fn.advance(this->base_reference(),-1); } | |
95 | <a name="l00072"></a>00072 <span class="keywordtype">void</span> advance(base_difference_type d) { _step_fn.advance(this->base_reference(),d); } | |
96 | <a name="l00073"></a>00073 difference_type distance_to(<span class="keyword">const</span> <a class="code" href="g_i_l_0036.html" title="An adaptor over an existing iterator that changes the step unit.">step_iterator_adaptor</a>& it)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> _step_fn.difference(this->base_reference(),it.base_reference()); } | |
97 | <a name="l00074"></a>00074 }; | |
98 | <a name="l00075"></a>00075 | |
99 | <a name="l00076"></a>00076 <span class="comment">// although iterator_adaptor defines these, the default implementation computes distance and compares for zero.</span> | |
100 | <a name="l00077"></a>00077 <span class="comment">// it is often faster to just apply the relation operator to the base</span> | |
101 | <a name="l00078"></a>00078 <span class="keyword">template</span> <<span class="keyword">typename</span> D,<span class="keyword">typename</span> Iterator,<span class="keyword">typename</span> SFn> <span class="keyword">inline</span> | |
102 | <a name="l00079"></a>00079 <span class="keywordtype">bool</span> operator>(<span class="keyword">const</span> <a class="code" href="g_i_l_0036.html" title="An adaptor over an existing iterator that changes the step unit.">step_iterator_adaptor<D,Iterator,SFn></a>& p1, <span class="keyword">const</span> <a class="code" href="g_i_l_0036.html" title="An adaptor over an existing iterator that changes the step unit.">step_iterator_adaptor<D,Iterator,SFn></a>& p2) { | |
103 | <a name="l00080"></a>00080 <span class="keywordflow">return</span> p1.<a class="code" href="g_i_l_0036.html#4d9de021528d2fae8de7b71dbc2e3909">step</a>()>0 ? p1.base()> p2.base() : p1.base()< p2.base(); | |
104 | <a name="l00081"></a>00081 } | |
105 | <a name="l00082"></a>00082 | |
106 | <a name="l00083"></a>00083 <span class="keyword">template</span> <<span class="keyword">typename</span> D,<span class="keyword">typename</span> Iterator,<span class="keyword">typename</span> SFn> <span class="keyword">inline</span> | |
107 | <a name="l00084"></a>00084 <span class="keywordtype">bool</span> operator<(const step_iterator_adaptor<D,Iterator,SFn>& p1, <span class="keyword">const</span> step_iterator_adaptor<D,Iterator,SFn>& p2) { | |
108 | <a name="l00085"></a>00085 <span class="keywordflow">return</span> p1.<a class="code" href="g_i_l_0036.html#4d9de021528d2fae8de7b71dbc2e3909">step</a>()>0 ? p1.base()< p2.base() : p1.base()> p2.base(); | |
109 | <a name="l00086"></a>00086 } | |
110 | <a name="l00087"></a>00087 | |
111 | <a name="l00088"></a>00088 <span class="keyword">template</span> <<span class="keyword">typename</span> D,<span class="keyword">typename</span> Iterator,<span class="keyword">typename</span> SFn> <span class="keyword">inline</span> | |
112 | <a name="l00089"></a>00089 <span class="keywordtype">bool</span> operator>=(<span class="keyword">const</span> step_iterator_adaptor<D,Iterator,SFn>& p1, <span class="keyword">const</span> step_iterator_adaptor<D,Iterator,SFn>& p2) { | |
113 | <a name="l00090"></a>00090 <span class="keywordflow">return</span> p1.step()>0 ? p1.base()>=p2.base() : p1.base()<=p2.base(); | |
114 | <a name="l00091"></a>00091 } | |
115 | <a name="l00092"></a>00092 | |
116 | <a name="l00093"></a>00093 <span class="keyword">template</span> <<span class="keyword">typename</span> D,<span class="keyword">typename</span> Iterator,<span class="keyword">typename</span> SFn> <span class="keyword">inline</span> | |
117 | <a name="l00094"></a>00094 <span class="keywordtype">bool</span> operator<=(const step_iterator_adaptor<D,Iterator,SFn>& p1, <span class="keyword">const</span> step_iterator_adaptor<D,Iterator,SFn>& p2) { | |
118 | <a name="l00095"></a>00095 <span class="keywordflow">return</span> p1.step()>0 ? p1.base()<=p2.base() : p1.base()>=p2.base(); | |
119 | <a name="l00096"></a>00096 } | |
120 | <a name="l00097"></a>00097 | |
121 | <a name="l00098"></a>00098 <span class="keyword">template</span> <<span class="keyword">typename</span> D,<span class="keyword">typename</span> Iterator,<span class="keyword">typename</span> SFn> <span class="keyword">inline</span> | |
122 | <a name="l00099"></a>00099 <span class="keywordtype">bool</span> operator==(<span class="keyword">const</span> step_iterator_adaptor<D,Iterator,SFn>& p1, <span class="keyword">const</span> step_iterator_adaptor<D,Iterator,SFn>& p2) { | |
123 | <a name="l00100"></a>00100 <span class="keywordflow">return</span> p1.base()==p2.base(); | |
124 | <a name="l00101"></a>00101 } | |
125 | <a name="l00102"></a>00102 | |
126 | <a name="l00103"></a>00103 <span class="keyword">template</span> <<span class="keyword">typename</span> D,<span class="keyword">typename</span> Iterator,<span class="keyword">typename</span> SFn> <span class="keyword">inline</span> | |
127 | <a name="l00104"></a>00104 <span class="keywordtype">bool</span> operator!=(<span class="keyword">const</span> step_iterator_adaptor<D,Iterator,SFn>& p1, <span class="keyword">const</span> step_iterator_adaptor<D,Iterator,SFn>& p2) { | |
128 | <a name="l00105"></a>00105 <span class="keywordflow">return</span> p1.base()!=p2.base(); | |
129 | <a name="l00106"></a>00106 } | |
130 | <a name="l00107"></a>00107 | |
131 | <a name="l00108"></a>00108 } <span class="comment">// namespace detail</span> | |
132 | <a name="l00109"></a>00109 | |
133 | <a name="l00113"></a>00113 | |
134 | <a name="l00129"></a>00129 | |
135 | <a name="l00132"></a>00132 <span class="keyword">template</span> <<span class="keyword">typename</span> Iterator> | |
136 | <a name="l00133"></a><a class="code" href="g_i_l_0576.html">00133</a> <span class="keyword">struct </span><a class="code" href="g_i_l_0576.html" title="function object that returns the memory unit distance between two iterators and advances...">memunit_step_fn</a> { | |
137 | <a name="l00134"></a>00134 <span class="keyword">typedef</span> std::ptrdiff_t difference_type; | |
138 | <a name="l00135"></a>00135 | |
139 | <a name="l00136"></a>00136 <a class="code" href="g_i_l_0576.html" title="function object that returns the memory unit distance between two iterators and advances...">memunit_step_fn</a>(difference_type step=memunit_step(Iterator())) : _step(step) {} | |
140 | <a name="l00137"></a>00137 | |
141 | <a name="l00138"></a>00138 difference_type difference(<span class="keyword">const</span> Iterator& it1, <span class="keyword">const</span> Iterator& it2)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> memunit_distance(it1,it2)/_step; } | |
142 | <a name="l00139"></a>00139 <span class="keywordtype">void</span> advance(Iterator& it, difference_type d)<span class="keyword"> const </span>{ memunit_advance(it,d*_step); } | |
143 | <a name="l00140"></a>00140 difference_type step()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> _step; } | |
144 | <a name="l00141"></a>00141 | |
145 | <a name="l00142"></a>00142 <span class="keywordtype">void</span> set_step(std::ptrdiff_t step) { _step=step; } | |
146 | <a name="l00143"></a>00143 <span class="keyword">private</span>: | |
147 | <a name="l00144"></a>00144 GIL_CLASS_REQUIRE(Iterator, boost::gil, <a class="code" href="g_i_l_0312.html" title="Concept of a random-access iterator that can be advanced in memory units (bytes or...">MemoryBasedIteratorConcept</a>) | |
148 | <a name="l00145"></a>00145 difference_type _step; | |
149 | <a name="l00146"></a>00146 }; | |
150 | <a name="l00147"></a>00147 | |
151 | <a name="l00148"></a>00148 <span class="keyword">template</span> <<span class="keyword">typename</span> Iterator> | |
152 | <a name="l00149"></a><a class="code" href="g_i_l_0046.html">00149</a> <span class="keyword">class </span><a class="code" href="g_i_l_0046.html" title="Iterator with dynamically specified step in memory units (bytes or bits). Models...">memory_based_step_iterator</a> : <span class="keyword">public</span> detail::step_iterator_adaptor<memory_based_step_iterator<Iterator>, | |
153 | <a name="l00150"></a>00150 Iterator, | |
154 | <a name="l00151"></a>00151 memunit_step_fn<Iterator> > { | |
155 | <a name="l00152"></a>00152 GIL_CLASS_REQUIRE(Iterator, boost::gil, <a class="code" href="g_i_l_0312.html" title="Concept of a random-access iterator that can be advanced in memory units (bytes or...">MemoryBasedIteratorConcept</a>) | |
156 | <a name="l00153"></a>00153 <span class="keyword">public</span>: | |
157 | <a name="l00154"></a>00154 <span class="keyword">typedef</span> <a class="code" href="g_i_l_0036.html" title="An adaptor over an existing iterator that changes the step unit.">detail::step_iterator_adaptor<memory_based_step_iterator<Iterator></a>, | |
158 | <a name="l00155"></a>00155 Iterator, | |
159 | <a name="l00156"></a>00156 <a class="code" href="g_i_l_0576.html" title="function object that returns the memory unit distance between two iterators and advances...">memunit_step_fn<Iterator></a> > parent_t; | |
160 | <a name="l00157"></a>00157 <span class="keyword">typedef</span> <span class="keyword">typename</span> parent_t::reference reference; | |
161 | <a name="l00158"></a>00158 <span class="keyword">typedef</span> <span class="keyword">typename</span> parent_t::difference_type difference_type; | |
162 | <a name="l00159"></a>00159 <span class="keyword">typedef</span> Iterator x_iterator; | |
163 | <a name="l00160"></a>00160 | |
164 | <a name="l00161"></a>00161 <a class="code" href="g_i_l_0046.html" title="Iterator with dynamically specified step in memory units (bytes or bits). Models...">memory_based_step_iterator</a>() : parent_t(Iterator()) {} | |
165 | <a name="l00162"></a>00162 <a class="code" href="g_i_l_0046.html" title="Iterator with dynamically specified step in memory units (bytes or bits). Models...">memory_based_step_iterator</a>(Iterator it, std::ptrdiff_t memunit_step) : parent_t(it, <a class="code" href="g_i_l_0576.html" title="function object that returns the memory unit distance between two iterators and advances...">memunit_step_fn<Iterator></a>(memunit_step)) {} | |
166 | <a name="l00163"></a>00163 <span class="keyword">template</span> <<span class="keyword">typename</span> I2> | |
167 | <a name="l00164"></a>00164 <a class="code" href="g_i_l_0046.html" title="Iterator with dynamically specified step in memory units (bytes or bits). Models...">memory_based_step_iterator</a>(<span class="keyword">const</span> <a class="code" href="g_i_l_0046.html" title="Iterator with dynamically specified step in memory units (bytes or bits). Models...">memory_based_step_iterator<I2></a>& it) | |
168 | <a name="l00165"></a>00165 : parent_t(it.<a class="code" href="g_i_l_0046.html#2d6722b54419923ecb1282a142fcd494">base</a>(), <a class="code" href="g_i_l_0576.html" title="function object that returns the memory unit distance between two iterators and advances...">memunit_step_fn<Iterator></a>(it.<a class="code" href="g_i_l_0036.html#4d9de021528d2fae8de7b71dbc2e3909">step</a>())) {} | |
169 | <a name="l00166"></a>00166 | |
170 | <a name="l00169"></a><a class="code" href="g_i_l_0046.html#de1279c4ed222b6efb0867c038765ea1">00169</a> reference <a class="code" href="g_i_l_0046.html#de1279c4ed222b6efb0867c038765ea1">operator[]</a>(difference_type d)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> *(*<span class="keyword">this</span>+d); } | |
171 | <a name="l00170"></a>00170 | |
172 | <a name="l00171"></a>00171 <span class="keywordtype">void</span> set_step(std::ptrdiff_t memunit_step) { this->_step_fn.set_step(memunit_step); } | |
173 | <a name="l00172"></a>00172 | |
174 | <a name="l00173"></a>00173 x_iterator& base() { <span class="keywordflow">return</span> parent_t::base_reference(); } | |
175 | <a name="l00174"></a>00174 x_iterator <span class="keyword">const</span>& base()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> parent_t::base_reference(); } | |
176 | <a name="l00175"></a>00175 }; | |
177 | <a name="l00176"></a>00176 | |
178 | <a name="l00177"></a>00177 <span class="keyword">template</span> <<span class="keyword">typename</span> Iterator> | |
179 | <a name="l00178"></a>00178 <span class="keyword">struct </span>const_iterator_type<memory_based_step_iterator<Iterator> > { | |
180 | <a name="l00179"></a>00179 <span class="keyword">typedef</span> memory_based_step_iterator<typename const_iterator_type<Iterator>::type> type; | |
181 | <a name="l00180"></a>00180 }; | |
182 | <a name="l00181"></a>00181 | |
183 | <a name="l00182"></a>00182 <span class="keyword">template</span> <<span class="keyword">typename</span> Iterator> | |
184 | <a name="l00183"></a>00183 <span class="keyword">struct </span>iterator_is_mutable<memory_based_step_iterator<Iterator> > : <span class="keyword">public</span> iterator_is_mutable<Iterator> {}; | |
185 | <a name="l00184"></a>00184 | |
186 | <a name="l00185"></a>00185 | |
187 | <a name="l00187"></a>00187 <span class="comment">// IteratorAdaptorConcept</span> | |
188 | <a name="l00189"></a>00189 <span class="comment"></span> | |
189 | <a name="l00190"></a>00190 <span class="keyword">template</span> <<span class="keyword">typename</span> Iterator> | |
190 | <a name="l00191"></a>00191 <span class="keyword">struct </span>is_iterator_adaptor<memory_based_step_iterator<Iterator> > : <span class="keyword">public</span> mpl::true_{}; | |
191 | <a name="l00192"></a>00192 | |
192 | <a name="l00193"></a>00193 <span class="keyword">template</span> <<span class="keyword">typename</span> Iterator> | |
193 | <a name="l00194"></a>00194 <span class="keyword">struct </span>iterator_adaptor_get_base<memory_based_step_iterator<Iterator> > { | |
194 | <a name="l00195"></a>00195 <span class="keyword">typedef</span> Iterator type; | |
195 | <a name="l00196"></a>00196 }; | |
196 | <a name="l00197"></a>00197 | |
197 | <a name="l00198"></a>00198 <span class="keyword">template</span> <<span class="keyword">typename</span> Iterator, <span class="keyword">typename</span> NewBaseIterator> | |
198 | <a name="l00199"></a>00199 <span class="keyword">struct </span>iterator_adaptor_rebind<memory_based_step_iterator<Iterator>,NewBaseIterator> { | |
199 | <a name="l00200"></a>00200 <span class="keyword">typedef</span> memory_based_step_iterator<NewBaseIterator> type; | |
200 | <a name="l00201"></a>00201 }; | |
201 | <a name="l00202"></a>00202 | |
202 | <a name="l00204"></a>00204 <span class="comment">// PixelBasedConcept</span> | |
203 | <a name="l00206"></a>00206 <span class="comment"></span> | |
204 | <a name="l00207"></a>00207 <span class="keyword">template</span> <<span class="keyword">typename</span> Iterator> | |
205 | <a name="l00208"></a>00208 <span class="keyword">struct </span>color_space_type<memory_based_step_iterator<Iterator> > : <span class="keyword">public</span> color_space_type<Iterator> {}; | |
206 | <a name="l00209"></a>00209 | |
207 | <a name="l00210"></a>00210 <span class="keyword">template</span> <<span class="keyword">typename</span> Iterator> | |
208 | <a name="l00211"></a>00211 <span class="keyword">struct </span>channel_mapping_type<memory_based_step_iterator<Iterator> > : <span class="keyword">public</span> channel_mapping_type<Iterator> {}; | |
209 | <a name="l00212"></a>00212 | |
210 | <a name="l00213"></a>00213 <span class="keyword">template</span> <<span class="keyword">typename</span> Iterator> | |
211 | <a name="l00214"></a>00214 <span class="keyword">struct </span>is_planar<memory_based_step_iterator<Iterator> > : <span class="keyword">public</span> is_planar<Iterator> {}; | |
212 | <a name="l00215"></a>00215 | |
213 | <a name="l00216"></a>00216 <span class="keyword">template</span> <<span class="keyword">typename</span> Iterator> | |
214 | <a name="l00217"></a>00217 <span class="keyword">struct </span>channel_type<memory_based_step_iterator<Iterator> > : <span class="keyword">public</span> channel_type<Iterator> {}; | |
215 | <a name="l00218"></a>00218 | |
216 | <a name="l00220"></a>00220 <span class="comment">// MemoryBasedIteratorConcept</span> | |
217 | <a name="l00222"></a>00222 <span class="comment"></span><span class="keyword">template</span> <<span class="keyword">typename</span> Iterator> | |
218 | <a name="l00223"></a>00223 <span class="keyword">struct </span>byte_to_memunit<memory_based_step_iterator<Iterator> > : <span class="keyword">public</span> byte_to_memunit<Iterator> {}; | |
219 | <a name="l00224"></a>00224 | |
220 | <a name="l00225"></a>00225 <span class="keyword">template</span> <<span class="keyword">typename</span> Iterator> | |
221 | <a name="l00226"></a>00226 <span class="keyword">inline</span> std::ptrdiff_t memunit_step(<span class="keyword">const</span> memory_based_step_iterator<Iterator>& p) { <span class="keywordflow">return</span> p.step(); } | |
222 | <a name="l00227"></a>00227 | |
223 | <a name="l00228"></a>00228 <span class="keyword">template</span> <<span class="keyword">typename</span> Iterator> | |
224 | <a name="l00229"></a>00229 <span class="keyword">inline</span> std::ptrdiff_t memunit_distance(<span class="keyword">const</span> memory_based_step_iterator<Iterator>& p1, | |
225 | <a name="l00230"></a>00230 <span class="keyword">const</span> memory_based_step_iterator<Iterator>& p2) { | |
226 | <a name="l00231"></a>00231 <span class="keywordflow">return</span> memunit_distance(p1.base(),p2.base()); | |
227 | <a name="l00232"></a>00232 } | |
228 | <a name="l00233"></a>00233 | |
229 | <a name="l00234"></a>00234 <span class="keyword">template</span> <<span class="keyword">typename</span> Iterator> | |
230 | <a name="l00235"></a>00235 <span class="keyword">inline</span> <span class="keywordtype">void</span> memunit_advance(memory_based_step_iterator<Iterator>& p, | |
231 | <a name="l00236"></a>00236 std::ptrdiff_t diff) { | |
232 | <a name="l00237"></a>00237 memunit_advance(p.base(), diff); | |
233 | <a name="l00238"></a>00238 } | |
234 | <a name="l00239"></a>00239 | |
235 | <a name="l00240"></a>00240 <span class="keyword">template</span> <<span class="keyword">typename</span> Iterator> | |
236 | <a name="l00241"></a>00241 <span class="keyword">inline</span> memory_based_step_iterator<Iterator> | |
237 | <a name="l00242"></a>00242 memunit_advanced(<span class="keyword">const</span> memory_based_step_iterator<Iterator>& p, | |
238 | <a name="l00243"></a>00243 std::ptrdiff_t diff) { | |
239 | <a name="l00244"></a>00244 <span class="keywordflow">return</span> memory_based_step_iterator<Iterator>(memunit_advanced(p.base(), diff),p.step()); | |
240 | <a name="l00245"></a>00245 } | |
241 | <a name="l00246"></a>00246 | |
242 | <a name="l00247"></a>00247 <span class="keyword">template</span> <<span class="keyword">typename</span> Iterator> | |
243 | <a name="l00248"></a>00248 <span class="keyword">inline</span> <span class="keyword">typename</span> std::iterator_traits<Iterator>::reference | |
244 | <a name="l00249"></a>00249 memunit_advanced_ref(<span class="keyword">const</span> memory_based_step_iterator<Iterator>& p, | |
245 | <a name="l00250"></a>00250 std::ptrdiff_t diff) { | |
246 | <a name="l00251"></a>00251 <span class="keywordflow">return</span> memunit_advanced_ref(p.base(), diff); | |
247 | <a name="l00252"></a>00252 } | |
248 | <a name="l00253"></a>00253 | |
249 | <a name="l00255"></a>00255 <span class="comment">// HasDynamicXStepTypeConcept</span> | |
250 | <a name="l00257"></a>00257 <span class="comment"></span> | |
251 | <a name="l00258"></a>00258 <span class="keyword">template</span> <<span class="keyword">typename</span> Iterator> | |
252 | <a name="l00259"></a>00259 <span class="keyword">struct </span>dynamic_x_step_type<memory_based_step_iterator<Iterator> > { | |
253 | <a name="l00260"></a>00260 <span class="keyword">typedef</span> memory_based_step_iterator<Iterator> type; | |
254 | <a name="l00261"></a>00261 }; | |
255 | <a name="l00262"></a>00262 | |
256 | <a name="l00263"></a>00263 <span class="comment">// For step iterators, pass the function object to the base</span> | |
257 | <a name="l00264"></a>00264 <span class="keyword">template</span> <<span class="keyword">typename</span> Iterator, <span class="keyword">typename</span> Deref> | |
258 | <a name="l00265"></a>00265 <span class="keyword">struct </span>iterator_add_deref<memory_based_step_iterator<Iterator>,Deref> { | |
259 | <a name="l00266"></a>00266 GIL_CLASS_REQUIRE(Deref, boost::gil, PixelDereferenceAdaptorConcept) | |
260 | <a name="l00267"></a>00267 | |
261 | <a name="l00268"></a>00268 typedef memory_based_step_iterator<typename iterator_add_deref<Iterator, Deref>::type> type; | |
262 | <a name="l00269"></a>00269 | |
263 | <a name="l00270"></a>00270 static type make(const memory_based_step_iterator<Iterator>& it, const Deref& d) { <span class="keywordflow">return</span> type(iterator_add_deref<Iterator, Deref>::make(it.base(),d),it.step()); } | |
264 | <a name="l00271"></a>00271 }; | |
265 | <a name="l00272"></a>00272 | |
266 | <a name="l00276"></a>00276 | |
267 | <a name="l00277"></a>00277 <span class="keyword">template</span> <<span class="keyword">typename</span> I> <span class="keyword">typename</span> dynamic_x_step_type<I>::type make_step_iterator(<span class="keyword">const</span> I& it, std::ptrdiff_t step); | |
268 | <a name="l00278"></a>00278 | |
269 | <a name="l00279"></a>00279 <span class="keyword">namespace </span>detail { | |
270 | <a name="l00280"></a>00280 | |
271 | <a name="l00281"></a>00281 <span class="comment">// if the iterator is a plain base iterator (non-adaptor), wraps it in memory_based_step_iterator</span> | |
272 | <a name="l00282"></a>00282 <span class="keyword">template</span> <<span class="keyword">typename</span> I> | |
273 | <a name="l00283"></a>00283 <span class="keyword">typename</span> dynamic_x_step_type<I>::type make_step_iterator_impl(<span class="keyword">const</span> I& it, std::ptrdiff_t step, mpl::false_) { | |
274 | <a name="l00284"></a>00284 <span class="keywordflow">return</span> memory_based_step_iterator<I>(it, step); | |
275 | <a name="l00285"></a>00285 } | |
276 | <a name="l00286"></a>00286 | |
277 | <a name="l00287"></a>00287 <span class="comment">// If the iterator is compound, put the step in its base</span> | |
278 | <a name="l00288"></a>00288 <span class="keyword">template</span> <<span class="keyword">typename</span> I> | |
279 | <a name="l00289"></a>00289 <span class="keyword">typename</span> dynamic_x_step_type<I>::type make_step_iterator_impl(<span class="keyword">const</span> I& it, std::ptrdiff_t step, mpl::true_) { | |
280 | <a name="l00290"></a>00290 <span class="keywordflow">return</span> make_step_iterator(it.base(), step); | |
281 | <a name="l00291"></a>00291 } | |
282 | <a name="l00292"></a>00292 | |
283 | <a name="l00293"></a>00293 <span class="comment">// If the iterator is memory_based_step_iterator, change the step</span> | |
284 | <a name="l00294"></a>00294 <span class="keyword">template</span> <<span class="keyword">typename</span> BaseIt> | |
285 | <a name="l00295"></a>00295 memory_based_step_iterator<BaseIt> make_step_iterator_impl(<span class="keyword">const</span> memory_based_step_iterator<BaseIt>& it, std::ptrdiff_t step, mpl::true_) { | |
286 | <a name="l00296"></a>00296 <span class="keywordflow">return</span> memory_based_step_iterator<BaseIt>(it.base(), step); | |
287 | <a name="l00297"></a>00297 } | |
288 | <a name="l00298"></a>00298 } | |
289 | <a name="l00299"></a>00299 | |
290 | <a name="l00313"></a>00313 <span class="keyword">template</span> <<span class="keyword">typename</span> I> <span class="comment">// Models MemoryBasedIteratorConcept, HasDynamicXStepTypeConcept</span> | |
291 | <a name="l00314"></a>00314 <span class="keyword">typename</span> dynamic_x_step_type<I>::type make_step_iterator(<span class="keyword">const</span> I& it, std::ptrdiff_t step) { | |
292 | <a name="l00315"></a>00315 <span class="keywordflow">return</span> detail::make_step_iterator_impl(it, step, <span class="keyword">typename</span> is_iterator_adaptor<I>::type()); | |
293 | <a name="l00316"></a>00316 } | |
294 | <a name="l00317"></a>00317 | |
295 | <a name="l00318"></a>00318 } } <span class="comment">// namespace boost::gil</span> | |
296 | <a name="l00319"></a>00319 | |
297 | <a name="l00320"></a>00320 <span class="preprocessor">#endif</span> | |
298 | </pre></div></div> | |
299 | <hr size="1"><address style="text-align: right;"><small>Generated on Sat May 2 13:50:15 2009 for Generic Image Library by | |
300 | <a href="http://www.doxygen.org/index.html"> | |
301 | <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.6 </small></address> | |
302 | </body> | |
303 | </html> |