| <!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>oscl_shared_ptr.h Source File</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="modules.html">Modules</a> <a class="qindex" href="hierarchy.html">Class Hierarchy</a> <a class="qindex" href="annotated.html">Data Structures</a> <a class="qindex" href="files.html">File List</a> <a class="qindex" href="functions.html">Data Fields</a> <a class="qindex" href="globals.html">Globals</a> </center> |
| <hr><h1>oscl_shared_ptr.h</h1><a href="oscl__shared__ptr_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="comment">// -*- c++ -*-</span> |
| 00002 <span class="comment">// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =</span> |
| 00003 |
| 00004 <span class="comment">// O S C L _ S H A R E D _ P T R</span> |
| 00005 |
| 00006 <span class="comment">// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =</span> |
| 00007 |
| 00019 <span class="preprocessor">#ifndef OSCL_SHARED_PTR_H_INCLUDED</span> |
| 00020 <span class="preprocessor"></span><span class="preprocessor">#define OSCL_SHARED_PTR_H_INCLUDED</span> |
| 00021 <span class="preprocessor"></span> |
| 00022 <span class="preprocessor">#ifndef OSCL_BASE_H_INCLUDED</span> |
| 00023 <span class="preprocessor"></span><span class="preprocessor">#include "<a class="code" href="oscl__base_8h.html">oscl_base.h</a>"</span> |
| 00024 <span class="preprocessor">#endif</span> |
| 00025 <span class="preprocessor"></span> |
| 00026 <span class="preprocessor">#ifndef OSCL_REFCOUNTER_H_INCLUDED</span> |
| 00027 <span class="preprocessor"></span><span class="preprocessor">#include "<a class="code" href="oscl__refcounter_8h.html">oscl_refcounter.h</a>"</span> |
| 00028 <span class="preprocessor">#endif</span> |
| 00029 <span class="preprocessor"></span> |
| <a name="l00030"></a><a class="code" href="group__osclbase.html#a105">00030</a> <span class="preprocessor">#define OSCL_DISABLE_WARNING_RETURN_TYPE_NOT_UDT</span> |
| 00031 <span class="preprocessor"></span><span class="preprocessor">#include "<a class="code" href="osclconfig__compiler__warnings_8h.html">osclconfig_compiler_warnings.h</a>"</span> |
| 00032 |
| 00034 <span class="keyword">template</span> <<span class="keyword">class</span> TheClass> |
| <a name="l00035"></a><a class="code" href="classOsclSharedPtr.html">00035</a> <span class="keyword">class </span><a class="code" href="classOsclSharedPtr.html">OsclSharedPtr</a> |
| 00036 { |
| 00037 <span class="keyword">public</span>: |
| <a name="l00039"></a><a class="code" href="classOsclSharedPtr.html#a0">00039</a> <a class="code" href="classOsclSharedPtr.html#a0">OsclSharedPtr</a>() : |
| 00040 mpRep(<a class="code" href="group__osclbase.html#a81">NULL</a>), refcnt(<a class="code" href="group__osclbase.html#a81">NULL</a>) {} |
| 00041 |
| 00043 |
| <a name="l00046"></a><a class="code" href="classOsclSharedPtr.html#a1">00046</a> <a class="code" href="classOsclSharedPtr.html#a0">OsclSharedPtr</a>(TheClass* inClassPtr, <a class="code" href="classOsclRefCounter.html">OsclRefCounter</a>* in_refcnt) : |
| 00047 mpRep(inClassPtr), refcnt(in_refcnt) {}; |
| 00048 |
| 00049 |
| <a name="l00051"></a><a class="code" href="classOsclSharedPtr.html#a2">00051</a> <a class="code" href="classOsclSharedPtr.html#a0">OsclSharedPtr</a>(<span class="keyword">const</span> <a class="code" href="classOsclSharedPtr.html">OsclSharedPtr</a>& inSharedPtr) : |
| 00052 mpRep(inSharedPtr.mpRep), refcnt(inSharedPtr.refcnt) |
| 00053 { |
| 00054 <span class="keywordflow">if</span> (refcnt) |
| 00055 { |
| 00056 refcnt-><a class="code" href="classOsclRefCounter.html#a0">addRef</a>(); |
| 00057 } |
| 00058 } |
| 00059 |
| 00060 |
| <a name="l00062"></a><a class="code" href="classOsclSharedPtr.html#a3">00062</a> <span class="keyword">virtual</span> <a class="code" href="classOsclSharedPtr.html#a3">~OsclSharedPtr</a>() |
| 00063 { |
| 00064 <span class="keywordflow">if</span> (refcnt != <a class="code" href="group__osclbase.html#a81">NULL</a>) |
| 00065 { |
| 00066 refcnt-><a class="code" href="classOsclRefCounter.html#a1">removeRef</a>(); |
| 00067 } |
| 00068 } <span class="comment">// end destructor</span> |
| 00069 |
| 00070 |
| <a name="l00073"></a><a class="code" href="classOsclSharedPtr.html#a4">00073</a> TheClass* <a class="code" href="classOsclSharedPtr.html#a4">operator-></a>() |
| 00074 { |
| 00075 <span class="keywordflow">return</span> mpRep; |
| 00076 } |
| 00077 |
| <a name="l00079"></a><a class="code" href="classOsclSharedPtr.html#a5">00079</a> TheClass& <a class="code" href="classOsclSharedPtr.html#a5">operator*</a>() |
| 00080 { |
| 00081 <span class="keywordflow">return</span> *mpRep; |
| 00082 } |
| 00083 |
| <a name="l00085"></a><a class="code" href="classOsclSharedPtr.html#a6">00085</a> <a class="code" href="classOsclSharedPtr.html#a6">operator TheClass*</a>() |
| 00086 { |
| 00087 <span class="keywordflow">return</span> mpRep; |
| 00088 } |
| 00089 |
| <a name="l00091"></a><a class="code" href="classOsclSharedPtr.html#a7">00091</a> TheClass* <a class="code" href="classOsclSharedPtr.html#a7">GetRep</a>() |
| 00092 { |
| 00093 <span class="keywordflow">return</span> mpRep; |
| 00094 } |
| 00095 |
| <a name="l00097"></a><a class="code" href="classOsclSharedPtr.html#a8">00097</a> <a class="code" href="classOsclRefCounter.html">OsclRefCounter</a>* <a class="code" href="classOsclSharedPtr.html#a8">GetRefCounter</a>() |
| 00098 { |
| 00099 <span class="keywordflow">return</span> refcnt; |
| 00100 } |
| 00101 |
| <a name="l00103"></a><a class="code" href="classOsclSharedPtr.html#a9">00103</a> <span class="keywordtype">int</span> <a class="code" href="classOsclSharedPtr.html#a9">get_count</a>() |
| 00104 { |
| 00105 <span class="keywordflow">return</span> (refcnt == <a class="code" href="group__osclbase.html#a81">NULL</a>) ? 0 : refcnt-><a class="code" href="classOsclRefCounter.html#a2">getCount</a>(); |
| 00106 } |
| 00107 |
| 00109 <span class="keywordtype">void</span> <a class="code" href="group__osclbase.html#a111">Bind</a>(<span class="keyword">const</span> <a class="code" href="classOsclSharedPtr.html">OsclSharedPtr</a>& inHandle); |
| 00110 |
| 00112 <span class="keywordtype">void</span> <a class="code" href="group__osclbase.html#a111">Bind</a>(TheClass* ptr, <a class="code" href="classOsclRefCounter.html">OsclRefCounter</a>* in_refcnt); |
| 00113 |
| <a name="l00115"></a><a class="code" href="classOsclSharedPtr.html#a12">00115</a> <span class="keywordtype">void</span> <a class="code" href="classOsclSharedPtr.html#a12">Unbind</a>() |
| 00116 { |
| 00117 <a class="code" href="group__osclbase.html#a111">Bind</a>(<a class="code" href="group__osclbase.html#a81">NULL</a>, <a class="code" href="group__osclbase.html#a81">NULL</a>); |
| 00118 }; |
| 00119 |
| <a name="l00121"></a><a class="code" href="classOsclSharedPtr.html#a13">00121</a> <a class="code" href="classOsclSharedPtr.html">OsclSharedPtr</a>& <a class="code" href="classOsclSharedPtr.html#a13">operator=</a>(<span class="keyword">const</span> <a class="code" href="classOsclSharedPtr.html">OsclSharedPtr</a>& inSharedPtr) |
| 00122 { |
| 00123 <a class="code" href="group__osclbase.html#a111">Bind</a>(inSharedPtr); |
| 00124 <span class="keywordflow">return</span> *<span class="keyword">this</span>; |
| 00125 } |
| 00126 |
| 00128 <span class="keywordtype">bool</span> <a class="code" href="group__osclbase.html#a110">operator==</a>(<span class="keyword">const</span> <a class="code" href="classOsclSharedPtr.html">OsclSharedPtr</a>& b) <span class="keyword">const</span>; |
| 00129 |
| 00130 <span class="keyword">private</span>: |
| 00131 |
| 00132 TheClass* mpRep; |
| 00133 <a class="code" href="classOsclRefCounter.html">OsclRefCounter</a>* refcnt; |
| 00134 |
| 00135 }; |
| 00136 |
| 00137 |
| <a name="l00138"></a><a class="code" href="classOsclSharedPtr.html#a110">00138</a> <span class="keyword">template</span> <<span class="keyword">class</span> TheClass> <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code" href="group__osclbase.html#a110">OsclSharedPtr<TheClass>::operator==</a>(<span class="keyword">const</span> <a class="code" href="classOsclSharedPtr.html">OsclSharedPtr<TheClass></a>& b)<span class="keyword"> const</span> |
| 00139 <span class="keyword"></span>{ |
| 00140 <span class="keywordflow">if</span> ((this->mpRep == b.<a class="code" href="classOsclSharedPtr.html#o0">mpRep</a>) && |
| 00141 (this->refcnt == b.<a class="code" href="classOsclSharedPtr.html#o1">refcnt</a>)) |
| 00142 { |
| 00143 <span class="keywordflow">return</span> <span class="keyword">true</span>; |
| 00144 } |
| 00145 <span class="keywordflow">return</span> <span class="keyword">false</span>; |
| 00146 } |
| 00147 |
| 00148 |
| <a name="l00149"></a><a class="code" href="classOsclSharedPtr.html#a111">00149</a> <span class="keyword">template</span> <<span class="keyword">class</span> TheClass> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="group__osclbase.html#a111">OsclSharedPtr<TheClass>::Bind</a>(<span class="keyword">const</span> <a class="code" href="classOsclSharedPtr.html">OsclSharedPtr</a>& inSharedPtr) |
| 00150 { |
| 00151 <span class="keywordflow">if</span> (mpRep == inSharedPtr.<a class="code" href="classOsclSharedPtr.html#o0">mpRep</a>) <span class="keywordflow">return</span>; |
| 00152 |
| 00153 <span class="keywordflow">if</span> (refcnt != <a class="code" href="group__osclbase.html#a81">NULL</a>) |
| 00154 { |
| 00155 refcnt-><a class="code" href="classOsclRefCounter.html#a1">removeRef</a>(); |
| 00156 } |
| 00157 |
| 00158 refcnt = inSharedPtr.<a class="code" href="classOsclSharedPtr.html#o1">refcnt</a>; |
| 00159 mpRep = inSharedPtr.<a class="code" href="classOsclSharedPtr.html#o0">mpRep</a>; |
| 00160 |
| 00161 <span class="keywordflow">if</span> (refcnt != <a class="code" href="group__osclbase.html#a81">NULL</a>) |
| 00162 { |
| 00163 refcnt-><a class="code" href="classOsclRefCounter.html#a0">addRef</a>(); |
| 00164 } |
| 00165 |
| 00166 } |
| 00167 |
| <a name="l00168"></a><a class="code" href="classOsclSharedPtr.html#a112">00168</a> <span class="keyword">template</span> <<span class="keyword">class</span> TheClass> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="group__osclbase.html#a111">OsclSharedPtr<TheClass>::Bind</a>(TheClass* ptr, |
| 00169 <a class="code" href="classOsclRefCounter.html">OsclRefCounter</a>* in_refcnt) |
| 00170 { |
| 00171 <span class="keywordflow">if</span> (refcnt != <a class="code" href="group__osclbase.html#a81">NULL</a>) |
| 00172 { |
| 00173 refcnt-><a class="code" href="classOsclRefCounter.html#a1">removeRef</a>(); |
| 00174 } |
| 00175 |
| 00176 mpRep = ptr; |
| 00177 refcnt = in_refcnt; |
| 00178 |
| 00179 } |
| 00180 |
| 00181 <span class="preprocessor">#endif // OSCL_SHARED_PTR_H_INCLUDED</span> |
| </pre></div><hr size="1"><img src="pvlogo_small.jpg"><address style="align: right;"><small>OSCL API</small> |
| <address style="align: left;"><small>Posting Version: OPENCORE_20090310 </small> |
| </small></address> |
| </body> |
| </html> |