<!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 CommonC++: ost::SharedFile Class Reference</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <link href="doxygen.css" rel="stylesheet" type="text/css"/> </head> <body> <!-- Generated by Doxygen 1.6.3 --> <div class="navigation" id="top"> <div class="tabs"> <ul> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li class="current"><a href="annotated.html"><span>Classes</span></a></li> <li><a href="files.html"><span>Files</span></a></li> <li><a href="examples.html"><span>Examples</span></a></li> </ul> </div> <div class="tabs"> <ul> <li><a href="annotated.html"><span>Class List</span></a></li> <li><a href="classes.html"><span>Class Index</span></a></li> <li><a href="hierarchy.html"><span>Class Hierarchy</span></a></li> <li><a href="functions.html"><span>Class Members</span></a></li> </ul> </div> <div class="navpath"><a class="el" href="namespaceost.html">ost</a>::<a class="el" href="classost_1_1_shared_file.html">SharedFile</a> </div> </div> <div class="contents"> <h1>ost::SharedFile Class Reference</h1><!-- doxytag: class="ost::SharedFile" --><!-- doxytag: inherits="ost::RandomFile" --> <p>This class defines a database I/O file service that can be shared by multiple processes. <a href="#_details">More...</a></p> <p><code>#include <<a class="el" href="file_8h_source.html">file.h</a>></code></p> <div class="dynheader"> Inheritance diagram for ost::SharedFile:</div> <div class="dynsection"> <div class="center"> <img src="classost_1_1_shared_file.png" usemap="#ost::SharedFile_map" alt=""/> <map id="ost::SharedFile_map" name="ost::SharedFile_map"> <area href="classost_1_1_random_file.html" alt="ost::RandomFile" shape="rect" coords="55,56,155,80"/> <area href="classost_1_1_mutex.html" alt="ost::Mutex" shape="rect" coords="0,0,100,24"/> <area href="classost_1_1_file.html" alt="ost::File" shape="rect" coords="110,0,210,24"/> </map> </div> </div> <p><a href="classost_1_1_shared_file-members.html">List of all members.</a></p> <table border="0" cellpadding="0" cellspacing="0"> <tr><td colspan="2"><h2>Public Member Functions</h2></td></tr> <tr><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classost_1_1_shared_file.html#ac5b43aef08de67e5f8fd88bf7e5f6a80">SharedFile</a> (const char *path)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Open or create a new database file. <a href="#ac5b43aef08de67e5f8fd88bf7e5f6a80"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classost_1_1_shared_file.html#ac13ee6d8e5fb10dcf5ce6e9e12f54ae9">SharedFile</a> (const <a class="el" href="classost_1_1_shared_file.html">SharedFile</a> &file)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Create a shared file as a duplicate of an existing shared file. <a href="#ac13ee6d8e5fb10dcf5ce6e9e12f54ae9"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">virtual </td><td class="memItemRight" valign="bottom"><a class="el" href="classost_1_1_shared_file.html#a4001a868611c75292113daded7c0a585">~SharedFile</a> ()</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Close and finish a database file. <a href="#a4001a868611c75292113daded7c0a585"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="classost_1_1_file.html#a726c26bbd45c9cb0701267a2824284e6">Error</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="classost_1_1_shared_file.html#a254c43de705b9ad9f5d24536b6cff1e0">restart</a> (void)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Restart an existing database; close and re-open. <a href="#a254c43de705b9ad9f5d24536b6cff1e0"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="classost_1_1_file.html#a726c26bbd45c9cb0701267a2824284e6">Error</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="classost_1_1_shared_file.html#aa4f875ec058a85297a62e30af397d014">fetch</a> (char *address=NULL, <a class="el" href="namespaceost.html#acedd0902cc2709bd066b9f8a2d1f44a0">ccxx_size_t</a> length=0, off_t position=-1)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Lock and Fetch a portion of the file into physical memory. <a href="#aa4f875ec058a85297a62e30af397d014"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="classost_1_1_file.html#a726c26bbd45c9cb0701267a2824284e6">Error</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="classost_1_1_shared_file.html#a5ace5a51d0da7c56a252e3f26efeff67">update</a> (char *address=NULL, <a class="el" href="namespaceost.html#acedd0902cc2709bd066b9f8a2d1f44a0">ccxx_size_t</a> length=0, off_t position=-1)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Update a portion of a file from physical memory. <a href="#a5ace5a51d0da7c56a252e3f26efeff67"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="classost_1_1_file.html#a726c26bbd45c9cb0701267a2824284e6">Error</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="classost_1_1_shared_file.html#ac36a90105fb7435b498dcd72fa2473dd">clear</a> (<a class="el" href="namespaceost.html#acedd0902cc2709bd066b9f8a2d1f44a0">ccxx_size_t</a> length=0, off_t pos=-1)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Clear a lock held from a previous fetch operation without updating. <a href="#ac36a90105fb7435b498dcd72fa2473dd"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="classost_1_1_file.html#a726c26bbd45c9cb0701267a2824284e6">Error</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="classost_1_1_shared_file.html#a7169520f6cabe7de4626ab2b0c1d138f">append</a> (char *address=NULL, <a class="el" href="namespaceost.html#acedd0902cc2709bd066b9f8a2d1f44a0">ccxx_size_t</a> length=0)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Add new data to the end of the file. <a href="#a7169520f6cabe7de4626ab2b0c1d138f"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">off_t </td><td class="memItemRight" valign="bottom"><a class="el" href="classost_1_1_shared_file.html#ab7ac91d6a8ded5c7236297784353a300">getPosition</a> (void)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Fetch the current file position marker for this thread. <a href="#ab7ac91d6a8ded5c7236297784353a300"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classost_1_1_shared_file.html#aa7a0de19328f2d2c2ed8d06f7e5fa884">operator++</a> (void)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classost_1_1_shared_file.html#a9bab1e7719f2f608d719e99125bdc8e8">operator--</a> (void)</td></tr> </table> <hr/><a name="_details"></a><h2>Detailed Description</h2> <p>This class defines a database I/O file service that can be shared by multiple processes. </p> <p>Each thread should access a dup of the database object, and mutex locks can be used to preserve transaction integrety if multiple threads are used.</p> <p><a class="el" href="classost_1_1_shared_file.html" title="This class defines a database I/O file service that can be shared by multiple processes...">SharedFile</a> is used when a database may be shared between multiple processes. <a class="el" href="classost_1_1_shared_file.html" title="This class defines a database I/O file service that can be shared by multiple processes...">SharedFile</a> automatically applies low level byte-range "file locks", and provides an interface to fetch and release byte-range locked portions of a file.</p> <dl class="author"><dt><b>Author:</b></dt><dd>David Sugar <<a href="mailto:dyfet@ostel.com">dyfet@ostel.com</a>> This class defines a database I/O file service that can be shared by multiple processes. </dd></dl> <hr/><h2>Constructor & Destructor Documentation</h2> <a class="anchor" id="ac5b43aef08de67e5f8fd88bf7e5f6a80"></a><!-- doxytag: member="ost::SharedFile::SharedFile" ref="ac5b43aef08de67e5f8fd88bf7e5f6a80" args="(const char *path)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">ost::SharedFile::SharedFile </td> <td>(</td> <td class="paramtype">const char * </td> <td class="paramname"> <em>path</em></td> <td> ) </td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Open or create a new database file. </p> <p>You should also use Initial.</p> <dl><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>path</em> </td><td>pathname of database to open. </td></tr> </table> </dd> </dl> </div> </div> <a class="anchor" id="ac13ee6d8e5fb10dcf5ce6e9e12f54ae9"></a><!-- doxytag: member="ost::SharedFile::SharedFile" ref="ac13ee6d8e5fb10dcf5ce6e9e12f54ae9" args="(const SharedFile &file)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">ost::SharedFile::SharedFile </td> <td>(</td> <td class="paramtype">const <a class="el" href="classost_1_1_shared_file.html">SharedFile</a> & </td> <td class="paramname"> <em>file</em></td> <td> ) </td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Create a shared file as a duplicate of an existing shared file. </p> <dl><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>file</em> </td><td>original file. </td></tr> </table> </dd> </dl> </div> </div> <a class="anchor" id="a4001a868611c75292113daded7c0a585"></a><!-- doxytag: member="ost::SharedFile::~SharedFile" ref="a4001a868611c75292113daded7c0a585" args="()" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">virtual ost::SharedFile::~SharedFile </td> <td>(</td> <td class="paramname"></td> <td> ) </td> <td><code> [virtual]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Close and finish a database file. </p> </div> </div> <hr/><h2>Member Function Documentation</h2> <a class="anchor" id="a7169520f6cabe7de4626ab2b0c1d138f"></a><!-- doxytag: member="ost::SharedFile::append" ref="a7169520f6cabe7de4626ab2b0c1d138f" args="(char *address=NULL, ccxx_size_t length=0)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname"><a class="el" href="classost_1_1_file.html#a726c26bbd45c9cb0701267a2824284e6">Error</a> ost::SharedFile::append </td> <td>(</td> <td class="paramtype">char * </td> <td class="paramname"> <em>address</em> = <code>NULL</code>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype"><a class="el" href="namespaceost.html#acedd0902cc2709bd066b9f8a2d1f44a0">ccxx_size_t</a> </td> <td class="paramname"> <em>length</em> = <code>0</code></td><td> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td><td></td> </tr> </table> </div> <div class="memdoc"> <p>Add new data to the end of the file. </p> <p>Locks file during append.</p> <dl><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>address</em> </td><td>address to use, or NULL if same as last I/O. </td></tr> <tr><td valign="top"></td><td valign="top"><em>length</em> </td><td>length to use, or 0 if same as last I/O. </td></tr> </table> </dd> </dl> </div> </div> <a class="anchor" id="ac36a90105fb7435b498dcd72fa2473dd"></a><!-- doxytag: member="ost::SharedFile::clear" ref="ac36a90105fb7435b498dcd72fa2473dd" args="(ccxx_size_t length=0, off_t pos=-1)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname"><a class="el" href="classost_1_1_file.html#a726c26bbd45c9cb0701267a2824284e6">Error</a> ost::SharedFile::clear </td> <td>(</td> <td class="paramtype"><a class="el" href="namespaceost.html#acedd0902cc2709bd066b9f8a2d1f44a0">ccxx_size_t</a> </td> <td class="paramname"> <em>length</em> = <code>0</code>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">off_t </td> <td class="paramname"> <em>pos</em> = <code>-1</code></td><td> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td><td></td> </tr> </table> </div> <div class="memdoc"> <p>Clear a lock held from a previous fetch operation without updating. </p> <dl class="return"><dt><b>Returns:</b></dt><dd>errSuccess on success. </dd></dl> <dl><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>length</em> </td><td>length to use, or 0 if same as last I/O. </td></tr> <tr><td valign="top"></td><td valign="top"><em>pos</em> </td><td>file position to use or -1 if same as last I/O. </td></tr> </table> </dd> </dl> </div> </div> <a class="anchor" id="aa4f875ec058a85297a62e30af397d014"></a><!-- doxytag: member="ost::SharedFile::fetch" ref="aa4f875ec058a85297a62e30af397d014" args="(char *address=NULL, ccxx_size_t length=0, off_t position=-1)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname"><a class="el" href="classost_1_1_file.html#a726c26bbd45c9cb0701267a2824284e6">Error</a> ost::SharedFile::fetch </td> <td>(</td> <td class="paramtype">char * </td> <td class="paramname"> <em>address</em> = <code>NULL</code>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype"><a class="el" href="namespaceost.html#acedd0902cc2709bd066b9f8a2d1f44a0">ccxx_size_t</a> </td> <td class="paramname"> <em>length</em> = <code>0</code>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">off_t </td> <td class="paramname"> <em>position</em> = <code>-1</code></td><td> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td><td></td> </tr> </table> </div> <div class="memdoc"> <p>Lock and Fetch a portion of the file into physical memory. </p> <p>This can use state information to fetch the current record multiple times.</p> <dl class="return"><dt><b>Returns:</b></dt><dd>errSuccess on success. </dd></dl> <dl><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>address</em> </td><td>address to use, or NULL if same as last I/O. </td></tr> <tr><td valign="top"></td><td valign="top"><em>length</em> </td><td>length to use, or 0 if same as last I/O. </td></tr> <tr><td valign="top"></td><td valign="top"><em>position</em> </td><td>file position to use -1 if same as last I/O. </td></tr> </table> </dd> </dl> </div> </div> <a class="anchor" id="ab7ac91d6a8ded5c7236297784353a300"></a><!-- doxytag: member="ost::SharedFile::getPosition" ref="ab7ac91d6a8ded5c7236297784353a300" args="(void)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">off_t ost::SharedFile::getPosition </td> <td>(</td> <td class="paramtype">void </td> <td class="paramname"></td> <td> ) </td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Fetch the current file position marker for this thread. </p> <dl class="return"><dt><b>Returns:</b></dt><dd>file position offset. </dd></dl> </div> </div> <a class="anchor" id="aa7a0de19328f2d2c2ed8d06f7e5fa884"></a><!-- doxytag: member="ost::SharedFile::operator++" ref="aa7a0de19328f2d2c2ed8d06f7e5fa884" args="(void)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">bool ost::SharedFile::operator++ </td> <td>(</td> <td class="paramtype">void </td> <td class="paramname"></td> <td> ) </td> <td></td> </tr> </table> </div> <div class="memdoc"> </div> </div> <a class="anchor" id="a9bab1e7719f2f608d719e99125bdc8e8"></a><!-- doxytag: member="ost::SharedFile::operator--" ref="a9bab1e7719f2f608d719e99125bdc8e8" args="(void)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">bool ost::SharedFile::operator-- </td> <td>(</td> <td class="paramtype">void </td> <td class="paramname"></td> <td> ) </td> <td></td> </tr> </table> </div> <div class="memdoc"> </div> </div> <a class="anchor" id="a254c43de705b9ad9f5d24536b6cff1e0"></a><!-- doxytag: member="ost::SharedFile::restart" ref="a254c43de705b9ad9f5d24536b6cff1e0" args="(void)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname"><a class="el" href="classost_1_1_file.html#a726c26bbd45c9cb0701267a2824284e6">Error</a> ost::SharedFile::restart </td> <td>(</td> <td class="paramtype">void </td> <td class="paramname"></td> <td> ) </td> <td><code> [inline, virtual]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Restart an existing database; close and re-open. </p> <dl class="return"><dt><b>Returns:</b></dt><dd>errSuccess if successful. </dd></dl> <p>Reimplemented from <a class="el" href="classost_1_1_random_file.html#ae78c71b1e3fab5861bc9fdae595829a7">ost::RandomFile</a>.</p> </div> </div> <a class="anchor" id="a5ace5a51d0da7c56a252e3f26efeff67"></a><!-- doxytag: member="ost::SharedFile::update" ref="a5ace5a51d0da7c56a252e3f26efeff67" args="(char *address=NULL, ccxx_size_t length=0, off_t position=-1)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname"><a class="el" href="classost_1_1_file.html#a726c26bbd45c9cb0701267a2824284e6">Error</a> ost::SharedFile::update </td> <td>(</td> <td class="paramtype">char * </td> <td class="paramname"> <em>address</em> = <code>NULL</code>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype"><a class="el" href="namespaceost.html#acedd0902cc2709bd066b9f8a2d1f44a0">ccxx_size_t</a> </td> <td class="paramname"> <em>length</em> = <code>0</code>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">off_t </td> <td class="paramname"> <em>position</em> = <code>-1</code></td><td> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td><td></td> </tr> </table> </div> <div class="memdoc"> <p>Update a portion of a file from physical memory. </p> <p>This can use state information to commit the last read record. The current lock is also cleared.</p> <dl class="return"><dt><b>Returns:</b></dt><dd>errSuccess on success. </dd></dl> <dl><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>address</em> </td><td>address to use, or NULL if same as last I/O. </td></tr> <tr><td valign="top"></td><td valign="top"><em>length</em> </td><td>length to use, or 0 if same as last I/O. </td></tr> <tr><td valign="top"></td><td valign="top"><em>position</em> </td><td>file position to use or -1 if same as last I/O. </td></tr> </table> </dd> </dl> </div> </div> <hr/>The documentation for this class was generated from the following file:<ul> <li><a class="el" href="file_8h_source.html">file.h</a></li> </ul> </div> <hr class="footer"/><address style="text-align: right;"><small>Generated on Fri Mar 12 10:07:40 2010 for GNU CommonC++ by <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.3 </small></address> </body> </html>