📄 classpsafeptr.html
字号:
<!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> TemplatePSafePtr< T > class Reference</title><link href="doxygen.css" rel="stylesheet" type="text/css"></head><body><!-- Generated by Doxygen 1.2.18 --><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="annotated.html">Compound List</a> <a class="qindex" href="files.html">File List</a> <a class="qindex" href="functions.html">Compound Members</a> <a class="qindex" href="globals.html">File Members</a> </center><hr><h1>PSafePtr< T > Class Template Reference</h1><code>#include <<a class="el" href="safecoll_8h-source.html">safecoll.h</a>></code><p><p>Inheritance diagram for PSafePtr< T >:<p><center><img src="classPSafePtr.png" usemap="#PSafePtr< T >_map" border="0" alt=""></center><map name="PSafePtr< T >_map"><area href="classPSafePtrBase.html" alt="PSafePtrBase" shape="rect" coords="0,56,93,80"><area href="classPObject.html" alt="PObject" shape="rect" coords="0,0,93,24"></map><a href="classPSafePtr-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 Methods</h2></td></tr><tr><td colspan="2"><div class="groupHeader">Construction</div></td></tr><tr><td nowrap align=right valign=top> </td><td valign=bottom><a class="el" href="classPSafePtr.html#z333_0">PSafePtr</a> (T *obj=NULL, <a class="el" href="safecoll_8h.html#a4">PSafetyMode</a> mode=PSafeReference)</td></tr><tr><td nowrap align=right valign=top> </td><td valign=bottom><a class="el" href="classPSafePtr.html#z333_1">PSafePtr</a> (const <a class="el" href="classPSafeCollection.html">PSafeCollection</a> &safeCollection, <a class="el" href="safecoll_8h.html#a4">PSafetyMode</a> mode=PSafeReadWrite, PINDEX idx=0)</td></tr><tr><td nowrap align=right valign=top> </td><td valign=bottom><a class="el" href="classPSafePtr.html#z333_2">PSafePtr</a> (const <a class="el" href="classPSafeCollection.html">PSafeCollection</a> &safeCollection, <a class="el" href="safecoll_8h.html#a4">PSafetyMode</a> mode, <a class="el" href="classPSafeObject.html">PSafeObject</a> *obj)</td></tr><tr><td nowrap align=right valign=top> </td><td valign=bottom><a class="el" href="classPSafePtr.html#z333_3">PSafePtr</a> (const PSafePtr &ptr)</td></tr><tr><td nowrap align=right valign=top>PSafePtr & </td><td valign=bottom><a class="el" href="classPSafePtr.html#z333_4">operator=</a> (const PSafePtr &ptr)</td></tr><tr><td nowrap align=right valign=top>PSafePtr & </td><td valign=bottom><a class="el" href="classPSafePtr.html#z333_5">operator=</a> (const <a class="el" href="classPSafeCollection.html">PSafeCollection</a> &safeCollection)</td></tr><tr><td nowrap align=right valign=top>PSafePtr & </td><td valign=bottom><a class="el" href="classPSafePtr.html#z333_6">operator=</a> (T *obj)</td></tr><tr><td nowrap align=right valign=top>PSafePtr & </td><td valign=bottom><a class="el" href="classPSafePtr.html#z333_7">operator=</a> (PINDEX idx)</td></tr><tr><td colspan="2"><div class="groupHeader">Operations</div></td></tr><tr><td nowrap align=right valign=top> </td><td valign=bottom><a class="el" href="classPSafePtr.html#z335_0">operator T *</a> () const</td></tr><tr><td nowrap align=right valign=top>T & </td><td valign=bottom><a class="el" href="classPSafePtr.html#z335_1">operator *</a> () const</td></tr><tr><td nowrap align=right valign=top>T * </td><td valign=bottom><a class="el" href="classPSafePtr.html#z335_2">operator-></a> () const</td></tr><tr><td nowrap align=right valign=top>T * </td><td valign=bottom><a class="el" href="classPSafePtr.html#z335_3">operator++</a> (int)</td></tr><tr><td nowrap align=right valign=top>T * </td><td valign=bottom><a class="el" href="classPSafePtr.html#z335_4">operator++</a> ()</td></tr><tr><td nowrap align=right valign=top>T * </td><td valign=bottom><a class="el" href="classPSafePtr.html#z335_5">operator--</a> (int)</td></tr><tr><td nowrap align=right valign=top>T * </td><td valign=bottom><a class="el" href="classPSafePtr.html#z335_6">operator--</a> ()</td></tr></table><hr><a name="_details"></a><h2>Detailed Description</h2><h3>template<class T><br> class PSafePtr< T ></h3>This class defines a thread-safe enumeration of object in a collection.<p>This is part of a set of classes to solve the general problem of a collection (eg a PList or PDictionary) of objects that needs to be a made thread safe. Any thread can add, read, write or remove an object with both the object and the database of objects itself kept thread safe.<p>There are two modes of safe pointer, one that is enumerating a collection and one that is independent of the collection that the safe object is in. There are some subtle semantics that must be observed in each of these two modes especially when switching from one to the other.<p>NOTE: the PSafePtr will allow safe and mutexed access to objects but is not thread safe itself! You should not share PSafePtr instances across threads. You can assign a PSafePtr to another instance across a thread boundary provided it is on a reference and no read only or read/write locks are present.<p>See the <a class="el" href="classPSafeObject.html">PSafeObject</a> class for more details. Especially in regard to enumeration of collections. <p><hr><h2>Constructor & Destructor Documentation</h2><a name="z333_0" doxytag="PSafePtr::PSafePtr"></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" colspan="4">template<class T> </td> </tr> <tr> <td class="md" nowrap valign="top"> PSafePtr< T >::PSafePtr </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">T * </td> <td class="mdname" nowrap> <em>obj</em> = NULL, </td> </tr> <tr> <td></td> <td></td> <td class="md" nowrap><a class="el" href="safecoll_8h.html#a4">PSafetyMode</a> </td> <td class="mdname" nowrap> <em>mode</em> = PSafeReference</td> </tr> <tr> <td></td> <td class="md">) </td> <td class="md" colspan="2"><code> [inline]</code></td> </tr> </table> </td> </tr></table><table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td><p>Create a new pointer to a <a class="el" href="classPSafeObject.html">PSafeObject</a>. An optional locking mode may be provided to lock the object for reading or writing and automatically unlock it on destruction.<p>Note that this version is not associated with a collection so the ++ and -- operators will not work. <dl compact><dt><b>Parameters: </b></dt><dd><table border=0 cellspacing=2 cellpadding=0><tr><td valign=top><em>mode</em> </td><td>Physical object to point to. Locking mode for the object </td></tr></table></dl> </td> </tr></table><a name="z333_1" doxytag="PSafePtr::PSafePtr"></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" colspan="4">template<class T> </td> </tr> <tr> <td class="md" nowrap valign="top"> PSafePtr< T >::PSafePtr </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">const <a class="el" href="classPSafeCollection.html">PSafeCollection</a> & </td> <td class="mdname" nowrap> <em>safeCollection</em>, </td> </tr> <tr> <td></td> <td></td> <td class="md" nowrap><a class="el" href="safecoll_8h.html#a4">PSafetyMode</a> </td> <td class="mdname" nowrap> <em>mode</em> = PSafeReadWrite, </td> </tr> <tr> <td></td> <td></td> <td class="md" nowrap>PINDEX </td> <td class="mdname" nowrap> <em>idx</em> = 0</td> </tr> <tr> <td></td> <td class="md">) </td> <td class="md" colspan="2"><code> [inline]</code></td> </tr> </table> </td> </tr></table><table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td><p>Create a new pointer to a <a class="el" href="classPSafeObject.html">PSafeObject</a>. An optional locking mode may be provided to lock the object for reading or writing and automatically unlock it on destruction.<p>The idx'th entry of the collection is pointed to by this object. If the idx is beyond the size of the collection, the pointer is NULL. <dl compact><dt><b>Parameters: </b></dt><dd><table border=0 cellspacing=2 cellpadding=0><tr><td valign=top><em>mode</em> </td><td>Collection pointer will enumerate </td></tr><tr><td valign=top><em>idx</em> </td><td>Locking mode for the object Index into collection to point to </td></tr></table></dl> </td> </tr></table><a name="z333_2" doxytag="PSafePtr::PSafePtr"></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" colspan="4">template<class T> </td> </tr> <tr> <td class="md" nowrap valign="top"> PSafePtr< T >::PSafePtr </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">const <a class="el" href="classPSafeCollection.html">PSafeCollection</a> & </td> <td class="mdname" nowrap> <em>safeCollection</em>, </td> </tr> <tr> <td></td> <td></td> <td class="md" nowrap><a class="el" href="safecoll_8h.html#a4">PSafetyMode</a> </td> <td class="mdname" nowrap> <em>mode</em>, </td> </tr> <tr> <td></td> <td></td> <td class="md" nowrap><a class="el" href="classPSafeObject.html">PSafeObject</a> * </td> <td class="mdname" nowrap> <em>obj</em></td> </tr> <tr> <td></td> <td class="md">) </td> <td class="md" colspan="2"><code> [inline]</code></td> </tr> </table> </td> </tr></table><table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td><p>Create a new pointer to a <a class="el" href="classPSafeObject.html">PSafeObject</a>. An optional locking mode may be provided to lock the object for reading or writing and automatically unlock it on destruction.<p>The obj parameter is only set if it contained in the collection, otherwise the pointer is NULL. <dl compact><dt><b>Parameters: </b></dt><dd><table border=0 cellspacing=2 cellpadding=0><tr><td valign=top><em>mode</em> </td><td>Collection pointer will enumerate </td></tr><tr><td valign=top><em>obj</em> </td><td>Locking mode for the object Inital object in collection to point to </td></tr></table></dl> </td> </tr></table><a name="z333_3" doxytag="PSafePtr::PSafePtr"></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" colspan="4">template<class T> </td> </tr> <tr> <td class="md" nowrap valign="top"> PSafePtr< T >::PSafePtr </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">const PSafePtr< T > & </td> <td class="mdname1" valign="top" nowrap> <em>ptr</em> </td> <td class="md" valign="top">) </td> <td class="md" nowrap><code> [inline]</code></td> </tr> </table> </td> </tr></table><table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td><p>Copy the pointer to the <a class="el" href="classPSafeObject.html">PSafeObject</a>. This will create a copy of the pointer with the same locking mode and lock on the <a class="el" href="classPSafeObject.html">PSafeObject</a>. It will also increment the reference count on the <a class="el" href="classPSafeObject.html">PSafeObject</a> as well. <dl compact><dt><b>Parameters: </b></dt><dd><table border=0 cellspacing=2 cellpadding=0><tr><td valign=top><em>ptr</em> </td><td>Pointer to copy </td></tr></table></dl> </td> </tr></table><hr><h2>Member Function Documentation</h2><a name="z335_1" doxytag="PSafePtr::operator *"></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" colspan="4">template<class T> </td> </tr> <tr> <td class="md" nowrap valign="top"> T& PSafePtr< T >::operator * </td> <td class="md" valign="top">( </td> <td class="mdname1" valign="top" nowrap> </td> <td class="md" valign="top">) </td> <td class="md" nowrap> const<code> [inline]</code></td> </tr> </table> </td> </tr></table><table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td><p>Return the physical pointer to the object. </td> </tr></table><a name="z335_0" doxytag="PSafePtr::operator T *"></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" colspan="4">template<class T> </td> </tr> <tr> <td class="md" nowrap valign="top"> PSafePtr< T >::operator T * </td> <td class="md" valign="top">( </td> <td class="mdname1" valign="top" nowrap> </td> <td class="md" valign="top">) </td> <td class="md" nowrap> const<code> [inline]</code></td> </tr> </table> </td> </tr></table><table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -