<!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>MemPager 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> <a class="qindex" href="namespaces.html">Namespace List</a> <a class="qindex" href="hierarchy.html">Class Hierarchy</a> <a class="qindex" href="classes.html">Alphabetical List</a> <a class="qindex" href="annotated.html">Compound List</a> <a class="qindex" href="files.html">File List</a> <a class="qindex" href="namespacemembers.html">Namespace Members</a> <a class="qindex" href="functions.html">Compound Members</a> <a class="qindex" href="globals.html">File Members</a> </center> <hr><h1>MemPager Class Reference</h1>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 <<a class="el" href="misc_8h-source.html">misc.h</a>></code> <p> <p>Inheritance diagram for MemPager:: <p><center><img src="class_mem_pager.gif" usemap="#MemPager_map" border="0"></center> <map name="MemPager_map"> <area href="class_keydata.html" alt="Keydata" shape="rect" coords="0,56,114,80"> <area href="class_shared_mem_pager.html" alt="SharedMemPager" shape="rect" coords="124,56,238,80"> </map> <a href="class_mem_pager-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>int </td><td valign=bottom><a class="el" href="class_mem_pager.html#a0">getPages</a> (void)</td></tr> <tr><td> </td><td><font size=-1><em>Return the total number of pages that have been allocated for this memory pool.</em> <a href="#a0">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 void * </td><td valign=bottom><a class="el" href="class_mem_pager.html#b0">first</a> (size_t size)</td></tr> <tr><td> </td><td><font size=-1><em>Allocate first workspace from paged memory.</em> <a href="#b0">More...</a><em></em></font><br><br></td></tr> <tr><td nowrap align=right valign=top>virtual void * </td><td valign=bottom><a class="el" href="class_mem_pager.html#b1">alloc</a> (size_t size)</td></tr> <tr><td> </td><td><font size=-1><em>Allocate memory from either the currently active page, or allocate a new page for the object.</em> <a href="#b1">More...</a><em></em></font><br><br></td></tr> <tr><td nowrap align=right valign=top>char * </td><td valign=bottom><a class="el" href="class_mem_pager.html#b2">first</a> (char *str)</td></tr> <tr><td> </td><td><font size=-1><em>Allocate a string from the memory pager pool and copy the string into it's new memory area.</em> <a href="#b2">More...</a><em></em></font><br><br></td></tr> <tr><td nowrap align=right valign=top>char * </td><td valign=bottom><a class="el" href="class_mem_pager.html#b3">alloc</a> (char *str)</td></tr> <tr><td> </td><td><font size=-1><em>Allocate a string from the memory pager pool and copy the string inti it's new memory area.</em> <a href="#b3">More...</a><em></em></font><br><br></td></tr> <tr><td nowrap align=right valign=top> </td><td valign=bottom><a class="el" href="class_mem_pager.html#b4">MemPager</a> (int pagesize=4096)</td></tr> <tr><td> </td><td><font size=-1><em>Create a paged memory pool for cumulative storage.</em> <a href="#b4">More...</a><em></em></font><br><br></td></tr> <tr><td nowrap align=right valign=top>void </td><td valign=bottom><a class="el" href="class_mem_pager.html#b5">purge</a> (void)</td></tr> <tr><td> </td><td><font size=-1><em>purge the current memory pool.</em> <a href="#b5">More...</a><em></em></font><br><br></td></tr> <tr><td nowrap align=right valign=top>virtual </td><td valign=bottom><a class="el" href="class_mem_pager.html#b6">~MemPager</a> ()</td></tr> <tr><td> </td><td><font size=-1><em>Delete the memory pool and all allocated memory.</em> <a href="#b6">More...</a><em></em></font><br><br></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><dd> David Sugar <<a href="mailto:dyfet@ostel.com">dyfet@ostel.com</a>> </dl> <p> <hr><h2>Constructor & Destructor Documentation</h2> <a name="b4" doxytag="MemPager::MemPager"></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"> MemPager::MemPager </td> <td class="md">( </td> <td class="md">int</td> <td class="mdname1"> <em>pagesize</em> = 4096 </td> <td class="md">) </td> <td class="md"><code> [protected]</code></td> </tr> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </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.<dl compact><dt><b> Parameters: </b><dd> <table border=0 cellspacing=2 cellpadding=0> <tr><td valign=top><em>pagesize </em> </td><td> to allocate chunks. </td></tr> </table> </dl> </td> </tr> </table> <a name="b6" doxytag="MemPager::~MemPager"></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 MemPager::~MemPager </td> <td class="md">( </td> <td class="mdname1"> </td> <td class="md">) </td> <td class="md"><code> [protected, virtual]</code></td> </tr> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> Delete the memory pool and all allocated memory. <p> </td> </tr> </table> <hr><h2>Member Function Documentation</h2> <a name="b3" doxytag="MemPager::alloc"></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"> char* MemPager::alloc </td> <td class="md">( </td> <td class="md">char *</td> <td class="mdname1"> <em>str</em> </td> <td class="md">) </td> <td class="md"><code> [protected]</code></td> </tr> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </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.<dl compact><dt><b> Parameters: </b><dd> <table border=0 cellspacing=2 cellpadding=0> <tr><td valign=top><em>str </em> </td><td> to allocate and copy into paged memory pool. </td></tr> </table> </dl><dl compact><dt><b> Returns: </b><dd> copy of string from allocated memory. </dl> </td> </tr> </table> <a name="b1" doxytag="MemPager::alloc"></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 void* MemPager::alloc </td> <td class="md">( </td> <td class="md">size_t</td> <td class="mdname1"> <em>size</em> </td> <td class="md">) </td> <td class="md"><code> [protected, virtual]</code></td> </tr> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </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><dd> <table border=0 cellspacing=2 cellpadding=0> <tr><td valign=top><em>size </em> </td><td> of memory to allocate. </td></tr> </table> </dl><dl compact><dt><b> Returns: </b><dd> pointer to allocated memory. </dl> <p> Reimplemented in <a class="el" href="class_shared_mem_pager.html#b3">SharedMemPager</a>. </td> </tr> </table> <a name="b2" doxytag="MemPager::first"></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"> char* MemPager::first </td> <td class="md">( </td> <td class="md">char *</td> <td class="mdname1"> <em>str</em> </td> <td class="md">) </td> <td class="md"><code> [protected]</code></td> </tr> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </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.<dl compact><dt><b> Parameters: </b><dd> <table border=0 cellspacing=2 cellpadding=0> <tr><td valign=top><em>str </em> </td><td> to allocate and copy into paged memory pool. </td></tr> </table> </dl><dl compact><dt><b> Returns: </b><dd> copy of string from allocated memory. </dl> </td> </tr> </table> <a name="b0" doxytag="MemPager::first"></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 void* MemPager::first </td> <td class="md">( </td> <td class="md">size_t</td> <td class="mdname1"> <em>size</em> </td> <td class="md">) </td> <td class="md"><code> [protected, virtual]</code></td> </tr> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </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.<dl compact><dt><b> Parameters: </b><dd> <table border=0 cellspacing=2 cellpadding=0> <tr><td valign=top><em>size </em> </td><td> of memory to allocate. </td></tr> </table> </dl><dl compact><dt><b> Returns: </b><dd> pointer to allocated memory. </dl> <p> Reimplemented in <a class="el" href="class_shared_mem_pager.html#b2">SharedMemPager</a>. </td> </tr> </table> <a name="a0" doxytag="MemPager::getPages"></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 MemPager::getPages </td> <td class="md">( </td> <td class="md">void</td> <td class="mdname1"> </td> <td class="md">) </td> <td class="md"><code> [inline]</code></td> </tr> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> Return the total number of pages that have been allocated for this memory pool. <p> <dl compact><dt><b> Returns: </b><dd> number of pages allocated. </dl> </td> </tr> </table> <a name="b5" doxytag="MemPager::purge"></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"> void MemPager::purge </td> <td class="md">( </td> <td class="md">void</td> <td class="mdname1"> </td> <td class="md">) </td> <td class="md"><code> [protected]</code></td> </tr> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> purge the current memory pool. <p> <p> Reimplemented in <a class="el" href="class_shared_mem_pager.html#b1">SharedMemPager</a>. </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><address><small>Generated at Tue Nov 20 13:28:48 2001 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>, © 1997-2001</small></address> </body> </html>