]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/gil/doc/html/g_i_l_0007.html
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / gil / doc / html / g_i_l_0007.html
CommitLineData
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: apply_operation_base.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>&nbsp;&raquo&nbsp;<a class="el" href="g_i_l_0079.html">gil</a>&nbsp;&raquo&nbsp;<a class="el" href="g_i_l_0078.html">extension</a>&nbsp;&raquo&nbsp;<a class="el" href="g_i_l_0075.html">dynamic_image</a>
39 </div>
40<div class="contents">
41<h1>apply_operation_base.hpp</h1><a href="g_i_l_0008.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_APPLY_OPERATION_BASE_HPP</span>
54<a name="l00014"></a>00014 <span class="preprocessor"></span><span class="preprocessor">#define GIL_APPLY_OPERATION_BASE_HPP</span>
55<a name="l00015"></a>00015 <span class="preprocessor"></span>
56<a name="l00016"></a>00016 <span class="preprocessor">#include "../../gil_config.hpp"</span>
57<a name="l00017"></a>00017 <span class="preprocessor">#include "../../utilities.hpp"</span>
58<a name="l00018"></a>00018 <span class="preprocessor">#include &lt;boost/mpl/begin.hpp&gt;</span>
59<a name="l00019"></a>00019 <span class="preprocessor">#include &lt;boost/mpl/next.hpp&gt;</span>
60<a name="l00020"></a>00020 <span class="preprocessor">#include &lt;boost/mpl/deref.hpp&gt;</span>
61<a name="l00021"></a>00021 <span class="preprocessor">#include &lt;boost/mpl/size.hpp&gt;</span>
62<a name="l00022"></a>00022 <span class="preprocessor">#include &lt;boost/preprocessor/repeat.hpp&gt;</span>
63<a name="l00023"></a>00023
64<a name="l00033"></a>00033
65<a name="l00034"></a>00034 <span class="keyword">namespace </span>boost { <span class="keyword">namespace </span>gil {
66<a name="l00035"></a>00035
67<a name="l00036"></a>00036 <span class="comment">/*</span>
68<a name="l00037"></a>00037 <span class="comment">GENERATE_APPLY_FWD_OPS generates for every N functions that look like this (for N==2):</span>
69<a name="l00038"></a>00038 <span class="comment"></span>
70<a name="l00039"></a>00039 <span class="comment"> template &lt;&gt; struct apply_operation_fwd_fn&lt;3&gt; {</span>
71<a name="l00040"></a>00040 <span class="comment"> template &lt;typename Types, typename Bits, typename UnaryOp&gt;</span>
72<a name="l00041"></a>00041 <span class="comment"> typename UnaryOp::result_type apply(Bits&amp; bits, std::size_t index, UnaryOp op) const {</span>
73<a name="l00042"></a>00042 <span class="comment"> typedef typename mpl::begin&lt;Types&gt;::type T0;</span>
74<a name="l00043"></a>00043 <span class="comment"> typedef typename mpl::next&lt;T0&gt;::type T1;</span>
75<a name="l00044"></a>00044 <span class="comment"> typedef typename mpl::next&lt;T1&gt;::type T2;</span>
76<a name="l00045"></a>00045 <span class="comment"> switch (index) {</span>
77<a name="l00046"></a>00046 <span class="comment"> case 0: return op(reinterpret_cast&lt;typename mpl::deref&lt;T0&gt;::type&amp;&gt;(bits));</span>
78<a name="l00047"></a>00047 <span class="comment"> case 1: return op(reinterpret_cast&lt;typename mpl::deref&lt;T1&gt;::type&amp;&gt;(bits));</span>
79<a name="l00048"></a>00048 <span class="comment"> case 2: return op(reinterpret_cast&lt;typename mpl::deref&lt;T2&gt;::type&amp;&gt;(bits));</span>
80<a name="l00049"></a>00049 <span class="comment"> }</span>
81<a name="l00050"></a>00050 <span class="comment"> throw;</span>
82<a name="l00051"></a>00051 <span class="comment"> }</span>
83<a name="l00052"></a>00052 <span class="comment"></span>
84<a name="l00053"></a>00053 <span class="comment"> template &lt;typename Types, typename Bits, typename UnaryOp&gt;</span>
85<a name="l00054"></a>00054 <span class="comment"> typename UnaryOp::result_type applyc(const Bits&amp; bits, std::size_t index, UnaryOp op) const {</span>
86<a name="l00055"></a>00055 <span class="comment"> typedef typename mpl::begin&lt;Types&gt;::type T0;</span>
87<a name="l00056"></a>00056 <span class="comment"> typedef typename mpl::next&lt;T0&gt;::type T1;</span>
88<a name="l00057"></a>00057 <span class="comment"> typedef typename mpl::next&lt;T1&gt;::type T2;</span>
89<a name="l00058"></a>00058 <span class="comment"> switch (index) {</span>
90<a name="l00059"></a>00059 <span class="comment"> case 0: return op(reinterpret_cast&lt;const typename mpl::deref&lt;T0&gt;::type&amp;&gt;(bits));</span>
91<a name="l00060"></a>00060 <span class="comment"> case 1: return op(reinterpret_cast&lt;const typename mpl::deref&lt;T1&gt;::type&amp;&gt;(bits));</span>
92<a name="l00061"></a>00061 <span class="comment"> case 2: return op(reinterpret_cast&lt;const typename mpl::deref&lt;T2&gt;::type&amp;&gt;(bits));</span>
93<a name="l00062"></a>00062 <span class="comment"> }</span>
94<a name="l00063"></a>00063 <span class="comment"> throw;</span>
95<a name="l00064"></a>00064 <span class="comment"> }</span>
96<a name="l00065"></a>00065 <span class="comment"> };</span>
97<a name="l00066"></a>00066 <span class="comment">*/</span>
98<a name="l00067"></a>00067
99<a name="l00068"></a>00068 <span class="preprocessor">#define GIL_FWD_TYPEDEFS(z, N, text) T##N; typedef typename mpl::next&lt;T##N&gt;::type </span>
100<a name="l00069"></a>00069 <span class="preprocessor"></span><span class="preprocessor">#define GIL_FWD_CASE(z, N, SUM) case N: return op(*gil_reinterpret_cast&lt;typename mpl::deref&lt;T##N&gt;::type*&gt;(&amp;bits));</span>
101<a name="l00070"></a>00070 <span class="preprocessor"></span><span class="preprocessor">#define GIL_FWD_CONST_CASE(z, N, SUM) case N: return op(*gil_reinterpret_cast_c&lt;const typename mpl::deref&lt;T##N&gt;::type*&gt;(&amp;bits));</span>
102<a name="l00071"></a>00071 <span class="preprocessor"></span>
103<a name="l00072"></a>00072 <span class="preprocessor">#define GIL_APPLY_FWD_OP(z, N, text) \</span>
104<a name="l00073"></a>00073 <span class="preprocessor"> template &lt;&gt; struct apply_operation_fwd_fn&lt;BOOST_PP_ADD(N,1)&gt; { \</span>
105<a name="l00074"></a>00074 <span class="preprocessor"> template &lt;typename Types, typename Bits, typename UnaryOp&gt; \</span>
106<a name="l00075"></a>00075 <span class="preprocessor"> typename UnaryOp::result_type apply(Bits&amp; bits, std::size_t index, UnaryOp op) const { \</span>
107<a name="l00076"></a>00076 <span class="preprocessor"> typedef typename mpl::begin&lt;Types&gt;::type \</span>
108<a name="l00077"></a>00077 <span class="preprocessor"> BOOST_PP_REPEAT(N, GIL_FWD_TYPEDEFS, BOOST_PP_EMPTY) \</span>
109<a name="l00078"></a>00078 <span class="preprocessor"> T##N; \</span>
110<a name="l00079"></a>00079 <span class="preprocessor"> switch (index) { \</span>
111<a name="l00080"></a>00080 <span class="preprocessor"> BOOST_PP_REPEAT(BOOST_PP_ADD(N,1), GIL_FWD_CASE, BOOST_PP_EMPTY) \</span>
112<a name="l00081"></a>00081 <span class="preprocessor"> } \</span>
113<a name="l00082"></a>00082 <span class="preprocessor"> throw; \</span>
114<a name="l00083"></a>00083 <span class="preprocessor"> } \</span>
115<a name="l00084"></a>00084 <span class="preprocessor"> template &lt;typename Types, typename Bits, typename UnaryOp&gt; \</span>
116<a name="l00085"></a>00085 <span class="preprocessor"> typename UnaryOp::result_type applyc(const Bits&amp; bits, std::size_t index, UnaryOp op) const { \</span>
117<a name="l00086"></a>00086 <span class="preprocessor"> typedef typename mpl::begin&lt;Types&gt;::type \</span>
118<a name="l00087"></a>00087 <span class="preprocessor"> BOOST_PP_REPEAT(N, GIL_FWD_TYPEDEFS, BOOST_PP_EMPTY) \</span>
119<a name="l00088"></a>00088 <span class="preprocessor"> T##N; \</span>
120<a name="l00089"></a>00089 <span class="preprocessor"> switch (index) { \</span>
121<a name="l00090"></a>00090 <span class="preprocessor"> BOOST_PP_REPEAT(BOOST_PP_ADD(N,1), GIL_FWD_CONST_CASE,BOOST_PP_EMPTY) \</span>
122<a name="l00091"></a>00091 <span class="preprocessor"> } \</span>
123<a name="l00092"></a>00092 <span class="preprocessor"> throw; \</span>
124<a name="l00093"></a>00093 <span class="preprocessor"> } \</span>
125<a name="l00094"></a>00094 <span class="preprocessor"> };</span>
126<a name="l00095"></a>00095 <span class="preprocessor"></span>
127<a name="l00096"></a>00096 <span class="preprocessor">#define GIL_GENERATE_APPLY_FWD_OPS(N) BOOST_PP_REPEAT(N, GIL_APPLY_FWD_OP, BOOST_PP_EMPTY)</span>
128<a name="l00097"></a>00097 <span class="preprocessor"></span>
129<a name="l00098"></a>00098 <span class="keyword">namespace </span>detail {
130<a name="l00099"></a>00099 <span class="keyword">template</span> &lt;std::<span class="keywordtype">size_t</span> N&gt; <span class="keyword">struct </span>apply_operation_fwd_fn {};
131<a name="l00100"></a>00100
132<a name="l00101"></a>00101 <span class="comment">// Create specializations of apply_operation_fn for each N 0..100</span>
133<a name="l00102"></a>00102 GIL_GENERATE_APPLY_FWD_OPS(99)
134<a name="l00103"></a>00103 } <span class="comment">// namespace detail</span>
135<a name="l00104"></a>00104
136<a name="l00105"></a>00105 <span class="comment">// unary application</span>
137<a name="l00106"></a>00106 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> Types, <span class="keyword">typename</span> Bits, <span class="keyword">typename</span> Op&gt;
138<a name="l00107"></a>00107 <span class="keyword">typename</span> Op::result_type GIL_FORCEINLINE apply_operation_basec(<span class="keyword">const</span> Bits&amp; bits, std::size_t index, Op op) {
139<a name="l00108"></a>00108 <span class="keywordflow">return</span> detail::apply_operation_fwd_fn&lt;mpl::size&lt;Types&gt;::value&gt;().<span class="keyword">template</span> applyc&lt;Types&gt;(bits,index,op);
140<a name="l00109"></a>00109 }
141<a name="l00110"></a>00110
142<a name="l00111"></a>00111 <span class="comment">// unary application</span>
143<a name="l00112"></a>00112 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> Types, <span class="keyword">typename</span> Bits, <span class="keyword">typename</span> Op&gt;
144<a name="l00113"></a>00113 <span class="keyword">typename</span> Op::result_type GIL_FORCEINLINE apply_operation_base( Bits&amp; bits, std::size_t index, Op op) {
145<a name="l00114"></a>00114 <span class="keywordflow">return</span> detail::apply_operation_fwd_fn&lt;mpl::size&lt;Types&gt;::value&gt;().<span class="keyword">template</span> apply&lt;Types&gt;(bits,index,op);
146<a name="l00115"></a>00115 }
147<a name="l00116"></a>00116
148<a name="l00117"></a>00117 <span class="keyword">namespace </span>detail {
149<a name="l00118"></a>00118 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> T2, <span class="keyword">typename</span> Op&gt;
150<a name="l00119"></a>00119 <span class="keyword">struct </span>reduce_bind1 {
151<a name="l00120"></a>00120 <span class="keyword">const</span> T2&amp; _t2;
152<a name="l00121"></a>00121 <span class="keyword">mutable</span> Op&amp; _op;
153<a name="l00122"></a>00122
154<a name="l00123"></a>00123 <span class="keyword">typedef</span> <span class="keyword">typename</span> Op::result_type result_type;
155<a name="l00124"></a>00124
156<a name="l00125"></a>00125 reduce_bind1(<span class="keyword">const</span> T2&amp; t2, Op&amp; op) : _t2(t2), _op(op) {}
157<a name="l00126"></a>00126
158<a name="l00127"></a>00127 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> T1&gt; GIL_FORCEINLINE result_type operator()(<span class="keyword">const</span> T1&amp; t1) { <span class="keywordflow">return</span> _op(t1, _t2); }
159<a name="l00128"></a>00128 };
160<a name="l00129"></a>00129
161<a name="l00130"></a>00130 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> Types1, <span class="keyword">typename</span> Bits1, <span class="keyword">typename</span> Op&gt;
162<a name="l00131"></a>00131 <span class="keyword">struct </span>reduce_bind2 {
163<a name="l00132"></a>00132 <span class="keyword">const</span> Bits1&amp; _bits1;
164<a name="l00133"></a>00133 std::size_t _index1;
165<a name="l00134"></a>00134 <span class="keyword">mutable</span> Op&amp; _op;
166<a name="l00135"></a>00135
167<a name="l00136"></a>00136 <span class="keyword">typedef</span> <span class="keyword">typename</span> Op::result_type result_type;
168<a name="l00137"></a>00137
169<a name="l00138"></a>00138 reduce_bind2(<span class="keyword">const</span> Bits1&amp; bits1, std::size_t index1, Op&amp; op) : _bits1(bits1), _index1(index1), _op(op) {}
170<a name="l00139"></a>00139
171<a name="l00140"></a>00140 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> T2&gt; GIL_FORCEINLINE result_type operator()(<span class="keyword">const</span> T2&amp; t2) {
172<a name="l00141"></a>00141 <span class="keywordflow">return</span> apply_operation_basec&lt;Types1&gt;(_bits1, _index1, reduce_bind1&lt;T2,Op&gt;(t2, _op));
173<a name="l00142"></a>00142 }
174<a name="l00143"></a>00143 };
175<a name="l00144"></a>00144 } <span class="comment">// namespace detail</span>
176<a name="l00145"></a>00145
177<a name="l00146"></a>00146 <span class="comment">// Binary application by applying on each dimension separately</span>
178<a name="l00147"></a>00147 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> Types1, <span class="keyword">typename</span> Types2, <span class="keyword">typename</span> Bits1, <span class="keyword">typename</span> Bits2, <span class="keyword">typename</span> Op&gt;
179<a name="l00148"></a>00148 <span class="keyword">static</span> <span class="keyword">typename</span> Op::result_type GIL_FORCEINLINE apply_operation_base(<span class="keyword">const</span> Bits1&amp; bits1, std::size_t index1, <span class="keyword">const</span> Bits2&amp; bits2, std::size_t index2, Op op) {
180<a name="l00149"></a>00149 <span class="keywordflow">return</span> apply_operation_basec&lt;Types2&gt;(bits2,index2,detail::reduce_bind2&lt;Types1,Bits1,Op&gt;(bits1,index1,op));
181<a name="l00150"></a>00150 }
182<a name="l00151"></a>00151
183<a name="l00152"></a>00152 <span class="preprocessor">#undef GIL_FWD_TYPEDEFS</span>
184<a name="l00153"></a>00153 <span class="preprocessor"></span><span class="preprocessor">#undef GIL_FWD_CASE</span>
185<a name="l00154"></a>00154 <span class="preprocessor"></span><span class="preprocessor">#undef GIL_FWD_CONST_CASE</span>
186<a name="l00155"></a>00155 <span class="preprocessor"></span><span class="preprocessor">#undef GIL_APPLY_FWD_OP</span>
187<a name="l00156"></a>00156 <span class="preprocessor"></span><span class="preprocessor">#undef GIL_GENERATE_APPLY_FWD_OPS</span>
188<a name="l00157"></a>00157 <span class="preprocessor"></span><span class="preprocessor">#undef BHS</span>
189<a name="l00158"></a>00158 <span class="preprocessor"></span>
190<a name="l00159"></a>00159 } } <span class="comment">// namespace boost::gil</span>
191<a name="l00160"></a>00160
192<a name="l00161"></a>00161
193<a name="l00162"></a>00162 <span class="preprocessor">#endif</span>
194</pre></div></div>
195<hr size="1"><address style="text-align: right;"><small>Generated on Sat May 2 13:50:13 2009 for Generic Image Library by&nbsp;
196<a href="http://www.doxygen.org/index.html">
197<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.6 </small></address>
198</body>
199</html>