Sophie

Sophie

distrib > Mandriva > 2007.0 > i586 > by-pkgid > ad1ba1135a9c9eeffc2e538163e00373 > files > 221

libCommonC++2_1.4-devel-1.4.1-1mdv2007.0.i586.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>GNU CommonC++: ost::MemPager Class Reference</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.4.6 -->
<div class="tabs">
  <ul>
    <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
    <li><a href="namespaces.html"><span>Namespaces</span></a></li>
    <li id="current"><a href="classes.html"><span>Classes</span></a></li>
    <li><a href="files.html"><span>Files</span></a></li>
    <li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
    <li><a href="examples.html"><span>Examples</span></a></li>
  </ul></div>
<div class="tabs">
  <ul>
    <li><a href="classes.html"><span>Alphabetical&nbsp;List</span></a></li>
    <li><a href="annotated.html"><span>Class&nbsp;List</span></a></li>
    <li><a href="hierarchy.html"><span>Class&nbsp;Hierarchy</span></a></li>
    <li><a href="functions.html"><span>Class&nbsp;Members</span></a></li>
  </ul></div>
<div class="nav">
<a class="el" href="namespaceost.html">ost</a>::<a class="el" href="classost_1_1_mem_pager.html">MemPager</a></div>
<h1>ost::MemPager Class Reference</h1><!-- doxytag: class="ost::MemPager" -->The memory pager is used to allocate cumulative memory pages for storing object specific "persistant" data that is presumed to persist during the life of a given derived object.Accumulative object memory allocator.  
<a href="#_details">More...</a>
<p>
<code>#include &lt;<a class="el" href="misc_8h-source.html">misc.h</a>&gt;</code>
<p>
<p>Inheritance diagram for ost::MemPager:
<p><center><img src="classost_1_1_mem_pager.png" usemap="#ost::MemPager_map" border="0" alt=""></center>
<map name="ost::MemPager_map">
<area href="classost_1_1_keydata.html" alt="ost::Keydata" shape="rect" coords="0,56,136,80">
<area href="classost_1_1_shared_mem_pager.html" alt="ost::SharedMemPager" shape="rect" coords="146,56,282,80">
<area href="classost_1_1_stack_pager.html" alt="ost::StackPager" shape="rect" coords="292,56,428,80">
</map>
<a href="classost_1_1_mem_pager-members.html">List of all members.</a><table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classost_1_1_mem_pager.html#320897ecfca3e92378c45ec70aee58ba">getPages</a> (void)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Return the total number of pages that have been allocated for this memory pool.  <a href="#320897ecfca3e92378c45ec70aee58ba"></a><br></td></tr>
<tr><td colspan="2"><br><h2>Protected Member Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">virtual void *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classost_1_1_mem_pager.html#2c82ac4c97fcba81c643966973e78d84">first</a> (size_t size)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Allocate first workspace from paged memory.  <a href="#2c82ac4c97fcba81c643966973e78d84"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">virtual void *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classost_1_1_mem_pager.html#3a03cb50bd4084ddbf6314ec0339d176">alloc</a> (size_t size)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Allocate memory from either the currently active page, or allocate a new page for the object.  <a href="#3a03cb50bd4084ddbf6314ec0339d176"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">char *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classost_1_1_mem_pager.html#7ea4e6f82bffa66c994fcd10ebdee594">first</a> (char *str)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Allocate a string from the memory pager pool and copy the string into it's new memory area.  <a href="#7ea4e6f82bffa66c994fcd10ebdee594"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">char *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classost_1_1_mem_pager.html#245b6c4181ccccbabc52f1c3451f2fb6">alloc</a> (const char *str)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Allocate a string from the memory pager pool and copy the string inti it's new memory area.  <a href="#245b6c4181ccccbabc52f1c3451f2fb6"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classost_1_1_mem_pager.html#5dc37c26af34d6f4c26e125eded3e2be">MemPager</a> (size_t pagesize=4096)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Create a paged memory pool for cumulative storage.  <a href="#5dc37c26af34d6f4c26e125eded3e2be"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classost_1_1_mem_pager.html#5bfdb6f2d6f569ba08c32c59efb3a012">purge</a> (void)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">purge the current memory pool.  <a href="#5bfdb6f2d6f569ba08c32c59efb3a012"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">virtual&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classost_1_1_mem_pager.html#58dcf48146eca4ae2286706968fdf9c5">~MemPager</a> ()</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Delete the memory pool and all allocated memory.  <a href="#58dcf48146eca4ae2286706968fdf9c5"></a><br></td></tr>
<tr><td colspan="2"><br><h2>Friends</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">class&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classost_1_1_mem_pager.html#7fb804f7dc96dd9f705c84095f37f1ca">String</a></td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">class&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classost_1_1_mem_pager.html#c5ec8bc6fca4e4e6a8faa45d4b0a9d58">MemPagerObject</a></td></tr>

<tr><td colspan="2"><br><h2>Classes</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">struct &nbsp;</td><td class="memItemRight" valign="bottom"><b>_page</b></td></tr>

</table>
<hr><a name="_details"></a><h2>Detailed Description</h2>
The memory pager is used to allocate cumulative memory pages for storing object specific "persistant" data that is presumed to persist during the life of a given derived object.Accumulative object memory allocator. 
<p>
When the object is destroyed, all accumulated data is automatically purged.<p>
There are a number of odd and specialized utility classes found in Common C++. The most common of these is the "MemPager" class. This is basically a class to enable page-grouped "cumulative" memory allocation; all accumulated allocations are dropped during the destructor. This class has found it's way in a lot of other utility classes in Common C++.<p>
<dl compact><dt><b>Author:</b></dt><dd>David Sugar &lt;<a href="mailto:dyfet@ostel.com">dyfet@ostel.com</a>&gt; </dd></dl>

<p>
<hr><h2>Constructor &amp; Destructor Documentation</h2>
<a class="anchor" name="5dc37c26af34d6f4c26e125eded3e2be"></a><!-- doxytag: member="ost::MemPager::MemPager" ref="5dc37c26af34d6f4c26e125eded3e2be" args="(size_t pagesize=4096)" --><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top">ost::MemPager::MemPager           </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">size_t&nbsp;</td>
          <td class="mdname1" valign="top" nowrap> <em>pagesize</em> = <code>4096</code>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap><code> [protected]</code></td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Create a paged memory pool for cumulative storage. 
<p>
This pool allocates memory in fixed "pagesize" chunks. Ideal performance is achived when the pool size matches the system page size. This pool can only exist in derived objects.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>pagesize</em>&nbsp;</td><td>page size to allocate chunks. </td></tr>
  </table>
</dl>
    </td>
  </tr>
</table>
<a class="anchor" name="58dcf48146eca4ae2286706968fdf9c5"></a><!-- doxytag: member="ost::MemPager::~MemPager" ref="58dcf48146eca4ae2286706968fdf9c5" args="()" --><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top">virtual ost::MemPager::~MemPager           </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="mdname1" valign="top" nowrap>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap><code> [protected, virtual]</code></td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Delete the memory pool and all allocated memory. 
<p>
    </td>
  </tr>
</table>
<hr><h2>Member Function Documentation</h2>
<a class="anchor" name="245b6c4181ccccbabc52f1c3451f2fb6"></a><!-- doxytag: member="ost::MemPager::alloc" ref="245b6c4181ccccbabc52f1c3451f2fb6" args="(const char *str)" --><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top">char* ost::MemPager::alloc           </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">const char *&nbsp;</td>
          <td class="mdname1" valign="top" nowrap> <em>str</em>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap><code> [protected]</code></td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Allocate a string from the memory pager pool and copy the string inti it's new memory area. 
<p>
This checks only the last active page for available space before allocating a new page.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>str</em>&nbsp;</td><td>string to allocate and copy into paged memory pool. </td></tr>
  </table>
</dl>
<dl compact><dt><b>Returns:</b></dt><dd>copy of string from allocated memory. </dd></dl>
    </td>
  </tr>
</table>
<a class="anchor" name="3a03cb50bd4084ddbf6314ec0339d176"></a><!-- doxytag: member="ost::MemPager::alloc" ref="3a03cb50bd4084ddbf6314ec0339d176" args="(size_t size)" --><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top">virtual void* ost::MemPager::alloc           </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">size_t&nbsp;</td>
          <td class="mdname1" valign="top" nowrap> <em>size</em>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap><code> [protected, virtual]</code></td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Allocate memory from either the currently active page, or allocate a new page for the object. 
<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>size</em>&nbsp;</td><td>size of memory to allocate. </td></tr>
  </table>
</dl>
<dl compact><dt><b>Returns:</b></dt><dd>pointer to allocated memory. </dd></dl>

<p>
Reimplemented in <a class="el" href="classost_1_1_shared_mem_pager.html#d5c3aad294fd247a972a72983dcf831b">ost::SharedMemPager</a>.    </td>
  </tr>
</table>
<a class="anchor" name="7ea4e6f82bffa66c994fcd10ebdee594"></a><!-- doxytag: member="ost::MemPager::first" ref="7ea4e6f82bffa66c994fcd10ebdee594" args="(char *str)" --><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top">char* ost::MemPager::first           </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">char *&nbsp;</td>
          <td class="mdname1" valign="top" nowrap> <em>str</em>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap><code> [protected]</code></td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Allocate a string from the memory pager pool and copy the string into it's new memory area. 
<p>
This method allocates memory by first searching for an available page, and then allocating a new page if no space is found.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>str</em>&nbsp;</td><td>string to allocate and copy into paged memory pool. </td></tr>
  </table>
</dl>
<dl compact><dt><b>Returns:</b></dt><dd>copy of string from allocated memory. </dd></dl>
    </td>
  </tr>
</table>
<a class="anchor" name="2c82ac4c97fcba81c643966973e78d84"></a><!-- doxytag: member="ost::MemPager::first" ref="2c82ac4c97fcba81c643966973e78d84" args="(size_t size)" --><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top">virtual void* ost::MemPager::first           </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">size_t&nbsp;</td>
          <td class="mdname1" valign="top" nowrap> <em>size</em>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap><code> [protected, virtual]</code></td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Allocate first workspace from paged memory. 
<p>
This method scans all currently allocated blocks for available space before adding new pages and hence is both slower and more efficient.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>size</em>&nbsp;</td><td>size of memory to allocate. </td></tr>
  </table>
</dl>
<dl compact><dt><b>Returns:</b></dt><dd>pointer to allocated memory. </dd></dl>

<p>
Reimplemented in <a class="el" href="classost_1_1_shared_mem_pager.html#644a00d48052aff83a180523b205aa6f">ost::SharedMemPager</a>.    </td>
  </tr>
</table>
<a class="anchor" name="320897ecfca3e92378c45ec70aee58ba"></a><!-- doxytag: member="ost::MemPager::getPages" ref="320897ecfca3e92378c45ec70aee58ba" args="(void)" --><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top">int ost::MemPager::getPages           </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">void&nbsp;</td>
          <td class="mdname1" valign="top" nowrap>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap><code> [inline]</code></td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Return the total number of pages that have been allocated for this memory pool. 
<p>
<dl compact><dt><b>Returns:</b></dt><dd>number of pages allocated. </dd></dl>
    </td>
  </tr>
</table>
<a class="anchor" name="5bfdb6f2d6f569ba08c32c59efb3a012"></a><!-- doxytag: member="ost::MemPager::purge" ref="5bfdb6f2d6f569ba08c32c59efb3a012" args="(void)" --><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top">void ost::MemPager::purge           </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">void&nbsp;</td>
          <td class="mdname1" valign="top" nowrap>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap><code> [protected]</code></td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
purge the current memory pool. 
<p>

<p>
Reimplemented in <a class="el" href="classost_1_1_stack_pager.html#c903c181770651ee8f42717892dd9fa4">ost::StackPager</a>, and <a class="el" href="classost_1_1_shared_mem_pager.html#fafb0b8ce31a2b1fdee64a5a9cadebc6">ost::SharedMemPager</a>.    </td>
  </tr>
</table>
<hr><h2>Friends And Related Function Documentation</h2>
<a class="anchor" name="c5ec8bc6fca4e4e6a8faa45d4b0a9d58"></a><!-- doxytag: member="ost::MemPager::MemPagerObject" ref="c5ec8bc6fca4e4e6a8faa45d4b0a9d58" args="" --><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top">friend class <a class="el" href="classost_1_1_mem_pager_object.html">MemPagerObject</a><code> [friend]</code>          </td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
    </td>
  </tr>
</table>
<a class="anchor" name="7fb804f7dc96dd9f705c84095f37f1ca"></a><!-- doxytag: member="ost::MemPager::String" ref="7fb804f7dc96dd9f705c84095f37f1ca" args="" --><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top">friend class <a class="el" href="classost_1_1_string.html">String</a><code> [friend]</code>          </td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
    </td>
  </tr>
</table>
<hr>The documentation for this class was generated from the following file:<ul>
<li><a class="el" href="misc_8h-source.html">misc.h</a></ul>
<hr size="1"><address style="align: right;"><small>Generated on Mon Jun 19 10:50:56 2006 for GNU CommonC++ by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.6 </small></address>
</body>
</html>