]>
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: position_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>position_iterator.hpp</h1><a href="g_i_l_0256.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_POSITION_ITERATOR_HPP</span> | |
54 | <a name="l00014"></a>00014 <span class="preprocessor"></span><span class="preprocessor">#define GIL_POSITION_ITERATOR_HPP</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 <boost/iterator/iterator_facade.hpp></span> | |
58 | <a name="l00026"></a>00026 <span class="preprocessor">#include "<a class="code" href="locator_8hpp.html" title="pixel 2D locator">locator.hpp</a>"</span> | |
59 | <a name="l00027"></a>00027 | |
60 | <a name="l00028"></a>00028 <span class="keyword">namespace </span>boost { <span class="keyword">namespace </span>gil { | |
61 | <a name="l00029"></a>00029 | |
62 | <a name="l00033"></a>00033 | |
63 | <a name="l00034"></a>00034 | |
64 | <a name="l00038"></a>00038 <span class="keyword">template</span> <<span class="keyword">typename</span> Deref, <span class="comment">// A function object that given a point returns a pixel reference. Models PixelDereferenceAdaptorConcept</span> | |
65 | <a name="l00039"></a>00039 <span class="keywordtype">int</span> Dim> <span class="comment">// the dimension to advance along</span> | |
66 | <a name="l00040"></a><a class="code" href="g_i_l_0617.html">00040</a> <span class="keyword">struct </span><a class="code" href="g_i_l_0617.html" title="An iterator that remembers its current X,Y position and invokes a function object...">position_iterator</a> : <span class="keyword">public</span> iterator_facade<position_iterator<Deref,Dim>, | |
67 | <a name="l00041"></a>00041 typename Deref::value_type, | |
68 | <a name="l00042"></a>00042 random_access_traversal_tag, | |
69 | <a name="l00043"></a>00043 typename Deref::reference, | |
70 | <a name="l00044"></a>00044 typename Deref::argument_type::template axis<Dim>::coord_t> { | |
71 | <a name="l00045"></a>00045 <span class="keyword">typedef</span> iterator_facade<position_iterator<Deref,Dim>, | |
72 | <a name="l00046"></a>00046 <span class="keyword">typename</span> Deref::value_type, | |
73 | <a name="l00047"></a>00047 random_access_traversal_tag, | |
74 | <a name="l00048"></a>00048 <span class="keyword">typename</span> Deref::reference, | |
75 | <a name="l00049"></a>00049 <span class="keyword">typename</span> Deref::argument_type::template axis<Dim>::coord_t> parent_t; | |
76 | <a name="l00050"></a>00050 <span class="keyword">typedef</span> <span class="keyword">typename</span> parent_t::difference_type difference_type; | |
77 | <a name="l00051"></a>00051 <span class="keyword">typedef</span> <span class="keyword">typename</span> parent_t::reference reference; | |
78 | <a name="l00052"></a>00052 <span class="keyword">typedef</span> <span class="keyword">typename</span> Deref::argument_type point_t; | |
79 | <a name="l00053"></a>00053 | |
80 | <a name="l00054"></a>00054 <a class="code" href="g_i_l_0617.html" title="An iterator that remembers its current X,Y position and invokes a function object...">position_iterator</a>() {} | |
81 | <a name="l00055"></a>00055 <a class="code" href="g_i_l_0617.html" title="An iterator that remembers its current X,Y position and invokes a function object...">position_iterator</a>(<span class="keyword">const</span> point_t& p, <span class="keyword">const</span> point_t& step, <span class="keyword">const</span> Deref& d) : _p(p), _step(step), _d(d) {} | |
82 | <a name="l00056"></a>00056 | |
83 | <a name="l00057"></a>00057 <a class="code" href="g_i_l_0617.html" title="An iterator that remembers its current X,Y position and invokes a function object...">position_iterator</a>(<span class="keyword">const</span> <a class="code" href="g_i_l_0617.html" title="An iterator that remembers its current X,Y position and invokes a function object...">position_iterator</a>& p) : _p(p.<a class="code" href="g_i_l_0617.html#971ddac6cfb72e0fb2233e50cc9e6e96">_p</a>), _step(p.<a class="code" href="g_i_l_0617.html#40c6b4f9743aad63f61973def7e31dc0">_step</a>), _d(p.<a class="code" href="g_i_l_0617.html#ce274a09c4eaceac7270c9fe5adff51a">_d</a>) {} | |
84 | <a name="l00058"></a>00058 <span class="keyword">template</span> <<span class="keyword">typename</span> D> <a class="code" href="g_i_l_0617.html" title="An iterator that remembers its current X,Y position and invokes a function object...">position_iterator</a>(<span class="keyword">const</span> <a class="code" href="g_i_l_0617.html" title="An iterator that remembers its current X,Y position and invokes a function object...">position_iterator<D,Dim></a>& p) : _p(p.<a class="code" href="g_i_l_0617.html#971ddac6cfb72e0fb2233e50cc9e6e96">_p</a>), _step(p.<a class="code" href="g_i_l_0617.html#40c6b4f9743aad63f61973def7e31dc0">_step</a>), _d(p.<a class="code" href="g_i_l_0617.html#ce274a09c4eaceac7270c9fe5adff51a">_d</a>) {} | |
85 | <a name="l00059"></a>00059 <a class="code" href="g_i_l_0617.html" title="An iterator that remembers its current X,Y position and invokes a function object...">position_iterator</a>& operator=(<span class="keyword">const</span> <a class="code" href="g_i_l_0617.html" title="An iterator that remembers its current X,Y position and invokes a function object...">position_iterator</a>& p) { _p=p.<a class="code" href="g_i_l_0617.html#971ddac6cfb72e0fb2233e50cc9e6e96">_p</a>; _d=p.<a class="code" href="g_i_l_0617.html#ce274a09c4eaceac7270c9fe5adff51a">_d</a>; _step=p.<a class="code" href="g_i_l_0617.html#40c6b4f9743aad63f61973def7e31dc0">_step</a>; <span class="keywordflow">return</span> *<span class="keyword">this</span>; } | |
86 | <a name="l00060"></a>00060 | |
87 | <a name="l00061"></a>00061 <span class="keyword">const</span> point_t& pos()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> _p; } | |
88 | <a name="l00062"></a>00062 <span class="keyword">const</span> point_t& step()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> _step; } | |
89 | <a name="l00063"></a>00063 <span class="keyword">const</span> Deref& deref_fn()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> _d; } | |
90 | <a name="l00064"></a>00064 | |
91 | <a name="l00065"></a>00065 <span class="keywordtype">void</span> set_step(difference_type s) { _step[Dim]=s; } | |
92 | <a name="l00068"></a><a class="code" href="g_i_l_0617.html#de1279c4ed222b6efb0867c038765ea1">00068</a> reference <a class="code" href="g_i_l_0617.html#de1279c4ed222b6efb0867c038765ea1">operator[]</a>(difference_type d)<span class="keyword"> const </span>{ point_t p=_p; p[Dim]+=d*_step[Dim]; <span class="keywordflow">return</span> _d(p); } | |
93 | <a name="l00069"></a>00069 | |
94 | <a name="l00070"></a>00070 <span class="keyword">private</span>: | |
95 | <a name="l00071"></a>00071 point_t _p, _step; | |
96 | <a name="l00072"></a>00072 Deref _d; | |
97 | <a name="l00073"></a>00073 | |
98 | <a name="l00074"></a>00074 <span class="keyword">template</span> <<span class="keyword">typename</span> DE, <span class="keywordtype">int</span> DI> <span class="keyword">friend</span> <span class="keyword">struct </span><a class="code" href="g_i_l_0617.html" title="An iterator that remembers its current X,Y position and invokes a function object...">position_iterator</a>; | |
99 | <a name="l00075"></a>00075 <span class="keyword">friend</span> <span class="keyword">class </span>boost::iterator_core_access; | |
100 | <a name="l00076"></a>00076 reference dereference()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> _d(_p); } | |
101 | <a name="l00077"></a>00077 <span class="keywordtype">void</span> increment() { _p[Dim]+=_step[Dim]; } | |
102 | <a name="l00078"></a>00078 <span class="keywordtype">void</span> decrement() { _p[Dim]-=_step[Dim]; } | |
103 | <a name="l00079"></a>00079 <span class="keywordtype">void</span> advance(difference_type d) { _p[Dim]+=d*_step[Dim]; } | |
104 | <a name="l00080"></a>00080 | |
105 | <a name="l00081"></a>00081 difference_type distance_to(<span class="keyword">const</span> position_iterator& it)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> (it._p[Dim]-_p[Dim])/_step[Dim]; } | |
106 | <a name="l00082"></a>00082 <span class="keywordtype">bool</span> <a class="code" href="g_i_l_0214.html#g4ed3cf71cb0fbf435d1389df8567a4e5" title="std::equal(I1,I1,I2) with I1 and I2 being a iterator_from_2d">equal</a>(<span class="keyword">const</span> position_iterator& it)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> _p==it._p; } | |
107 | <a name="l00083"></a>00083 }; | |
108 | <a name="l00084"></a>00084 | |
109 | <a name="l00085"></a>00085 <span class="keyword">template</span> <<span class="keyword">typename</span> Deref,<span class="keywordtype">int</span> Dim> | |
110 | <a name="l00086"></a>00086 <span class="keyword">struct </span>const_iterator_type<position_iterator<Deref,Dim> > { | |
111 | <a name="l00087"></a>00087 <span class="keyword">typedef</span> position_iterator<typename Deref::const_t,Dim> type; | |
112 | <a name="l00088"></a>00088 }; | |
113 | <a name="l00089"></a>00089 | |
114 | <a name="l00090"></a>00090 <span class="keyword">template</span> <<span class="keyword">typename</span> Deref,<span class="keywordtype">int</span> Dim> | |
115 | <a name="l00091"></a>00091 <span class="keyword">struct </span>iterator_is_mutable<position_iterator<Deref,Dim> > : <span class="keyword">public</span> mpl::bool_<Deref::is_mutable> { | |
116 | <a name="l00092"></a>00092 }; | |
117 | <a name="l00093"></a>00093 | |
118 | <a name="l00095"></a>00095 <span class="comment">// PixelBasedConcept</span> | |
119 | <a name="l00097"></a>00097 <span class="comment"></span> | |
120 | <a name="l00098"></a>00098 <span class="keyword">template</span> <<span class="keyword">typename</span> Deref,<span class="keywordtype">int</span> Dim> | |
121 | <a name="l00099"></a>00099 <span class="keyword">struct </span>color_space_type<position_iterator<Deref,Dim> > : <span class="keyword">public</span> color_space_type<typename Deref::value_type> {}; | |
122 | <a name="l00100"></a>00100 | |
123 | <a name="l00101"></a>00101 <span class="keyword">template</span> <<span class="keyword">typename</span> Deref,<span class="keywordtype">int</span> Dim> | |
124 | <a name="l00102"></a>00102 <span class="keyword">struct </span>channel_mapping_type<position_iterator<Deref,Dim> > : <span class="keyword">public</span> channel_mapping_type<typename Deref::value_type> {}; | |
125 | <a name="l00103"></a>00103 | |
126 | <a name="l00104"></a>00104 <span class="keyword">template</span> <<span class="keyword">typename</span> Deref,<span class="keywordtype">int</span> Dim> | |
127 | <a name="l00105"></a>00105 <span class="keyword">struct </span>is_planar<position_iterator<Deref,Dim> > : <span class="keyword">public</span> mpl::false_ {}; | |
128 | <a name="l00106"></a>00106 | |
129 | <a name="l00107"></a>00107 <span class="keyword">template</span> <<span class="keyword">typename</span> Deref,<span class="keywordtype">int</span> Dim> | |
130 | <a name="l00108"></a>00108 <span class="keyword">struct </span>channel_type<position_iterator<Deref,Dim> > : <span class="keyword">public</span> channel_type<typename Deref::value_type> {}; | |
131 | <a name="l00109"></a>00109 | |
132 | <a name="l00111"></a>00111 <span class="comment">// HasDynamicXStepTypeConcept</span> | |
133 | <a name="l00113"></a>00113 <span class="comment"></span> | |
134 | <a name="l00114"></a>00114 <span class="keyword">template</span> <<span class="keyword">typename</span> Deref,<span class="keywordtype">int</span> Dim> | |
135 | <a name="l00115"></a>00115 <span class="keyword">struct </span>dynamic_x_step_type<position_iterator<Deref,Dim> > { | |
136 | <a name="l00116"></a>00116 <span class="keyword">typedef</span> position_iterator<Deref,Dim> type; | |
137 | <a name="l00117"></a>00117 }; | |
138 | <a name="l00118"></a>00118 | |
139 | <a name="l00119"></a>00119 } } <span class="comment">// namespace boost::gil</span> | |
140 | <a name="l00120"></a>00120 | |
141 | <a name="l00121"></a>00121 <span class="preprocessor">#endif</span> | |
142 | </pre></div></div> | |
143 | <hr size="1"><address style="text-align: right;"><small>Generated on Sat May 2 13:50:15 2009 for Generic Image Library by | |
144 | <a href="http://www.doxygen.org/index.html"> | |
145 | <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.6 </small></address> | |
146 | </body> | |
147 | </html> |