Sophie

Sophie

distrib > Fedora > 14 > i386 > by-pkgid > 623999701586b0ea103ff2ccad7954a6 > files > 6207

boost-doc-1.44.0-1.fc14.noarch.rpm

<!-- Copyright 2008 Lubomir Bourdev and Hailin Jin

     Distributed under the Boost Software License, Version 1.0.
     (See accompanying file LICENSE_1_0.txt or copy at
     http://www.boost.org/LICENSE_1_0.txt)
  -->

<!--
    Copyright 2005-2007 Adobe Systems Incorporated
    Distributed under the MIT License (see accompanying file LICENSE_1_0_0.txt
    or a copy at http://stlab.adobe.com/licenses.html)

    Some files are held under additional license.
    Please see "http://stlab.adobe.com/licenses.html" for more information.
-->

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">

<head>
    <TITLE>Generic Image Library: dynamic_at_c.hpp Source File</TITLE>
    <META HTTP-EQUIV="content-type" CONTENT="text/html;charset=ISO-8859-1"/>
    <LINK TYPE="text/css" REL="stylesheet" HREF="adobe_source.css"/>
</head>
<body>
<table border="0" cellspacing="0" cellpadding="0" style='width: 100%; margin: 0; padding: 0'><tr>
<td width="100%" valign="top" style='padding-left: 10px; padding-right: 10px; padding-bottom: 10px'>
<div class="qindex"><a class="qindex" href="index.html">Modules</a> 
                  | <a class="qindex" href="classes.html">Alphabetical List</a> 
                  | <a class="qindex" href="annotated.html">Class List</a> 
                  | <a class="qindex" href="dirs.html">Directories</a> 
                  | <a class="qindex" href="files.html">File List</a> 
                  | <a class="qindex" href="../index.html">GIL Home Page</a> 
</div>
<!-- End Header -->
<!-- Generated by Doxygen 1.5.6 -->
  <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>
  </div>
<div class="contents">
<h1>dynamic_at_c.hpp</h1><a href="g_i_l_0081.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
<a name="l00002"></a>00002 <span class="comment">    Copyright 2005-2007 Adobe Systems Incorporated</span>
<a name="l00003"></a>00003 <span class="comment">   </span>
<a name="l00004"></a>00004 <span class="comment">    Use, modification and distribution are subject to the Boost Software License,</span>
<a name="l00005"></a>00005 <span class="comment">    Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at</span>
<a name="l00006"></a>00006 <span class="comment">    http://www.boost.org/LICENSE_1_0.txt).</span>
<a name="l00007"></a>00007 <span class="comment"></span>
<a name="l00008"></a>00008 <span class="comment">    See http://opensource.adobe.com/gil for most recent version including documentation.</span>
<a name="l00009"></a>00009 <span class="comment">*/</span>
<a name="l00010"></a>00010 
<a name="l00011"></a>00011 <span class="comment">/*************************************************************************************************/</span>
<a name="l00012"></a>00012 
<a name="l00013"></a>00013 <span class="preprocessor">#ifndef GIL_DYNAMIC_AT_C_HPP</span>
<a name="l00014"></a>00014 <span class="preprocessor"></span><span class="preprocessor">#define GIL_DYNAMIC_AT_C_HPP</span>
<a name="l00015"></a>00015 <span class="preprocessor"></span>
<a name="l00016"></a>00016 <span class="preprocessor">#include "../../gil_config.hpp"</span>
<a name="l00017"></a>00017 <span class="preprocessor">#include &lt;cassert&gt;</span>
<a name="l00018"></a>00018 <span class="preprocessor">#include &lt;stdexcept&gt;</span>
<a name="l00019"></a>00019 <span class="preprocessor">#include &lt;boost/mpl/at.hpp&gt;</span>
<a name="l00020"></a>00020 <span class="preprocessor">#include &lt;boost/mpl/size.hpp&gt;</span>
<a name="l00021"></a>00021 
<a name="l00022"></a>00022 
<a name="l00031"></a>00031 
<a name="l00032"></a>00032 <span class="keyword">namespace </span>boost { <span class="keyword">namespace </span>gil {
<a name="l00033"></a>00033 
<a name="l00034"></a>00034 <span class="preprocessor">#define GIL_AT_C_VALUE(z, N, text)    mpl::at_c&lt;IntTypes,S+N&gt;::type::value,</span>
<a name="l00035"></a>00035 <span class="preprocessor"></span><span class="preprocessor">#define GIL_DYNAMIC_AT_C_LIMIT        226    // size of the maximum vector to handle</span>
<a name="l00036"></a>00036 <span class="preprocessor"></span>
<a name="l00037"></a>00037 <span class="preprocessor">#define GIL_AT_C_LOOKUP(z, NUM, text)                                   \</span>
<a name="l00038"></a>00038 <span class="preprocessor">    template&lt;std::size_t S&gt;                                             \</span>
<a name="l00039"></a>00039 <span class="preprocessor">    struct at_c_fn&lt;S,NUM&gt; {                                             \</span>
<a name="l00040"></a>00040 <span class="preprocessor">    template &lt;typename IntTypes, typename ValueType&gt; inline           \</span>
<a name="l00041"></a>00041 <span class="preprocessor">        static ValueType apply(std::size_t index) {                    \</span>
<a name="l00042"></a>00042 <span class="preprocessor">            static ValueType table[] = {                               \</span>
<a name="l00043"></a>00043 <span class="preprocessor">                BOOST_PP_REPEAT(NUM, GIL_AT_C_VALUE, BOOST_PP_EMPTY)    \</span>
<a name="l00044"></a>00044 <span class="preprocessor">            };                                                          \</span>
<a name="l00045"></a>00045 <span class="preprocessor">            return table[index];                                        \</span>
<a name="l00046"></a>00046 <span class="preprocessor">        }                                                               \</span>
<a name="l00047"></a>00047 <span class="preprocessor">    };</span>
<a name="l00048"></a>00048 <span class="preprocessor"></span>
<a name="l00049"></a>00049 <span class="keyword">namespace </span>detail {
<a name="l00050"></a>00050     <span class="keyword">namespace </span>at_c {
<a name="l00051"></a>00051         <span class="keyword">template</span> &lt;std::<span class="keywordtype">size_t</span> START, std::<span class="keywordtype">size_t</span> NUM&gt; <span class="keyword">struct </span>at_c_fn;
<a name="l00052"></a>00052         BOOST_PP_REPEAT(GIL_DYNAMIC_AT_C_LIMIT, GIL_AT_C_LOOKUP, BOOST_PP_EMPTY)
<a name="l00053"></a>00053 
<a name="l00054"></a>00054         template &lt;std::<span class="keywordtype">size_t</span> QUOT&gt; struct at_c_impl;
<a name="l00055"></a>00055 
<a name="l00056"></a>00056         template &lt;&gt;
<a name="l00057"></a>00057         struct at_c_impl&lt;0&gt; {
<a name="l00058"></a>00058             <span class="keyword">template</span> &lt;<span class="keyword">typename</span> IntTypes, <span class="keyword">typename</span> ValueType&gt; <span class="keyword">inline</span>
<a name="l00059"></a>00059             <span class="keyword">static</span> ValueType apply(std::size_t index) {
<a name="l00060"></a>00060                 <span class="keywordflow">return</span> at_c_fn&lt;0,mpl::size&lt;IntTypes&gt;::value&gt;::template apply&lt;IntTypes,ValueType&gt;(index);
<a name="l00061"></a>00061             }
<a name="l00062"></a>00062         };
<a name="l00063"></a>00063 
<a name="l00064"></a>00064         <span class="keyword">template</span> &lt;&gt;
<a name="l00065"></a>00065         <span class="keyword">struct </span>at_c_impl&lt;1&gt; {
<a name="l00066"></a>00066             <span class="keyword">template</span> &lt;<span class="keyword">typename</span> IntTypes, <span class="keyword">typename</span> ValueType&gt; <span class="keyword">inline</span>
<a name="l00067"></a>00067             <span class="keyword">static</span> ValueType apply(std::size_t index) {
<a name="l00068"></a>00068                 <span class="keyword">const</span> std::size_t SIZE=mpl::size&lt;IntTypes&gt;::value;
<a name="l00069"></a>00069                 <span class="keyword">const</span> std::size_t REM = SIZE % GIL_DYNAMIC_AT_C_LIMIT;
<a name="l00070"></a>00070                 <span class="keywordflow">switch</span> (index / GIL_DYNAMIC_AT_C_LIMIT) {
<a name="l00071"></a>00071                     <span class="keywordflow">case</span> 0: <span class="keywordflow">return</span> at_c_fn&lt;0                   ,GIL_DYNAMIC_AT_C_LIMIT-1&gt;::template apply&lt;IntTypes,ValueType&gt;(index);
<a name="l00072"></a>00072                     <span class="keywordflow">case</span> 1: <span class="keywordflow">return</span> at_c_fn&lt;GIL_DYNAMIC_AT_C_LIMIT  ,REM                 &gt;::template apply&lt;IntTypes,ValueType&gt;(index - GIL_DYNAMIC_AT_C_LIMIT);                
<a name="l00073"></a>00073                 };
<a name="l00074"></a>00074                 <span class="keywordflow">throw</span>;
<a name="l00075"></a>00075             }
<a name="l00076"></a>00076         };
<a name="l00077"></a>00077 
<a name="l00078"></a>00078         <span class="keyword">template</span> &lt;&gt;
<a name="l00079"></a>00079         <span class="keyword">struct </span>at_c_impl&lt;2&gt; {
<a name="l00080"></a>00080             <span class="keyword">template</span> &lt;<span class="keyword">typename</span> IntTypes, <span class="keyword">typename</span> ValueType&gt; <span class="keyword">inline</span>
<a name="l00081"></a>00081             <span class="keyword">static</span> ValueType apply(std::size_t index) {
<a name="l00082"></a>00082                 <span class="keyword">const</span> std::size_t SIZE=mpl::size&lt;IntTypes&gt;::value;
<a name="l00083"></a>00083                 <span class="keyword">const</span> std::size_t REM = SIZE % GIL_DYNAMIC_AT_C_LIMIT;
<a name="l00084"></a>00084                 <span class="keywordflow">switch</span> (index / GIL_DYNAMIC_AT_C_LIMIT) {
<a name="l00085"></a>00085                     <span class="keywordflow">case</span> 0: <span class="keywordflow">return</span> at_c_fn&lt;0                   ,GIL_DYNAMIC_AT_C_LIMIT-1&gt;::template apply&lt;IntTypes,ValueType&gt;(index);
<a name="l00086"></a>00086                     <span class="keywordflow">case</span> 1: <span class="keywordflow">return</span> at_c_fn&lt;GIL_DYNAMIC_AT_C_LIMIT  ,GIL_DYNAMIC_AT_C_LIMIT-1&gt;::template apply&lt;IntTypes,ValueType&gt;(index - GIL_DYNAMIC_AT_C_LIMIT);
<a name="l00087"></a>00087                     <span class="keywordflow">case</span> 2: <span class="keywordflow">return</span> at_c_fn&lt;GIL_DYNAMIC_AT_C_LIMIT*2,REM                 &gt;::template apply&lt;IntTypes,ValueType&gt;(index - GIL_DYNAMIC_AT_C_LIMIT*2);                
<a name="l00088"></a>00088                 };
<a name="l00089"></a>00089                 <span class="keywordflow">throw</span>;
<a name="l00090"></a>00090             }
<a name="l00091"></a>00091         };
<a name="l00092"></a>00092 
<a name="l00093"></a>00093         <span class="keyword">template</span> &lt;&gt;
<a name="l00094"></a>00094         <span class="keyword">struct </span>at_c_impl&lt;3&gt; {
<a name="l00095"></a>00095             <span class="keyword">template</span> &lt;<span class="keyword">typename</span> IntTypes, <span class="keyword">typename</span> ValueType&gt; <span class="keyword">inline</span>
<a name="l00096"></a>00096             <span class="keyword">static</span> ValueType apply(std::size_t index) {
<a name="l00097"></a>00097                 <span class="keyword">const</span> std::size_t SIZE=mpl::size&lt;IntTypes&gt;::value;
<a name="l00098"></a>00098                 <span class="keyword">const</span> std::size_t REM = SIZE % GIL_DYNAMIC_AT_C_LIMIT;
<a name="l00099"></a>00099                 <span class="keywordflow">switch</span> (index / GIL_DYNAMIC_AT_C_LIMIT) {
<a name="l00100"></a>00100                     <span class="keywordflow">case</span> 0: <span class="keywordflow">return</span> at_c_fn&lt;0                   ,GIL_DYNAMIC_AT_C_LIMIT-1&gt;::template apply&lt;IntTypes,ValueType&gt;(index);
<a name="l00101"></a>00101                     <span class="keywordflow">case</span> 1: <span class="keywordflow">return</span> at_c_fn&lt;GIL_DYNAMIC_AT_C_LIMIT  ,GIL_DYNAMIC_AT_C_LIMIT-1&gt;::template apply&lt;IntTypes,ValueType&gt;(index - GIL_DYNAMIC_AT_C_LIMIT);
<a name="l00102"></a>00102                     <span class="keywordflow">case</span> 2: <span class="keywordflow">return</span> at_c_fn&lt;GIL_DYNAMIC_AT_C_LIMIT*2,GIL_DYNAMIC_AT_C_LIMIT-1&gt;::template apply&lt;IntTypes,ValueType&gt;(index - GIL_DYNAMIC_AT_C_LIMIT*2);                
<a name="l00103"></a>00103                     <span class="keywordflow">case</span> 3: <span class="keywordflow">return</span> at_c_fn&lt;GIL_DYNAMIC_AT_C_LIMIT*3,REM                 &gt;::template apply&lt;IntTypes,ValueType&gt;(index - GIL_DYNAMIC_AT_C_LIMIT*3);                
<a name="l00104"></a>00104                 };
<a name="l00105"></a>00105                 <span class="keywordflow">throw</span>;
<a name="l00106"></a>00106             }
<a name="l00107"></a>00107         };
<a name="l00108"></a>00108     }
<a name="l00109"></a>00109 }
<a name="l00110"></a>00110 
<a name="l00117"></a>00117 
<a name="l00118"></a>00118 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> IntTypes, <span class="keyword">typename</span> ValueType&gt; <span class="keyword">inline</span> 
<a name="l00119"></a>00119 ValueType at_c(std::size_t index) { 
<a name="l00120"></a>00120     <span class="keyword">const</span> std::size_t Size=mpl::size&lt;IntTypes&gt;::value;
<a name="l00121"></a>00121     <span class="keywordflow">return</span> detail::at_c::at_c_impl&lt;Size/GIL_DYNAMIC_AT_C_LIMIT&gt;::template apply&lt;IntTypes,ValueType&gt;(index);
<a name="l00122"></a>00122 }    
<a name="l00123"></a>00123 
<a name="l00124"></a>00124 <span class="preprocessor">#undef GIL_AT_C_VALUE</span>
<a name="l00125"></a>00125 <span class="preprocessor"></span><span class="preprocessor">#undef GIL_DYNAMIC_AT_C_LIMIT</span>
<a name="l00126"></a>00126 <span class="preprocessor"></span><span class="preprocessor">#undef GIL_AT_C_LOOKUP</span>
<a name="l00127"></a>00127 <span class="preprocessor"></span>
<a name="l00128"></a>00128 } }  <span class="comment">// namespace boost::gil</span>
<a name="l00129"></a>00129 
<a name="l00130"></a>00130 <span class="preprocessor">#endif</span>
</pre></div></div>
<hr size="1"><address style="text-align: right;"><small>Generated on Sat May 2 13:50:13 2009 for Generic Image Library by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.6 </small></address>
</body>
</html>