Sophie

Sophie

distrib > Fedora > 14 > x86_64 > media > updates > by-pkgid > 6e7a2755bd78c9deedab199b86e675f3 > files > 3771

gnuradio-doc-3.2.2-9.fc14.x86_64.rpm

<!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">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>GNU Radio 3.2.2 C++ API: gr_buffer.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript">
$(document).ready(initResizable);
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Generated by Doxygen 1.7.3 -->
<div id="top">
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">GNU Radio 3.2.2 C++ API</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('gr__buffer_8h.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="headertitle">
<h1>gr_buffer.h</h1>  </div>
</div>
<div class="contents">
<a href="gr__buffer_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/* -*- c++ -*- */</span>
<a name="l00002"></a>00002 <span class="comment">/*</span>
<a name="l00003"></a>00003 <span class="comment"> * Copyright 2004 Free Software Foundation, Inc.</span>
<a name="l00004"></a>00004 <span class="comment"> * </span>
<a name="l00005"></a>00005 <span class="comment"> * This file is part of GNU Radio</span>
<a name="l00006"></a>00006 <span class="comment"> * </span>
<a name="l00007"></a>00007 <span class="comment"> * GNU Radio is free software; you can redistribute it and/or modify</span>
<a name="l00008"></a>00008 <span class="comment"> * it under the terms of the GNU General Public License as published by</span>
<a name="l00009"></a>00009 <span class="comment"> * the Free Software Foundation; either version 3, or (at your option)</span>
<a name="l00010"></a>00010 <span class="comment"> * any later version.</span>
<a name="l00011"></a>00011 <span class="comment"> * </span>
<a name="l00012"></a>00012 <span class="comment"> * GNU Radio is distributed in the hope that it will be useful,</span>
<a name="l00013"></a>00013 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00014"></a>00014 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span>
<a name="l00015"></a>00015 <span class="comment"> * GNU General Public License for more details.</span>
<a name="l00016"></a>00016 <span class="comment"> * </span>
<a name="l00017"></a>00017 <span class="comment"> * You should have received a copy of the GNU General Public License</span>
<a name="l00018"></a>00018 <span class="comment"> * along with GNU Radio; see the file COPYING.  If not, write to</span>
<a name="l00019"></a>00019 <span class="comment"> * the Free Software Foundation, Inc., 51 Franklin Street,</span>
<a name="l00020"></a>00020 <span class="comment"> * Boston, MA 02110-1301, USA.</span>
<a name="l00021"></a>00021 <span class="comment"> */</span>
<a name="l00022"></a>00022 
<a name="l00023"></a>00023 <span class="preprocessor">#ifndef INCLUDED_GR_BUFFER_H</span>
<a name="l00024"></a>00024 <span class="preprocessor"></span><span class="preprocessor">#define INCLUDED_GR_BUFFER_H</span>
<a name="l00025"></a>00025 <span class="preprocessor"></span>
<a name="l00026"></a>00026 <span class="preprocessor">#include &lt;<a class="code" href="gr__runtime__types_8h.html">gr_runtime_types.h</a>&gt;</span>
<a name="l00027"></a>00027 <span class="preprocessor">#include &lt;boost/weak_ptr.hpp&gt;</span>
<a name="l00028"></a>00028 <span class="preprocessor">#include &lt;boost/thread.hpp&gt;</span>
<a name="l00029"></a>00029 
<a name="l00030"></a>00030 <span class="keyword">class </span><a class="code" href="classgr__vmcircbuf.html" title="abstract class to implement doubly mapped virtual memory circular buffers">gr_vmcircbuf</a>;
<a name="l00031"></a>00031 <span class="comment"></span>
<a name="l00032"></a>00032 <span class="comment">/*!</span>
<a name="l00033"></a>00033 <span class="comment"> * \brief Allocate a buffer that holds at least \p nitems of size \p sizeof_item.</span>
<a name="l00034"></a>00034 <span class="comment"> *</span>
<a name="l00035"></a>00035 <span class="comment"> * The total size of the buffer will be rounded up to a system</span>
<a name="l00036"></a>00036 <span class="comment"> * dependent boundary.  This is typically the system page size, but</span>
<a name="l00037"></a>00037 <span class="comment"> * under MS windows is 64KB.</span>
<a name="l00038"></a>00038 <span class="comment"> *</span>
<a name="l00039"></a>00039 <span class="comment"> * \param nitems is the minimum number of items the buffer will hold.</span>
<a name="l00040"></a>00040 <span class="comment"> * \param sizeof_item is the size of an item in bytes.</span>
<a name="l00041"></a>00041 <span class="comment"> * \param link is the block that writes to this buffer.</span>
<a name="l00042"></a>00042 <span class="comment"> */</span>
<a name="l00043"></a>00043 <a class="code" href="classboost_1_1shared__ptr.html" title="shared_ptr documentation stub">gr_buffer_sptr</a> <a class="code" href="gr__buffer_8h.html#aebc8f592465e520011dc5eb872b1a5e7" title="Allocate a buffer that holds at least nitems of size sizeof_item.">gr_make_buffer</a> (<span class="keywordtype">int</span> nitems, <span class="keywordtype">size_t</span> sizeof_item, <a class="code" href="classboost_1_1shared__ptr.html">gr_block_sptr</a> link=<a class="code" href="classboost_1_1shared__ptr.html">gr_block_sptr</a>());
<a name="l00044"></a>00044 
<a name="l00045"></a>00045 <span class="comment"></span>
<a name="l00046"></a>00046 <span class="comment">/*!</span>
<a name="l00047"></a>00047 <span class="comment"> * \brief Single writer, multiple reader fifo.</span>
<a name="l00048"></a>00048 <span class="comment"> * \ingroup internal</span>
<a name="l00049"></a>00049 <span class="comment"> */</span>
<a name="l00050"></a><a class="code" href="classgr__buffer.html">00050</a> <span class="keyword">class </span><a class="code" href="classgr__buffer.html" title="Single writer, multiple reader fifo.">gr_buffer</a> {
<a name="l00051"></a>00051  <span class="keyword">public</span>:
<a name="l00052"></a>00052 
<a name="l00053"></a><a class="code" href="classgr__buffer.html#aff98726da27f70ef316640f925636260">00053</a>   <span class="keyword">typedef</span> boost::unique_lock&lt;boost::mutex&gt;  <a class="code" href="classgr__buffer.html#aff98726da27f70ef316640f925636260">scoped_lock</a>;
<a name="l00054"></a>00054 
<a name="l00055"></a>00055   <span class="keyword">virtual</span> <a class="code" href="classgr__buffer.html#ab3c5c8028b30a30c6c3eb3015225ba4b">~gr_buffer</a> ();
<a name="l00056"></a>00056 <span class="comment"></span>
<a name="l00057"></a>00057 <span class="comment">  /*!</span>
<a name="l00058"></a>00058 <span class="comment">   * \brief return number of items worth of space available for writing</span>
<a name="l00059"></a>00059 <span class="comment">   */</span>
<a name="l00060"></a>00060   <span class="keywordtype">int</span> <a class="code" href="classgr__buffer.html#a1d064236bb139c339a425b51212813b1" title="return number of items worth of space available for writing">space_available</a> ();
<a name="l00061"></a>00061 <span class="comment"></span>
<a name="l00062"></a>00062 <span class="comment">  /*!</span>
<a name="l00063"></a>00063 <span class="comment">   * \brief return size of this buffer in items</span>
<a name="l00064"></a>00064 <span class="comment">   */</span>
<a name="l00065"></a><a class="code" href="classgr__buffer.html#a39a2c75577d0b37f7eef0b930d588da4">00065</a>   <span class="keywordtype">int</span> <a class="code" href="classgr__buffer.html#a39a2c75577d0b37f7eef0b930d588da4" title="return size of this buffer in items">bufsize</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classgr__buffer.html#a2ce1b319068ce94e4799b7affe4b48ae">d_bufsize</a>; }
<a name="l00066"></a>00066 <span class="comment"></span>
<a name="l00067"></a>00067 <span class="comment">  /*!</span>
<a name="l00068"></a>00068 <span class="comment">   * \brief return pointer to write buffer.</span>
<a name="l00069"></a>00069 <span class="comment">   *</span>
<a name="l00070"></a>00070 <span class="comment">   * The return value points at space that can hold at least</span>
<a name="l00071"></a>00071 <span class="comment">   * space_available() items.</span>
<a name="l00072"></a>00072 <span class="comment">   */</span>
<a name="l00073"></a>00073   <span class="keywordtype">void</span> *<a class="code" href="classgr__buffer.html#a1a4dc904e4da49e58a3405550665a712" title="return pointer to write buffer.">write_pointer</a> ();
<a name="l00074"></a>00074 <span class="comment"></span>
<a name="l00075"></a>00075 <span class="comment">  /*!</span>
<a name="l00076"></a>00076 <span class="comment">   * \brief tell buffer that we wrote \p nitems into it</span>
<a name="l00077"></a>00077 <span class="comment">   */</span>
<a name="l00078"></a>00078   <span class="keywordtype">void</span> <a class="code" href="classgr__buffer.html#aba102b9c8394068b2c4b570c0e788e82" title="tell buffer that we wrote nitems into it">update_write_pointer</a> (<span class="keywordtype">int</span> nitems);
<a name="l00079"></a>00079 
<a name="l00080"></a>00080   <span class="keywordtype">void</span> <a class="code" href="classgr__buffer.html#af7528d62028e0b7e022734b00f8aeb1b">set_done</a> (<span class="keywordtype">bool</span> <a class="code" href="classgr__buffer.html#a89a1d9c85ba243e952a62015c7009d8d">done</a>);
<a name="l00081"></a><a class="code" href="classgr__buffer.html#a89a1d9c85ba243e952a62015c7009d8d">00081</a>   <span class="keywordtype">bool</span> <a class="code" href="classgr__buffer.html#a89a1d9c85ba243e952a62015c7009d8d">done</a> ()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> d_done; }
<a name="l00082"></a>00082 <span class="comment"></span>
<a name="l00083"></a>00083 <span class="comment">  /*!</span>
<a name="l00084"></a>00084 <span class="comment">   * \brief Return the block that writes to this buffer.</span>
<a name="l00085"></a>00085 <span class="comment">   */</span>
<a name="l00086"></a><a class="code" href="classgr__buffer.html#a3e5c410222891cad5b7d5b85ff82b85f">00086</a>   <a class="code" href="classboost_1_1shared__ptr.html">gr_block_sptr</a> <a class="code" href="classgr__buffer.html#a3e5c410222891cad5b7d5b85ff82b85f" title="Return the block that writes to this buffer.">link</a>() { <span class="keywordflow">return</span> <a class="code" href="classboost_1_1shared__ptr.html">gr_block_sptr</a>(d_link); }
<a name="l00087"></a>00087 
<a name="l00088"></a><a class="code" href="classgr__buffer.html#a2eb5af8306fe4a2c6d6838ff41b3240b">00088</a>   <span class="keywordtype">size_t</span> <a class="code" href="classgr__buffer.html#a2eb5af8306fe4a2c6d6838ff41b3240b">nreaders</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> d_readers.size(); }
<a name="l00089"></a><a class="code" href="classgr__buffer.html#a2009bf87ea09dd35abd0f42030911381">00089</a>   <a class="code" href="classgr__buffer__reader.html" title="How we keep track of the readers of a gr_buffer.">gr_buffer_reader</a>* <a class="code" href="classgr__buffer.html#a2009bf87ea09dd35abd0f42030911381">reader</a>(<span class="keywordtype">size_t</span> index) { <span class="keywordflow">return</span> d_readers[index]; }
<a name="l00090"></a>00090 
<a name="l00091"></a><a class="code" href="classgr__buffer.html#afb6b8a5f64a9d556a80ce528168fcd7b">00091</a>   boost::mutex *<a class="code" href="classgr__buffer.html#afb6b8a5f64a9d556a80ce528168fcd7b">mutex</a>() { <span class="keywordflow">return</span> &amp;d_mutex; }
<a name="l00092"></a>00092 
<a name="l00093"></a>00093   <span class="comment">// -------------------------------------------------------------------------</span>
<a name="l00094"></a>00094 
<a name="l00095"></a>00095  <span class="keyword">private</span>:
<a name="l00096"></a>00096 
<a name="l00097"></a><a class="code" href="classgr__buffer.html#a7ecfad759b1fdf2dcb7416a16f563482">00097</a>   <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="classgr__buffer__reader.html" title="How we keep track of the readers of a gr_buffer.">gr_buffer_reader</a>;
<a name="l00098"></a>00098   <span class="keyword">friend</span> <a class="code" href="classboost_1_1shared__ptr.html">gr_buffer_sptr</a> <a class="code" href="classgr__buffer.html#a9c3543ee3c4e4eea1d8ea5c3705ecdbf" title="Allocate a buffer that holds at least nitems of size sizeof_item.">gr_make_buffer</a> (<span class="keywordtype">int</span> nitems, <span class="keywordtype">size_t</span> sizeof_item, <a class="code" href="classboost_1_1shared__ptr.html">gr_block_sptr</a> <a class="code" href="classgr__buffer.html#a3e5c410222891cad5b7d5b85ff82b85f" title="Return the block that writes to this buffer.">link</a>);
<a name="l00099"></a>00099   <span class="keyword">friend</span> <a class="code" href="classboost_1_1shared__ptr.html">gr_buffer_reader_sptr</a> <a class="code" href="classgr__buffer.html#afb5b9797c2e10e7f5d456643d3b420cb" title="Create a new gr_buffer_reader and attach it to buffer buf.">gr_buffer_add_reader</a> (<a class="code" href="classboost_1_1shared__ptr.html">gr_buffer_sptr</a> buf, <span class="keywordtype">int</span> nzero_preload, <a class="code" href="classboost_1_1shared__ptr.html">gr_block_sptr</a> <a class="code" href="classgr__buffer.html#a3e5c410222891cad5b7d5b85ff82b85f" title="Return the block that writes to this buffer.">link</a>);
<a name="l00100"></a>00100 
<a name="l00101"></a>00101  <span class="keyword">protected</span>:
<a name="l00102"></a><a class="code" href="classgr__buffer.html#a60aa2c93de67e9c5782a34130aac8da3">00102</a>   <span class="keywordtype">char</span>                                 *<a class="code" href="classgr__buffer.html#a60aa2c93de67e9c5782a34130aac8da3">d_base</a>;         <span class="comment">// base address of buffer</span>
<a name="l00103"></a><a class="code" href="classgr__buffer.html#a2ce1b319068ce94e4799b7affe4b48ae">00103</a>   <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>                          <a class="code" href="classgr__buffer.html#a2ce1b319068ce94e4799b7affe4b48ae">d_bufsize</a>;      <span class="comment">// in items</span>
<a name="l00104"></a>00104  <span class="keyword">private</span>:
<a name="l00105"></a>00105   <a class="code" href="classgr__vmcircbuf.html" title="abstract class to implement doubly mapped virtual memory circular buffers">gr_vmcircbuf</a>                         *d_vmcircbuf;
<a name="l00106"></a>00106   <span class="keywordtype">size_t</span>                                d_sizeof_item;  <span class="comment">// in bytes</span>
<a name="l00107"></a>00107   <a class="code" href="classstd_1_1vector.html">std::vector&lt;gr_buffer_reader *&gt;</a>       d_readers;
<a name="l00108"></a>00108   boost::weak_ptr&lt;gr_block&gt;             d_link;         <span class="comment">// block that writes to this buffer</span>
<a name="l00109"></a>00109 
<a name="l00110"></a>00110   <span class="comment">//</span>
<a name="l00111"></a>00111   <span class="comment">// The mutex protects d_write_index, d_done and the d_read_index&#39;s in the buffer readers.</span>
<a name="l00112"></a>00112   <span class="comment">//</span>
<a name="l00113"></a>00113   boost::mutex                          d_mutex;
<a name="l00114"></a>00114   <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>                          d_write_index;  <span class="comment">// in items [0,d_bufsize)</span>
<a name="l00115"></a>00115   <span class="keywordtype">bool</span>                                  d_done;
<a name="l00116"></a>00116   
<a name="l00117"></a>00117   <span class="keywordtype">unsigned</span>
<a name="l00118"></a>00118   index_add (<span class="keywordtype">unsigned</span> a, <span class="keywordtype">unsigned</span> b)
<a name="l00119"></a>00119   {
<a name="l00120"></a>00120     <span class="keywordtype">unsigned</span> s = a + b;
<a name="l00121"></a>00121 
<a name="l00122"></a>00122     <span class="keywordflow">if</span> (s &gt;= <a class="code" href="classgr__buffer.html#a2ce1b319068ce94e4799b7affe4b48ae">d_bufsize</a>)
<a name="l00123"></a>00123       s -= <a class="code" href="classgr__buffer.html#a2ce1b319068ce94e4799b7affe4b48ae">d_bufsize</a>;
<a name="l00124"></a>00124 
<a name="l00125"></a>00125     assert (s &lt; <a class="code" href="classgr__buffer.html#a2ce1b319068ce94e4799b7affe4b48ae">d_bufsize</a>);
<a name="l00126"></a>00126     <span class="keywordflow">return</span> s;
<a name="l00127"></a>00127   }
<a name="l00128"></a>00128 
<a name="l00129"></a>00129   <span class="keywordtype">unsigned</span>
<a name="l00130"></a>00130   index_sub (<span class="keywordtype">unsigned</span> a, <span class="keywordtype">unsigned</span> b)
<a name="l00131"></a>00131   {
<a name="l00132"></a>00132     <span class="keywordtype">int</span> s = a - b;
<a name="l00133"></a>00133 
<a name="l00134"></a>00134     <span class="keywordflow">if</span> (s &lt; 0)
<a name="l00135"></a>00135       s += <a class="code" href="classgr__buffer.html#a2ce1b319068ce94e4799b7affe4b48ae">d_bufsize</a>;
<a name="l00136"></a>00136 
<a name="l00137"></a>00137     assert ((<span class="keywordtype">unsigned</span>) s &lt; <a class="code" href="classgr__buffer.html#a2ce1b319068ce94e4799b7affe4b48ae">d_bufsize</a>);
<a name="l00138"></a>00138     <span class="keywordflow">return</span> s;
<a name="l00139"></a>00139   }
<a name="l00140"></a>00140 
<a name="l00141"></a>00141   <span class="keyword">virtual</span> <span class="keywordtype">bool</span> allocate_buffer (<span class="keywordtype">int</span> nitems, <span class="keywordtype">size_t</span> sizeof_item);
<a name="l00142"></a>00142 <span class="comment"></span>
<a name="l00143"></a>00143 <span class="comment">  /*!</span>
<a name="l00144"></a>00144 <span class="comment">   * \brief constructor is private.  Use gr_make_buffer to create instances.</span>
<a name="l00145"></a>00145 <span class="comment">   *</span>
<a name="l00146"></a>00146 <span class="comment">   * Allocate a buffer that holds at least \p nitems of size \p sizeof_item.</span>
<a name="l00147"></a>00147 <span class="comment">   *</span>
<a name="l00148"></a>00148 <span class="comment">   * \param nitems is the minimum number of items the buffer will hold.</span>
<a name="l00149"></a>00149 <span class="comment">   * \param sizeof_item is the size of an item in bytes.</span>
<a name="l00150"></a>00150 <span class="comment">   * \param link is the block that writes to this buffer.</span>
<a name="l00151"></a>00151 <span class="comment">   *</span>
<a name="l00152"></a>00152 <span class="comment">   * The total size of the buffer will be rounded up to a system</span>
<a name="l00153"></a>00153 <span class="comment">   * dependent boundary.  This is typically the system page size, but</span>
<a name="l00154"></a>00154 <span class="comment">   * under MS windows is 64KB.</span>
<a name="l00155"></a>00155 <span class="comment">   */</span>
<a name="l00156"></a>00156   <a class="code" href="classgr__buffer__reader.html#a25dff068f5cfde18c4307b4973f4db9d">gr_buffer</a> (<span class="keywordtype">int</span> nitems, <span class="keywordtype">size_t</span> sizeof_item, <a class="code" href="classboost_1_1shared__ptr.html">gr_block_sptr</a> <a class="code" href="classgr__buffer.html#a3e5c410222891cad5b7d5b85ff82b85f" title="Return the block that writes to this buffer.">link</a>);
<a name="l00157"></a>00157 <span class="comment"></span>
<a name="l00158"></a>00158 <span class="comment">  /*!</span>
<a name="l00159"></a>00159 <span class="comment">   * \brief disassociate \p reader from this buffer</span>
<a name="l00160"></a>00160 <span class="comment">   */</span>
<a name="l00161"></a>00161   <span class="keywordtype">void</span> drop_reader (<a class="code" href="classgr__buffer__reader.html" title="How we keep track of the readers of a gr_buffer.">gr_buffer_reader</a> *<a class="code" href="classgr__buffer.html#a2009bf87ea09dd35abd0f42030911381">reader</a>);
<a name="l00162"></a>00162 
<a name="l00163"></a>00163 };
<a name="l00164"></a>00164 <span class="comment"></span>
<a name="l00165"></a>00165 <span class="comment">/*!</span>
<a name="l00166"></a>00166 <span class="comment"> * \brief Create a new gr_buffer_reader and attach it to buffer \p buf</span>
<a name="l00167"></a>00167 <span class="comment"> * \param buf is the buffer the \p gr_buffer_reader reads from.</span>
<a name="l00168"></a>00168 <span class="comment"> * \param nzero_preload -- number of zero items to &quot;preload&quot; into buffer.</span>
<a name="l00169"></a>00169 <span class="comment"> * \param link is the block that reads from the buffer using this gr_buffer_reader.</span>
<a name="l00170"></a>00170 <span class="comment"> */</span>
<a name="l00171"></a>00171 <a class="code" href="classboost_1_1shared__ptr.html">gr_buffer_reader_sptr</a> 
<a name="l00172"></a>00172 <a class="code" href="gr__buffer_8h.html#aa5e3f8c5b81a3b5395efb545e5b56613" title="Create a new gr_buffer_reader and attach it to buffer buf.">gr_buffer_add_reader</a> (<a class="code" href="classboost_1_1shared__ptr.html" title="shared_ptr documentation stub">gr_buffer_sptr</a> buf, <span class="keywordtype">int</span> nzero_preload, <a class="code" href="classboost_1_1shared__ptr.html">gr_block_sptr</a> <a class="code" href="classgr__buffer__reader.html#acd78edc8986ecdb3b78a3add8e2ebfde" title="Return the block that reads via this reader.">link</a>=<a class="code" href="classboost_1_1shared__ptr.html">gr_block_sptr</a>());
<a name="l00173"></a>00173 <span class="comment"></span>
<a name="l00174"></a>00174 <span class="comment">//! returns # of gr_buffers currently allocated</span>
<a name="l00175"></a>00175 <span class="comment"></span><span class="keywordtype">long</span> <a class="code" href="gr__buffer_8h.html#aa863a94ed8f87b2603df59e7b0eeed37" title="returns # of gr_buffers currently allocated">gr_buffer_ncurrently_allocated</a> ();
<a name="l00176"></a>00176 
<a name="l00177"></a>00177 
<a name="l00178"></a>00178 <span class="comment">// ---------------------------------------------------------------------------</span>
<a name="l00179"></a>00179 <span class="comment"></span>
<a name="l00180"></a>00180 <span class="comment">/*!</span>
<a name="l00181"></a>00181 <span class="comment"> * \brief How we keep track of the readers of a gr_buffer.</span>
<a name="l00182"></a>00182 <span class="comment"> * \ingroup internal</span>
<a name="l00183"></a>00183 <span class="comment"> */</span>
<a name="l00184"></a>00184 
<a name="l00185"></a><a class="code" href="classgr__buffer__reader.html">00185</a> <span class="keyword">class </span><a class="code" href="classgr__buffer__reader.html" title="How we keep track of the readers of a gr_buffer.">gr_buffer_reader</a> {
<a name="l00186"></a>00186  <span class="keyword">public</span>:
<a name="l00187"></a>00187 
<a name="l00188"></a><a class="code" href="classgr__buffer__reader.html#aa81c4b34f6e518e11cef52972a9a0c76">00188</a>   <span class="keyword">typedef</span> <a class="code" href="classgr__buffer.html#aff98726da27f70ef316640f925636260">gr_buffer::scoped_lock</a> <a class="code" href="classgr__buffer__reader.html#aa81c4b34f6e518e11cef52972a9a0c76">scoped_lock</a>;
<a name="l00189"></a>00189 
<a name="l00190"></a>00190   <a class="code" href="classgr__buffer__reader.html#a296f93185ddabe97c74ee2bfc1858194">~gr_buffer_reader</a> ();
<a name="l00191"></a>00191 <span class="comment"></span>
<a name="l00192"></a>00192 <span class="comment">  /*!</span>
<a name="l00193"></a>00193 <span class="comment">   * \brief Return number of items available for reading.</span>
<a name="l00194"></a>00194 <span class="comment">   */</span>
<a name="l00195"></a>00195   <span class="keywordtype">int</span> <a class="code" href="classgr__buffer__reader.html#a1ef86082ac536ac95ec469f27d99d6a0" title="Return number of items available for reading.">items_available</a> () <span class="keyword">const</span>;
<a name="l00196"></a>00196 <span class="comment"></span>
<a name="l00197"></a>00197 <span class="comment">  /*!</span>
<a name="l00198"></a>00198 <span class="comment">   * \brief Return buffer this reader reads from.</span>
<a name="l00199"></a>00199 <span class="comment">   */</span>
<a name="l00200"></a><a class="code" href="classgr__buffer__reader.html#aa1f9fc3b86fea8da9cfdb6f693b0d8b1">00200</a>   <a class="code" href="classboost_1_1shared__ptr.html" title="shared_ptr documentation stub">gr_buffer_sptr</a> <a class="code" href="classgr__buffer__reader.html#aa1f9fc3b86fea8da9cfdb6f693b0d8b1" title="Return buffer this reader reads from.">buffer</a> ()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> d_buffer; }
<a name="l00201"></a>00201 
<a name="l00202"></a>00202 <span class="comment"></span>
<a name="l00203"></a>00203 <span class="comment">  /*!</span>
<a name="l00204"></a>00204 <span class="comment">   * \brief Return maximum number of items that could ever be available for reading.</span>
<a name="l00205"></a>00205 <span class="comment">   * This is used as a sanity check in the scheduler to avoid looping forever.</span>
<a name="l00206"></a>00206 <span class="comment">   */</span>
<a name="l00207"></a><a class="code" href="classgr__buffer__reader.html#a87ef46cf000ef6168115b8b06cfd0ce8">00207</a>   <span class="keywordtype">int</span> <a class="code" href="classgr__buffer__reader.html#a87ef46cf000ef6168115b8b06cfd0ce8" title="Return maximum number of items that could ever be available for reading. This is used as a sanity che...">max_possible_items_available</a> ()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> d_buffer-&gt;d_bufsize - 1; }
<a name="l00208"></a>00208 <span class="comment"></span>
<a name="l00209"></a>00209 <span class="comment">  /*!</span>
<a name="l00210"></a>00210 <span class="comment">   * \brief return pointer to read buffer.</span>
<a name="l00211"></a>00211 <span class="comment">   *</span>
<a name="l00212"></a>00212 <span class="comment">   * The return value points to items_available() number of items</span>
<a name="l00213"></a>00213 <span class="comment">   */</span>
<a name="l00214"></a>00214   <span class="keyword">const</span> <span class="keywordtype">void</span> *<a class="code" href="classgr__buffer__reader.html#aa0a07401b38ed900cb53e72193233ddf" title="return pointer to read buffer.">read_pointer</a> ();
<a name="l00215"></a>00215 
<a name="l00216"></a>00216   <span class="comment">/*</span>
<a name="l00217"></a>00217 <span class="comment">   * \brief tell buffer we read \p items from it</span>
<a name="l00218"></a>00218 <span class="comment">   */</span>
<a name="l00219"></a>00219   <span class="keywordtype">void</span> <a class="code" href="classgr__buffer__reader.html#a6a8e969300be7ffa49811109f27005c4">update_read_pointer</a> (<span class="keywordtype">int</span> nitems);
<a name="l00220"></a>00220 
<a name="l00221"></a><a class="code" href="classgr__buffer__reader.html#a8b550f828745a575387ead9701174665">00221</a>   <span class="keywordtype">void</span> <a class="code" href="classgr__buffer__reader.html#a8b550f828745a575387ead9701174665">set_done</a> (<span class="keywordtype">bool</span> <a class="code" href="classgr__buffer__reader.html#a1b0037b814e8576b279fe307c47dd5a5">done</a>)   { d_buffer-&gt;set_done (done); }
<a name="l00222"></a><a class="code" href="classgr__buffer__reader.html#a1b0037b814e8576b279fe307c47dd5a5">00222</a>   <span class="keywordtype">bool</span> <a class="code" href="classgr__buffer__reader.html#a1b0037b814e8576b279fe307c47dd5a5">done</a> ()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> d_buffer-&gt;done (); }
<a name="l00223"></a>00223 
<a name="l00224"></a><a class="code" href="classgr__buffer__reader.html#a789fe0fe9eb7968ab971d848452f3d5c">00224</a>   boost::mutex *<a class="code" href="classgr__buffer__reader.html#a789fe0fe9eb7968ab971d848452f3d5c">mutex</a>() { <span class="keywordflow">return</span> d_buffer-&gt;mutex(); }
<a name="l00225"></a>00225 
<a name="l00226"></a>00226 <span class="comment"></span>
<a name="l00227"></a>00227 <span class="comment">  /*!</span>
<a name="l00228"></a>00228 <span class="comment">   * \brief Return the block that reads via this reader.</span>
<a name="l00229"></a>00229 <span class="comment">   */</span>
<a name="l00230"></a><a class="code" href="classgr__buffer__reader.html#acd78edc8986ecdb3b78a3add8e2ebfde">00230</a>   <a class="code" href="classboost_1_1shared__ptr.html">gr_block_sptr</a> <a class="code" href="classgr__buffer__reader.html#acd78edc8986ecdb3b78a3add8e2ebfde" title="Return the block that reads via this reader.">link</a>() { <span class="keywordflow">return</span> <a class="code" href="classboost_1_1shared__ptr.html">gr_block_sptr</a>(d_link); }
<a name="l00231"></a>00231 
<a name="l00232"></a>00232   <span class="comment">// -------------------------------------------------------------------------</span>
<a name="l00233"></a>00233 
<a name="l00234"></a>00234  <span class="keyword">private</span>:
<a name="l00235"></a>00235 
<a name="l00236"></a><a class="code" href="classgr__buffer__reader.html#a25dff068f5cfde18c4307b4973f4db9d">00236</a>   <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="classgr__buffer.html" title="Single writer, multiple reader fifo.">gr_buffer</a>;
<a name="l00237"></a>00237   <span class="keyword">friend</span> <a class="code" href="classboost_1_1shared__ptr.html">gr_buffer_reader_sptr</a> 
<a name="l00238"></a>00238   <a class="code" href="classgr__buffer__reader.html#afb5b9797c2e10e7f5d456643d3b420cb" title="Create a new gr_buffer_reader and attach it to buffer buf.">gr_buffer_add_reader</a> (<a class="code" href="classboost_1_1shared__ptr.html" title="shared_ptr documentation stub">gr_buffer_sptr</a> buf, <span class="keywordtype">int</span> nzero_preload, <a class="code" href="classboost_1_1shared__ptr.html">gr_block_sptr</a> <a class="code" href="classgr__buffer__reader.html#acd78edc8986ecdb3b78a3add8e2ebfde" title="Return the block that reads via this reader.">link</a>);
<a name="l00239"></a>00239 
<a name="l00240"></a>00240 
<a name="l00241"></a>00241   <a class="code" href="classboost_1_1shared__ptr.html" title="shared_ptr documentation stub">gr_buffer_sptr</a>                d_buffer;
<a name="l00242"></a>00242   <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>                  d_read_index;   <span class="comment">// in items [0,d-&gt;buffer.d_bufsize)</span>
<a name="l00243"></a>00243   boost::weak_ptr&lt;gr_block&gt;     d_link;         <span class="comment">// block that reads via this buffer reader</span>
<a name="l00244"></a>00244 <span class="comment"></span>
<a name="l00245"></a>00245 <span class="comment">  //! constructor is private.  Use gr_buffer::add_reader to create instances</span>
<a name="l00246"></a>00246 <span class="comment"></span>  <a class="code" href="classgr__buffer.html#a7ecfad759b1fdf2dcb7416a16f563482">gr_buffer_reader</a> (<a class="code" href="classboost_1_1shared__ptr.html" title="shared_ptr documentation stub">gr_buffer_sptr</a> <a class="code" href="classgr__buffer__reader.html#aa1f9fc3b86fea8da9cfdb6f693b0d8b1" title="Return buffer this reader reads from.">buffer</a>, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> read_index, <a class="code" href="classboost_1_1shared__ptr.html">gr_block_sptr</a> <a class="code" href="classgr__buffer__reader.html#acd78edc8986ecdb3b78a3add8e2ebfde" title="Return the block that reads via this reader.">link</a>);
<a name="l00247"></a>00247 };
<a name="l00248"></a>00248 <span class="comment"></span>
<a name="l00249"></a>00249 <span class="comment">//! returns # of gr_buffer_readers currently allocated</span>
<a name="l00250"></a>00250 <span class="comment"></span><span class="keywordtype">long</span> <a class="code" href="gr__buffer_8h.html#a229e8245902aa53c7fe9644c2fc6f3a9" title="returns # of gr_buffer_readers currently allocated">gr_buffer_reader_ncurrently_allocated</a> ();
<a name="l00251"></a>00251 
<a name="l00252"></a>00252 
<a name="l00253"></a>00253 <span class="preprocessor">#endif </span><span class="comment">/* INCLUDED_GR_BUFFER_H */</span>
</pre></div></div>
</div>
  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><a class="el" href="gr__buffer_8h.html">gr_buffer.h</a>      </li>
      <li class="footer">Generated on Thu Feb 17 2011 for GNU Radio 3.2.2 C++ API by&#160;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.3 </li>
    </ul>
  </div>

</body>
</html>