Sophie

Sophie

distrib > Fedora > 14 > x86_64 > by-pkgid > 3f684444755c5ad1181cdd5a97348f3c > files > 1435

PyQt4-devel-4.7.4-2.fc14.i686.rpm

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html><head><title>QSharedMemory Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
td.postheader { font-family: sans-serif }
tr.address { font-family: sans-serif }
body { background: #ffffff; color: black; }
</style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">&#160;&#160;</td><td class="postheader" valign="center"><a href="../pyqt4ref.html"><font color="#004faf">Home</font></a>&#160;&#183; <a href="classes.html"><font color="#004faf">All Classes</font></a>&#160;&#183; <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QSharedMemory Class Reference<br /><sup><sup>[<a href="qtcore.html">QtCore</a> module]</sup></sup></h1><p>The QSharedMemory class provides access to a shared memory segment. <a href="#details">More...</a></p>
<p>Inherits <a href="qobject.html">QObject</a>.</p><h3>Types</h3><ul><li><div class="fn" />enum <b><a href="qsharedmemory.html#AccessMode-enum">AccessMode</a></b> { ReadOnly, ReadWrite }</li><li><div class="fn" />enum <b><a href="qsharedmemory.html#SharedMemoryError-enum">SharedMemoryError</a></b> { NoError, PermissionDenied, InvalidSize, KeyError, ..., UnknownError }</li></ul><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qsharedmemory.html#QSharedMemory">__init__</a></b> (<i>self</i>, QObject&#160;<i>parent</i>&#160;=&#160;None)</li><li><div class="fn" /><b><a href="qsharedmemory.html#QSharedMemory-2">__init__</a></b> (<i>self</i>, QString, QObject&#160;<i>parent</i>&#160;=&#160;None)</li><li><div class="fn" />bool <b><a href="qsharedmemory.html#attach">attach</a></b> (<i>self</i>, AccessMode&#160;<i>mode</i>&#160;=&#160;QSharedMemory.ReadWrite)</li><li><div class="fn" />sip.voidptr <b><a href="qsharedmemory.html#constData">constData</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qsharedmemory.html#create">create</a></b> (<i>self</i>, int, AccessMode&#160;<i>mode</i>&#160;=&#160;QSharedMemory.ReadWrite)</li><li><div class="fn" />sip.voidptr <b><a href="qsharedmemory.html#data">data</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qsharedmemory.html#detach">detach</a></b> (<i>self</i>)</li><li><div class="fn" />SharedMemoryError <b><a href="qsharedmemory.html#error">error</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qsharedmemory.html#errorString">errorString</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qsharedmemory.html#isAttached">isAttached</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qsharedmemory.html#key">key</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qsharedmemory.html#lock">lock</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qsharedmemory.html#setKey">setKey</a></b> (<i>self</i>, QString)</li><li><div class="fn" />int <b><a href="qsharedmemory.html#size">size</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qsharedmemory.html#unlock">unlock</a></b> (<i>self</i>)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QSharedMemory class provides access to a shared memory segment.</p>
<p>QSharedMemory provides access to a shared memory segment by multiple threads and processes. It also provides a way for a single thread or process to lock the memory for exclusive access.</p>
<p>When using this class, be aware of the following platform differences:</p>
<ul>
<li>Windows: QSharedMemory does not "own" the shared memory segment. When all threads or processes that have an instance of QSharedMemory attached to a particular shared memory segment have either destroyed their instance of QSharedMemory or exited, the Windows kernel releases the shared memory segment automatically.</li>
<li>Unix: QSharedMemory "owns" the shared memory segment. When the last thread or process that has an instance of QSharedMemory attached to a particular shared memory segment detaches from the segment by destroying its instance of QSharedMemory, the Unix kernel release the shared memory segment. But if that last thread or process crashes without running the QSharedMemory destructor, the shared memory segment survives the crash.</li>
<li>HP-UX: Only one attach to a shared memory segment is allowed per process. This means that QSharedMemory should not be used across multiple threads in the same process in HP-UX.</li>
<li>Symbian: QSharedMemory does not "own" the shared memory segment. When all threads or processes that have an instance of QSharedMemory attached to a particular shared memory segment have either destroyed their instance of QSharedMemory or exited, the Symbian kernel releases the shared memory segment automatically. Also, access to a shared memory segment cannot be limited to read-only in Symbian.</li>
</ul>
<p>Remember to lock the shared memory with <a href="qsharedmemory.html#lock">lock</a>() before reading from or writing to the shared memory, and remember to release the lock with <a href="qsharedmemory.html#unlock">unlock</a>() after you are done.</p>
<p>Unlike <a href="http://qt.nokia.com/products/add-on-products/catalog/4/Utilities/qtsharedmemory/">QtSharedMemory</a>, QSharedMemory automatically destroys the shared memory segment when the last instance of QSharedMemory is detached from the segment, and no references to the segment remain. Do not mix using <a href="http://qt.nokia.com/products/add-on-products/catalog/4/Utilities/qtsharedmemory/">QtSharedMemory</a> and QSharedMemory. Port everything to QSharedMemory.</p>
<p><b>Warning:</b> QSharedMemory changes the key in a Qt-specific way. It is therefore currently not possible to use the shared memory of non-Qt applications with QSharedMemory.</p>
<hr /><h2>Type Documentation</h2><h3 class="fn"><a name="AccessMode-enum" />QSharedMemory.AccessMode</h3><p><table border="1" cellpadding="2" cellspacing="1" class="valuelist" width="100%">
<tr><th width="25%">Constant</th><th width="15%">Value</th><th width="60%">Description</th></tr>
<tr><td valign="top"><tt>QSharedMemory.ReadOnly</tt></td><td align="center" valign="top"><tt>0</tt></td><td valign="top">The shared memory segment is read-only. Writing to the shared memory segment is not allowed. An attempt to write to a shared memory segment created with ReadOnly causes the program to abort.</td></tr>
<tr><td valign="top"><tt>QSharedMemory.ReadWrite</tt></td><td align="center" valign="top"><tt>1</tt></td><td valign="top">Reading and writing the shared memory segment are both allowed.</td></tr>
</table></p>
<a name="//apple_ref/cpp/tag/QSharedMemory/SharedMemoryError" />
<a name="//apple_ref/cpp/econst/QSharedMemory/NoError" />
<a name="//apple_ref/cpp/econst/QSharedMemory/PermissionDenied" />
<a name="//apple_ref/cpp/econst/QSharedMemory/InvalidSize" />
<a name="//apple_ref/cpp/econst/QSharedMemory/KeyError" />
<a name="//apple_ref/cpp/econst/QSharedMemory/AlreadyExists" />
<a name="//apple_ref/cpp/econst/QSharedMemory/NotFound" />
<a name="//apple_ref/cpp/econst/QSharedMemory/LockError" />
<a name="//apple_ref/cpp/econst/QSharedMemory/OutOfResources" />
<a name="//apple_ref/cpp/econst/QSharedMemory/UnknownError" />
<h3 class="fn"><a name="SharedMemoryError-enum" />QSharedMemory.SharedMemoryError</h3><p><table border="1" cellpadding="2" cellspacing="1" class="valuelist" width="100%">
<tr><th width="25%">Constant</th><th width="15%">Value</th><th width="60%">Description</th></tr>
<tr><td valign="top"><tt>QSharedMemory.NoError</tt></td><td align="center" valign="top"><tt>0</tt></td><td valign="top">No error occurred.</td></tr>
<tr><td valign="top"><tt>QSharedMemory.PermissionDenied</tt></td><td align="center" valign="top"><tt>1</tt></td><td valign="top">The operation failed because the caller didn't have the required permissions.</td></tr>
<tr><td valign="top"><tt>QSharedMemory.InvalidSize</tt></td><td align="center" valign="top"><tt>2</tt></td><td valign="top">A create operation failed because the requested size was invalid.</td></tr>
<tr><td valign="top"><tt>QSharedMemory.KeyError</tt></td><td align="center" valign="top"><tt>3</tt></td><td valign="top">The operation failed because of an invalid key.</td></tr>
<tr><td valign="top"><tt>QSharedMemory.AlreadyExists</tt></td><td align="center" valign="top"><tt>4</tt></td><td valign="top">A <a href="qsharedmemory.html#create">create</a>() operation failed because a shared memory segment with the specified key already existed.</td></tr>
<tr><td valign="top"><tt>QSharedMemory.NotFound</tt></td><td align="center" valign="top"><tt>5</tt></td><td valign="top">An <a href="qsharedmemory.html#attach">attach</a>() failed because a shared memory segment with the specified key could not be found.</td></tr>
<tr><td valign="top"><tt>QSharedMemory.LockError</tt></td><td align="center" valign="top"><tt>6</tt></td><td valign="top">The attempt to <a href="qsharedmemory.html#lock">lock</a>() the shared memory segment failed because <a href="qsharedmemory.html#create">create</a>() or <a href="qsharedmemory.html#attach">attach</a>() failed and returned false, or because a system error occurred in <a href="qsystemsemaphore.html#acquire">QSystemSemaphore.acquire</a>().</td></tr>
<tr><td valign="top"><tt>QSharedMemory.OutOfResources</tt></td><td align="center" valign="top"><tt>7</tt></td><td valign="top">A <a href="qsharedmemory.html#create">create</a>() operation failed because there was not enough memory available to fill the request.</td></tr>
<tr><td valign="top"><tt>QSharedMemory.UnknownError</tt></td><td align="center" valign="top"><tt>8</tt></td><td valign="top">Something else happened and it was bad.</td></tr>
</table></p>
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QSharedMemory" />QSharedMemory.__init__ (<i>self</i>, <a href="qobject.html">QObject</a>&#160;<i>parent</i>&#160;=&#160;None)</h3><p>The <i>parent</i> argument, if not None, causes <i>self</i> to be owned by Qt instead of PyQt.</p><p>Constructs a shared memory object with the given <i>parent</i> and with its key set to <i>key</i>. Because its key is set, its <a href="qsharedmemory.html#create">create</a>() and <a href="qsharedmemory.html#attach">attach</a>() functions can be called.</p>
<p>See also <a href="qsharedmemory.html#setKey">setKey</a>(), <a href="qsharedmemory.html#create">create</a>(), and <a href="qsharedmemory.html#attach">attach</a>().</p>
<h3 class="fn"><a name="QSharedMemory-2" />QSharedMemory.__init__ (<i>self</i>, QString, <a href="qobject.html">QObject</a>&#160;<i>parent</i>&#160;=&#160;None)</h3><p>The <i>parent</i> argument, if not None, causes <i>self</i> to be owned by Qt instead of PyQt.</p><p>This function overloads <a href="qsharedmemory.html#QSharedMemory">QSharedMemory</a>().</p>
<p>Constructs a shared memory object with the given <i>parent</i>. The shared memory object's key is not set by the constructor, so the shared memory object does not have an underlying shared memory segment attached. The key must be set with <a href="qsharedmemory.html#setKey">setKey</a>() before <a href="qsharedmemory.html#create">create</a>() or <a href="qsharedmemory.html#attach">attach</a>() can be used.</p>
<p>See also <a href="qsharedmemory.html#setKey">setKey</a>().</p>
<a name="//apple_ref/cpp/instm/QSharedMemory/~QSharedMemory" />
<h3 class="fn"><a name="attach" />bool QSharedMemory.attach (<i>self</i>, <a href="qsharedmemory.html#AccessMode-enum">AccessMode</a>&#160;<i>mode</i>&#160;=&#160;QSharedMemory.ReadWrite)</h3><p>Attempts to attach the process to the shared memory segment identified by the key that was passed to the constructor or to a call to <a href="qsharedmemory.html#setKey">setKey</a>(). The access <i>mode</i> is <a href="qsharedmemory.html#AccessMode-enum">ReadWrite</a> by default. It can also be <a href="qsharedmemory.html#AccessMode-enum">ReadOnly</a>. Returns true if the attach operation is successful. If false is returned, call <a href="qsharedmemory.html#error">error</a>() to determine which error occurred. After attaching the shared memory segment, a pointer to the shared memory can be obtained by calling <a href="qsharedmemory.html#data">data</a>().</p>
<p>See also <a href="qsharedmemory.html#isAttached">isAttached</a>(), <a href="qsharedmemory.html#detach">detach</a>(), and <a href="qsharedmemory.html#create">create</a>().</p>
<a name="//apple_ref/cpp/instm/QSharedMemory/constData" />
<h3 class="fn"><a name="constData" />sip.voidptr QSharedMemory.constData (<i>self</i>)</h3><p>Returns a const pointer to the contents of the shared memory segment, if one is attached. Otherwise it returns null. Remember to lock the shared memory with <a href="qsharedmemory.html#lock">lock</a>() before reading from or writing to the shared memory, and remember to release the lock with <a href="qsharedmemory.html#unlock">unlock</a>() after you are done.</p>
<p>See also <a href="qsharedmemory.html#attach">attach</a>() and <a href="qsharedmemory.html#create">create</a>().</p>
<a name="//apple_ref/cpp/instm/QSharedMemory/create" />
<h3 class="fn"><a name="create" />bool QSharedMemory.create (<i>self</i>, int, <a href="qsharedmemory.html#AccessMode-enum">AccessMode</a>&#160;<i>mode</i>&#160;=&#160;QSharedMemory.ReadWrite)</h3><p>Creates a shared memory segment of <i>size</i> bytes with the key passed to the constructor or set with <a href="qsharedmemory.html#setKey">setKey</a>(), attaches to the new shared memory segment with the given access <i>mode</i>, and returns <tt>true</tt>. If a shared memory segment identified by the key already exists, the attach operation is not performed, and <tt>false</tt> is returned. When the return value is <tt>false</tt>, call <a href="qsharedmemory.html#error">error</a>() to determine which error occurred.</p>
<p>See also <a href="qsharedmemory.html#error">error</a>().</p>
<a name="//apple_ref/cpp/instm/QSharedMemory/data" />
<h3 class="fn"><a name="data" />sip.voidptr QSharedMemory.data (<i>self</i>)</h3><p>Returns a pointer to the contents of the shared memory segment, if one is attached. Otherwise it returns null. Remember to lock the shared memory with <a href="qsharedmemory.html#lock">lock</a>() before reading from or writing to the shared memory, and remember to release the lock with <a href="qsharedmemory.html#unlock">unlock</a>() after you are done.</p>
<p>See also <a href="qsharedmemory.html#attach">attach</a>().</p>
<h3 class="fn"><a name="detach" />bool QSharedMemory.detach (<i>self</i>)</h3><p>Detaches the process from the shared memory segment. If this was the last process attached to the shared memory segment, then the shared memory segment is released by the system, i.e., the contents are destroyed. The function returns true if it detaches the shared memory segment. If it returns false, it usually means the segment either isn't attached, or it is locked by another process.</p>
<p>See also <a href="qsharedmemory.html#attach">attach</a>() and <a href="qsharedmemory.html#isAttached">isAttached</a>().</p>
<a name="//apple_ref/cpp/instm/QSharedMemory/error" />
<h3 class="fn"><a name="error" /><a href="qsharedmemory.html#SharedMemoryError-enum">SharedMemoryError</a> QSharedMemory.error (<i>self</i>)</h3><p>Returns a value indicating whether an error occurred, and, if so, which error it was.</p>
<p>See also <a href="qsharedmemory.html#errorString">errorString</a>().</p>
<a name="//apple_ref/cpp/instm/QSharedMemory/errorString" />
<h3 class="fn"><a name="errorString" />QString QSharedMemory.errorString (<i>self</i>)</h3><p>Returns a text description of the last error that occurred. If <a href="qsharedmemory.html#error">error</a>() returns an <a href="qsharedmemory.html#SharedMemoryError-enum">error value</a>, call this function to get a text string that describes the error.</p>
<p>See also <a href="qsharedmemory.html#error">error</a>().</p>
<a name="//apple_ref/cpp/instm/QSharedMemory/isAttached" />
<h3 class="fn"><a name="isAttached" />bool QSharedMemory.isAttached (<i>self</i>)</h3><p>Returns true if this process is attached to the shared memory segment.</p>
<p>See also <a href="qsharedmemory.html#attach">attach</a>() and <a href="qsharedmemory.html#detach">detach</a>().</p>
<a name="//apple_ref/cpp/instm/QSharedMemory/key" />
<h3 class="fn"><a name="key" />QString QSharedMemory.key (<i>self</i>)</h3><p>Returns the key assigned to this shared memory. The key is the identifier used by the operating system to identify the shared memory segment. When <a href="qsharedmemory.html">QSharedMemory</a> is used for interprocess communication, the key is how each process attaches to the shared memory segment through which the IPC occurs.</p>
<p>See also <a href="qsharedmemory.html#setKey">setKey</a>().</p>
<a name="//apple_ref/cpp/instm/QSharedMemory/lock" />
<h3 class="fn"><a name="lock" />bool QSharedMemory.lock (<i>self</i>)</h3><p>This is a semaphore that locks the shared memory segment for access by this process and returns true. If another process has locked the segment, this function blocks until the lock is released. Then it acquires the lock and returns true. If this function returns false, it means either that you have ignored a false return from <a href="qsharedmemory.html#create">create</a>() or <a href="qsharedmemory.html#attach">attach</a>(), or that <a href="qsystemsemaphore.html#acquire">QSystemSemaphore.acquire</a>() failed due to an unknown system error.</p>
<p>See also <a href="qsharedmemory.html#unlock">unlock</a>(), <a href="qsharedmemory.html#data">data</a>(), and <a href="qsystemsemaphore.html#acquire">QSystemSemaphore.acquire</a>().</p>
<a name="//apple_ref/cpp/instm/QSharedMemory/setKey" />
<h3 class="fn"><a name="setKey" />QSharedMemory.setKey (<i>self</i>, QString)</h3><p>Sets a new <i>key</i> for this shared memory object. If <i>key</i> and the current key are the same, the function returns without doing anything. If the shared memory object is attached to an underlying shared memory segment, it will <a href="qsharedmemory.html#detach">detach</a> from it before setting the new key. This function does not do an <a href="qsharedmemory.html#attach">attach</a>().</p>
<p>See also <a href="qsharedmemory.html#key">key</a>() and <a href="qsharedmemory.html#isAttached">isAttached</a>().</p>
<a name="//apple_ref/cpp/instm/QSharedMemory/size" />
<h3 class="fn"><a name="size" />int QSharedMemory.size (<i>self</i>)</h3><p>Returns the size of the attached shared memory segment. If no shared memory segment is attached, 0 is returned.</p>
<p>See also <a href="qsharedmemory.html#create">create</a>() and <a href="qsharedmemory.html#attach">attach</a>().</p>
<a name="//apple_ref/cpp/instm/QSharedMemory/unlock" />
<h3 class="fn"><a name="unlock" />bool QSharedMemory.unlock (<i>self</i>)</h3><p>Releases the lock on the shared memory segment and returns true, if the lock is currently held by this process. If the segment is not locked, or if the lock is held by another process, nothing happens and false is returned.</p>
<p>See also <a href="qsharedmemory.html#lock">lock</a>().</p>
<p /><address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt&#160;4.7.4 for X11</td><td align="center" width="50%">Copyright &#169; <a href="http://www.riverbankcomputing.com">Riverbank&#160;Computing&#160;Ltd</a> and <a href="http://www.qtsoftware.com">Nokia</a> 2010</td><td align="right" width="25%">Qt&#160;4.6.3</td></tr></table></div></address></body></html>