Sophie

Sophie

distrib > Mandriva > 8.2 > i586 > media > contrib > by-pkgid > 68d373e54fb21da3730c08bede406633 > files > 490

libCommonC++1.9_3-devel-1.9.4-2mdk.i586.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>ost::Buffer class Reference</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body bgcolor="#ffffff">
<!-- Generated by Doxygen 1.2.10 -->
<center>
<a class="qindex" href="index.html">Main Page</a> &nbsp; <a class="qindex" href="namespaces.html">Namespace List</a> &nbsp; <a class="qindex" href="hierarchy.html">Class Hierarchy</a> &nbsp; <a class="qindex" href="classes.html">Alphabetical List</a> &nbsp; <a class="qindex" href="annotated.html">Compound List</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="namespacemembers.html">Namespace Members</a> &nbsp; <a class="qindex" href="functions.html">Compound Members</a> &nbsp; <a class="qindex" href="globals.html">File Members</a> &nbsp; </center>
<hr><h1>ost::Buffer  Class Reference</h1>The buffer class represents an IPC service that is built upon a buffer of fixed capacity that can be used to transfer objects between one or more producer and consumer threads. Producer/Consumer buffer for use between threads. 
<a href="#_details">More...</a>
<p>
<code>#include &lt;<a class="el" href="thread_8h-source.html">thread.h</a>&gt;</code>
<p>
<p>Inheritance diagram for ost::Buffer::
<p><center><img src="classost_1_1_buffer.gif" usemap="#ost::Buffer_map" border="0"></center>
<map name="ost::Buffer_map">
<area href="classost_1_1_fixed_buffer.html" alt="ost::FixedBuffer" shape="rect" coords="0,56,100,80">
</map>
<a href="classost_1_1_buffer-members.html">List of all members.</a><table border=0 cellpadding=0 cellspacing=0>
<tr><td colspan=2><br><h2>Public Methods</h2></td></tr>
<tr><td nowrap align=right valign=top>&nbsp;</td><td valign=bottom><a class="el" href="classost_1_1_buffer.html#a0">Buffer</a> (size_t capacity)</td></tr>
<tr><td>&nbsp;</td><td><font size=-1><em>Create a buffer object of known capacity.</em> <a href="#a0">More...</a><em></em></font><br><br></td></tr>
<tr><td nowrap align=right valign=top>virtual&nbsp;</td><td valign=bottom><a class="el" href="classost_1_1_buffer.html#a1">~Buffer</a> ()</td></tr>
<tr><td>&nbsp;</td><td><font size=-1><em>In derived functions, may be used to free the actual memory used to hold buffered data.</em> <a href="#a1">More...</a><em></em></font><br><br></td></tr>
<tr><td nowrap align=right valign=top>size_t&nbsp;</td><td valign=bottom><a class="el" href="classost_1_1_buffer.html#a2">getSize</a> (void)</td></tr>
<tr><td>&nbsp;</td><td><font size=-1><em>Return the capacity of the buffer as specified at creation.</em> <a href="#a2">More...</a><em></em></font><br><br></td></tr>
<tr><td nowrap align=right valign=top>size_t&nbsp;</td><td valign=bottom><a class="el" href="classost_1_1_buffer.html#a3">getUsed</a> (void)</td></tr>
<tr><td>&nbsp;</td><td><font size=-1><em>Return the current capacity in use for the buffer.</em> <a href="#a3">More...</a><em></em></font><br><br></td></tr>
<tr><td nowrap align=right valign=top>int&nbsp;</td><td valign=bottom><a class="el" href="classost_1_1_buffer.html#a4">Wait</a> (void *buf)</td></tr>
<tr><td>&nbsp;</td><td><font size=-1><em>Let one or more threads wait for an object to become available in the buffer.</em> <a href="#a4">More...</a><em></em></font><br><br></td></tr>
<tr><td nowrap align=right valign=top>int&nbsp;</td><td valign=bottom><a class="el" href="classost_1_1_buffer.html#a5">Post</a> (void *buf)</td></tr>
<tr><td>&nbsp;</td><td><font size=-1><em>Post an object into the buffer and enable a waiting thread to receive it.</em> <a href="#a5">More...</a><em></em></font><br><br></td></tr>
<tr><td nowrap align=right valign=top>int&nbsp;</td><td valign=bottom><a class="el" href="classost_1_1_buffer.html#a6">Peek</a> (void *buf)</td></tr>
<tr><td>&nbsp;</td><td><font size=-1><em>Peek at the current content (first object) in the buffer.</em> <a href="#a6">More...</a><em></em></font><br><br></td></tr>
<tr><td nowrap align=right valign=top>virtual bool&nbsp;</td><td valign=bottom><a class="el" href="classost_1_1_buffer.html#a7">isValid</a> (void)</td></tr>
<tr><td>&nbsp;</td><td><font size=-1><em>New virtual to test if buffer is a valid object.</em> <a href="#a7">More...</a><em></em></font><br><br></td></tr>
<tr><td colspan=2><br><h2>Protected Methods</h2></td></tr>
<tr><td nowrap align=right valign=top>virtual int&nbsp;</td><td valign=bottom><a class="el" href="classost_1_1_buffer.html#b0">OnPeek</a> (void *buf)=0</td></tr>
<tr><td>&nbsp;</td><td><font size=-1><em>Invoke derived class buffer peeking method.</em> <a href="#b0">More...</a><em></em></font><br><br></td></tr>
<tr><td nowrap align=right valign=top>virtual int&nbsp;</td><td valign=bottom><a class="el" href="classost_1_1_buffer.html#b1">OnWait</a> (void *buf)=0</td></tr>
<tr><td>&nbsp;</td><td><font size=-1><em>Invoke derived class object request from buffer.</em> <a href="#b1">More...</a><em></em></font><br><br></td></tr>
<tr><td nowrap align=right valign=top>virtual int&nbsp;</td><td valign=bottom><a class="el" href="classost_1_1_buffer.html#b2">OnPost</a> (void *buf)=0</td></tr>
<tr><td>&nbsp;</td><td><font size=-1><em>Invoke derived class posting of object to buffer.</em> <a href="#b2">More...</a><em></em></font><br><br></td></tr>
</table>
<hr><a name="_details"></a><h2>Detailed Description</h2>
The buffer class represents an IPC service that is built upon a buffer of fixed capacity that can be used to transfer objects between one or more producer and consumer threads. Producer/Consumer buffer for use between threads.
<p>
Producer threads post objects into the buffer, and consumer threads wait for and receive objects from the buffer. Semaphores are used to to block the buffer from overflowing and indicate when there is data available, and mutexes are used to protect multiple consumers and producer threads from stepping over each other.
<p>
The buffer class is an abstract class in that the actual data being buffered is not directly specified within the buffer class itself. The buffer class should be used as a base class for a class that actually impliments buffering and which may be aware of the data types actually are being buffered. A template class could be created based on buffer for this purpose. Another possibility is to create a class derived from both <a class="el" href="classost_1_1_thread.html">Thread</a> and <a class="el" href="classost_1_1_buffer.html">Buffer</a> which can be used to implement message passing threads.
<p>
<dl compact><dt><b>
Author: </b><dd>
David Sugar &lt;<a href="mailto:dyfet@ostel.com">dyfet@ostel.com</a>&gt; </dl>
<p>
<hr><h2>Constructor &amp; Destructor Documentation</h2>
<a name="a0" doxytag="ost::Buffer::Buffer"></a><p>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
  <tr>
    <td class="md">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> ost::Buffer::Buffer </td>
          <td class="md">(&nbsp;</td>
          <td class="md">size_t</td>
          <td class="mdname1">&nbsp; <em>capacity</em>          </td>
          <td class="md">)&nbsp;</td>
          <td class="md"></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Create a buffer object of known capacity.
<p>
<dl compact><dt><b>
Parameters: </b><dd>
<table border=0 cellspacing=2 cellpadding=0>
<tr><td valign=top><em>capcity
</em>&nbsp;</td><td>
is the integer capacity of the buffer. </td></tr>
</table>
</dl>    </td>
  </tr>
</table>
<a name="a1" doxytag="ost::Buffer::~Buffer"></a><p>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
  <tr>
    <td class="md">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> virtual ost::Buffer::~Buffer </td>
          <td class="md">(&nbsp;</td>
          <td class="mdname1">&nbsp;          </td>
          <td class="md">)&nbsp;</td>
          <td class="md"><code> [inline, virtual]</code></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
In derived functions, may be used to free the actual memory used to hold buffered data.
<p>
    </td>
  </tr>
</table>
<hr><h2>Member Function Documentation</h2>
<a name="b0" doxytag="ost::Buffer::OnPeek"></a><p>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
  <tr>
    <td class="md">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> virtual int ost::Buffer::OnPeek </td>
          <td class="md">(&nbsp;</td>
          <td class="md">void *</td>
          <td class="mdname1">&nbsp; <em>buf</em>          </td>
          <td class="md">)&nbsp;</td>
          <td class="md"><code> [protected, pure virtual]</code></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Invoke derived class buffer peeking method.
<p>
<dl compact><dt><b>
Returns: </b><dd>
size of object found. </dl><dl compact><dt><b>
Parameters: </b><dd>
<table border=0 cellspacing=2 cellpadding=0>
<tr><td valign=top><em>buf
</em>&nbsp;</td><td>
pointer to copy contents of head of buffer to. </td></tr>
</table>
</dl>
<p>
Reimplemented in <a class="el" href="classost_1_1_fixed_buffer.html#b0">ost::FixedBuffer</a>.    </td>
  </tr>
</table>
<a name="b2" doxytag="ost::Buffer::OnPost"></a><p>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
  <tr>
    <td class="md">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> virtual int ost::Buffer::OnPost </td>
          <td class="md">(&nbsp;</td>
          <td class="md">void *</td>
          <td class="mdname1">&nbsp; <em>buf</em>          </td>
          <td class="md">)&nbsp;</td>
          <td class="md"><code> [protected, pure virtual]</code></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Invoke derived class posting of object to buffer.
<p>
<dl compact><dt><b>
Returns: </b><dd>
size of object posted. </dl><dl compact><dt><b>
Parameters: </b><dd>
<table border=0 cellspacing=2 cellpadding=0>
<tr><td valign=top><em>buf
</em>&nbsp;</td><td>
pointer to object being posted to the buffer. </td></tr>
</table>
</dl>
<p>
Reimplemented in <a class="el" href="classost_1_1_fixed_buffer.html#b2">ost::FixedBuffer</a>.    </td>
  </tr>
</table>
<a name="b1" doxytag="ost::Buffer::OnWait"></a><p>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
  <tr>
    <td class="md">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> virtual int ost::Buffer::OnWait </td>
          <td class="md">(&nbsp;</td>
          <td class="md">void *</td>
          <td class="mdname1">&nbsp; <em>buf</em>          </td>
          <td class="md">)&nbsp;</td>
          <td class="md"><code> [protected, pure virtual]</code></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Invoke derived class object request from buffer.
<p>
<dl compact><dt><b>
Returns: </b><dd>
size of object returned. </dl><dl compact><dt><b>
Parameters: </b><dd>
<table border=0 cellspacing=2 cellpadding=0>
<tr><td valign=top><em>buf
</em>&nbsp;</td><td>
pointer to hold object returned from the buffer. </td></tr>
</table>
</dl>
<p>
Reimplemented in <a class="el" href="classost_1_1_fixed_buffer.html#b1">ost::FixedBuffer</a>.    </td>
  </tr>
</table>
<a name="a6" doxytag="ost::Buffer::Peek"></a><p>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
  <tr>
    <td class="md">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> int ost::Buffer::Peek </td>
          <td class="md">(&nbsp;</td>
          <td class="md">void *</td>
          <td class="mdname1">&nbsp; <em>buf</em>          </td>
          <td class="md">)&nbsp;</td>
          <td class="md"></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Peek at the current content (first object) in the buffer.
<p>
<dl compact><dt><b>
Returns: </b><dd>
size of object in the buffer. </dl><dl compact><dt><b>
Parameters: </b><dd>
<table border=0 cellspacing=2 cellpadding=0>
<tr><td valign=top><em>buf
</em>&nbsp;</td><td>
pointer to store object found in the buffer. </td></tr>
</table>
</dl>    </td>
  </tr>
</table>
<a name="a5" doxytag="ost::Buffer::Post"></a><p>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
  <tr>
    <td class="md">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> int ost::Buffer::Post </td>
          <td class="md">(&nbsp;</td>
          <td class="md">void *</td>
          <td class="mdname1">&nbsp; <em>buf</em>          </td>
          <td class="md">)&nbsp;</td>
          <td class="md"></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Post an object into the buffer and enable a waiting thread to receive it.
<p>
<dl compact><dt><b>
Returns: </b><dd>
size of object posted in bytes. </dl><dl compact><dt><b>
Parameters: </b><dd>
<table border=0 cellspacing=2 cellpadding=0>
<tr><td valign=top><em>buf
</em>&nbsp;</td><td>
pointer to object to store in the buffer. </td></tr>
</table>
</dl>    </td>
  </tr>
</table>
<a name="a4" doxytag="ost::Buffer::Wait"></a><p>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
  <tr>
    <td class="md">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> int ost::Buffer::Wait </td>
          <td class="md">(&nbsp;</td>
          <td class="md">void *</td>
          <td class="mdname1">&nbsp; <em>buf</em>          </td>
          <td class="md">)&nbsp;</td>
          <td class="md"></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Let one or more threads wait for an object to become available in the buffer.
<p>
The waiting thread(s) will wait forever if no object is ever placed into the buffer.
<p>
<dl compact><dt><b>
Returns: </b><dd>
size of object passed by buffer in bytes. </dl><dl compact><dt><b>
Parameters: </b><dd>
<table border=0 cellspacing=2 cellpadding=0>
<tr><td valign=top><em>buf
</em>&nbsp;</td><td>
pointer to store object retrieved from the buffer. </td></tr>
</table>
</dl>    </td>
  </tr>
</table>
<a name="a2" doxytag="ost::Buffer::getSize"></a><p>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
  <tr>
    <td class="md">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> size_t ost::Buffer::getSize </td>
          <td class="md">(&nbsp;</td>
          <td class="md">void</td>
          <td class="mdname1">&nbsp;          </td>
          <td class="md">)&nbsp;</td>
          <td class="md"><code> [inline]</code></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Return the capacity of the buffer as specified at creation.
<p>
<dl compact><dt><b>
Returns: </b><dd>
size of buffer. </dl>    </td>
  </tr>
</table>
<a name="a3" doxytag="ost::Buffer::getUsed"></a><p>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
  <tr>
    <td class="md">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> size_t ost::Buffer::getUsed </td>
          <td class="md">(&nbsp;</td>
          <td class="md">void</td>
          <td class="mdname1">&nbsp;          </td>
          <td class="md">)&nbsp;</td>
          <td class="md"><code> [inline]</code></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Return the current capacity in use for the buffer.
<p>
Free space is technically <a class="el" href="classost_1_1_buffer.html#a2">getSize</a>() - <a class="el" href="classost_1_1_buffer.html#a3">getUsed</a>(). <dl compact><dt><b>
Returns: </b><dd>
integer used capacity of the buffer. </dl><dl compact><dt><b>
See also: </b><dd>
<a class="el" href="classost_1_1_buffer.html#a2">getSize</a> </dl>    </td>
  </tr>
</table>
<a name="a7" doxytag="ost::Buffer::isValid"></a><p>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
  <tr>
    <td class="md">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> virtual bool ost::Buffer::isValid </td>
          <td class="md">(&nbsp;</td>
          <td class="md">void</td>
          <td class="mdname1">&nbsp;          </td>
          <td class="md">)&nbsp;</td>
          <td class="md"><code> [inline, virtual]</code></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
New virtual to test if buffer is a valid object.
<p>
<dl compact><dt><b>
Returns: </b><dd>
true if object is valid. </dl>
<p>
Reimplemented in <a class="el" href="classost_1_1_fixed_buffer.html#a4">ost::FixedBuffer</a>.    </td>
  </tr>
</table>
<hr>The documentation for this class was generated from the following file:<ul>
<li><a class="el" href="thread_8h-source.html">thread.h</a></ul>
<hr><address><small>Generated at Fri Jan 4 18:51:47 2002 for CommonC++ by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.gif" alt="doxygen" align="middle" border=0 
width=110 height=53></a>1.2.10 written by <a href="mailto:dimitri@stack.nl">Dimitri van Heesch</a>,
 &copy;&nbsp;1997-2001</small></address>
</body>
</html>