blob: 1c9dad62c6ef4194d2229129162fa056a7e26974 [file] [log] [blame]
<!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_exclusive_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> &nbsp; <a class="qindex" href="modules.html">Modules</a> &nbsp; <a class="qindex" href="hierarchy.html">Class Hierarchy</a> &nbsp; <a class="qindex" href="annotated.html">Data Structures</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="functions.html">Data Fields</a> &nbsp; <a class="qindex" href="globals.html">Globals</a> &nbsp; </center>
<hr><h1>oscl_exclusive_ptr.h</h1><a href="oscl__exclusive__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 _ E X C L U S I V E _ P T R</span>
00005
00006 <span class="comment">// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =</span>
00007
00023 <span class="preprocessor">#ifndef OSCL_EXCLUSIVE_PTR_H_INCLUDED</span>
00024 <span class="preprocessor"></span><span class="preprocessor">#define OSCL_EXCLUSIVE_PTR_H_INCLUDED</span>
00025 <span class="preprocessor"></span>
00026 <span class="preprocessor">#ifndef OSCL_DEFALLOC_H_INCLUDED</span>
00027 <span class="preprocessor"></span><span class="preprocessor">#include "<a class="code" href="oscl__defalloc_8h.html">oscl_defalloc.h</a>"</span>
00028 <span class="preprocessor">#endif</span>
00029 <span class="preprocessor"></span>
00030 <span class="preprocessor">#ifndef OSCL_BASE_H_INCLUDED</span>
00031 <span class="preprocessor"></span><span class="preprocessor">#include "<a class="code" href="oscl__base_8h.html">oscl_base.h</a>"</span>
00032 <span class="preprocessor">#endif</span>
00033 <span class="preprocessor"></span>
<a name="l00051"></a><a class="code" href="classOsclExclusivePtr.html">00051</a> <span class="keyword">template</span>&lt;<span class="keyword">class</span> T&gt; <span class="keyword">class </span><a class="code" href="classOsclExclusivePtr.html">OsclExclusivePtr</a>
00052 {
00053 <span class="keyword">protected</span>:
<a name="l00054"></a><a class="code" href="classOsclExclusivePtr.html#n0">00054</a> T* <a class="code" href="classOsclExclusivePtr.html#n0">_Ptr</a>;
00055
00056 <span class="keyword">public</span>:
00057
<a name="l00062"></a><a class="code" href="classOsclExclusivePtr.html#a0">00062</a> <span class="keyword">explicit</span> <a class="code" href="classOsclExclusivePtr.html#a0">OsclExclusivePtr</a>(T* inPtr = 0) : <a class="code" href="classOsclExclusivePtr.html#n0">_Ptr</a>(inPtr) {};
00063
<a name="l00071"></a><a class="code" href="classOsclExclusivePtr.html#a1">00071</a> <a class="code" href="classOsclExclusivePtr.html#a0">OsclExclusivePtr</a>(<a class="code" href="classOsclExclusivePtr.html">OsclExclusivePtr&lt;T&gt;</a>&amp; _Y): <a class="code" href="classOsclExclusivePtr.html#n0">_Ptr</a>(_Y.<a class="code" href="classOsclExclusivePtr.html#a7">release</a>()) {};
00072
00073
<a name="l00087"></a><a class="code" href="classOsclExclusivePtr.html#a2">00087</a> <a class="code" href="classOsclExclusivePtr.html">OsclExclusivePtr&lt;T&gt;</a>&amp; <a class="code" href="classOsclExclusivePtr.html#a2">operator=</a>(<a class="code" href="classOsclExclusivePtr.html">OsclExclusivePtr&lt;T&gt;</a>&amp; _Y)
00088 {
00089 <span class="keywordflow">if</span> (<span class="keyword">this</span> != &amp;_Y)
00090 {
00091 <span class="keywordflow">if</span> (<a class="code" href="classOsclExclusivePtr.html#n0">_Ptr</a> != _Y.<a class="code" href="classOsclExclusivePtr.html#a6">get</a>())
00092 {
00093 <span class="keyword">delete</span> <a class="code" href="classOsclExclusivePtr.html#n0">_Ptr</a>;
00094 }
00095 <a class="code" href="classOsclExclusivePtr.html#n0">_Ptr</a> = _Y.<a class="code" href="classOsclExclusivePtr.html#a7">release</a>();
00096 }
00097 <span class="keywordflow">return</span> (*this);
00098 }
00099
<a name="l00105"></a><a class="code" href="classOsclExclusivePtr.html#a3">00105</a> <span class="keyword">virtual</span> <a class="code" href="classOsclExclusivePtr.html#a3">~OsclExclusivePtr</a>()
00106 {
00107 <span class="keywordflow">if</span> (_Ptr)
00108 <span class="keyword">delete</span> <a class="code" href="classOsclExclusivePtr.html#n0">_Ptr</a>;
00109 }
00110
<a name="l00118"></a><a class="code" href="classOsclExclusivePtr.html#a4">00118</a> T&amp; <a class="code" href="classOsclExclusivePtr.html#a4">operator*</a>()<span class="keyword"> const</span>
00119 <span class="keyword"> </span>{
00120 <span class="keywordflow">return</span> (*<a class="code" href="classOsclExclusivePtr.html#a6">get</a>());
00121 }
00122
<a name="l00130"></a><a class="code" href="classOsclExclusivePtr.html#a5">00130</a> T *<a class="code" href="classOsclExclusivePtr.html#a5">operator-&gt;</a>()<span class="keyword"> const</span>
00131 <span class="keyword"> </span>{
00132 <span class="keywordflow">return</span> (<a class="code" href="classOsclExclusivePtr.html#a6">get</a>());
00133 }
00134
<a name="l00139"></a><a class="code" href="classOsclExclusivePtr.html#a6">00139</a> T *<a class="code" href="classOsclExclusivePtr.html#a6">get</a>()<span class="keyword"> const</span>
00140 <span class="keyword"> </span>{
00141 <span class="keywordflow">return</span> (_Ptr);
00142 }
00143
<a name="l00149"></a><a class="code" href="classOsclExclusivePtr.html#a7">00149</a> T *<a class="code" href="classOsclExclusivePtr.html#a7">release</a>()
00150 {
00151 T *tmp = <a class="code" href="classOsclExclusivePtr.html#n0">_Ptr</a>;
00152 <a class="code" href="classOsclExclusivePtr.html#n0">_Ptr</a> = <a class="code" href="group__osclbase.html#a81">NULL</a>;
00153 <span class="keywordflow">return</span> (tmp);
00154 }
00155
<a name="l00162"></a><a class="code" href="classOsclExclusivePtr.html#a8">00162</a> <span class="keywordtype">bool</span> <a class="code" href="classOsclExclusivePtr.html#a8">set</a>(T* ptr)
00163 {
00164 <span class="keywordflow">if</span> ((<a class="code" href="classOsclExclusivePtr.html#n0">_Ptr</a> == <a class="code" href="group__osclbase.html#a81">NULL</a>))
00165 {
00166 <a class="code" href="classOsclExclusivePtr.html#n0">_Ptr</a> = ptr;
00167 <span class="keywordflow">return</span> <span class="keyword">true</span>;
00168 }
00169 <span class="keywordflow">return</span> <span class="keyword">false</span>;
00170 }
00171
00172 };
00173
<a name="l00190"></a><a class="code" href="classOsclExclusiveArrayPtr.html">00190</a> <span class="keyword">template</span>&lt;<span class="keyword">class</span> T&gt; <span class="keyword">class </span><a class="code" href="classOsclExclusiveArrayPtr.html">OsclExclusiveArrayPtr</a>
00191 {
00192 <span class="keyword">protected</span>:
<a name="l00193"></a><a class="code" href="classOsclExclusiveArrayPtr.html#n0">00193</a> T* <a class="code" href="classOsclExclusiveArrayPtr.html#n0">_Ptr</a>;
00194
00195 <span class="keyword">public</span>:
00196
<a name="l00201"></a><a class="code" href="classOsclExclusiveArrayPtr.html#a0">00201</a> <span class="keyword">explicit</span> <a class="code" href="classOsclExclusiveArrayPtr.html#a0">OsclExclusiveArrayPtr</a>(T* inPtr = 0) : <a class="code" href="classOsclExclusiveArrayPtr.html#n0">_Ptr</a>(inPtr) {};
00202
<a name="l00210"></a><a class="code" href="classOsclExclusiveArrayPtr.html#a1">00210</a> <a class="code" href="classOsclExclusiveArrayPtr.html#a0">OsclExclusiveArrayPtr</a>(<a class="code" href="classOsclExclusiveArrayPtr.html">OsclExclusiveArrayPtr&lt;T&gt;</a>&amp; _Y): <a class="code" href="classOsclExclusiveArrayPtr.html#n0">_Ptr</a>(_Y.<a class="code" href="classOsclExclusiveArrayPtr.html#a7">release</a>()) {};
00211
00212
<a name="l00226"></a><a class="code" href="classOsclExclusiveArrayPtr.html#a2">00226</a> <a class="code" href="classOsclExclusiveArrayPtr.html">OsclExclusiveArrayPtr&lt;T&gt;</a>&amp; <a class="code" href="classOsclExclusiveArrayPtr.html#a2">operator=</a>(<a class="code" href="classOsclExclusiveArrayPtr.html">OsclExclusiveArrayPtr&lt;T&gt;</a>&amp; _Y)
00227 {
00228 <span class="keywordflow">if</span> (<span class="keyword">this</span> != &amp;_Y)
00229 {
00230 <span class="keywordflow">if</span> (<a class="code" href="classOsclExclusiveArrayPtr.html#n0">_Ptr</a> != _Y.<a class="code" href="classOsclExclusiveArrayPtr.html#a6">get</a>())
00231 {
00232 <span class="keyword">delete</span> [] <a class="code" href="classOsclExclusiveArrayPtr.html#n0">_Ptr</a>;
00233 }
00234 <a class="code" href="classOsclExclusiveArrayPtr.html#n0">_Ptr</a> = _Y.<a class="code" href="classOsclExclusiveArrayPtr.html#a7">release</a>();
00235 }
00236 <span class="keywordflow">return</span> (*this);
00237 }
00238
<a name="l00244"></a><a class="code" href="classOsclExclusiveArrayPtr.html#a3">00244</a> <span class="keyword">virtual</span> <a class="code" href="classOsclExclusiveArrayPtr.html#a3">~OsclExclusiveArrayPtr</a>()
00245 {
00246 <span class="keywordflow">if</span> (_Ptr)
00247 <span class="keyword">delete</span> [] <a class="code" href="classOsclExclusiveArrayPtr.html#n0">_Ptr</a>;
00248 }
00249
<a name="l00257"></a><a class="code" href="classOsclExclusiveArrayPtr.html#a4">00257</a> T&amp; <a class="code" href="classOsclExclusiveArrayPtr.html#a4">operator*</a>()<span class="keyword"> const</span>
00258 <span class="keyword"> </span>{
00259 <span class="keywordflow">return</span> (*<a class="code" href="classOsclExclusiveArrayPtr.html#a6">get</a>());
00260 }
00261
<a name="l00269"></a><a class="code" href="classOsclExclusiveArrayPtr.html#a5">00269</a> T *<a class="code" href="classOsclExclusiveArrayPtr.html#a5">operator-&gt;</a>()<span class="keyword"> const</span>
00270 <span class="keyword"> </span>{
00271 <span class="keywordflow">return</span> (<a class="code" href="classOsclExclusiveArrayPtr.html#a6">get</a>());
00272 }
00273
<a name="l00278"></a><a class="code" href="classOsclExclusiveArrayPtr.html#a6">00278</a> T *<a class="code" href="classOsclExclusiveArrayPtr.html#a6">get</a>()<span class="keyword"> const</span>
00279 <span class="keyword"> </span>{
00280 <span class="keywordflow">return</span> (_Ptr);
00281 }
00282
<a name="l00288"></a><a class="code" href="classOsclExclusiveArrayPtr.html#a7">00288</a> T *<a class="code" href="classOsclExclusiveArrayPtr.html#a7">release</a>()
00289 {
00290 T *tmp = <a class="code" href="classOsclExclusiveArrayPtr.html#n0">_Ptr</a>;
00291 <a class="code" href="classOsclExclusiveArrayPtr.html#n0">_Ptr</a> = <a class="code" href="group__osclbase.html#a81">NULL</a>;
00292 <span class="keywordflow">return</span> (tmp);
00293 }
00294
<a name="l00301"></a><a class="code" href="classOsclExclusiveArrayPtr.html#a8">00301</a> <span class="keywordtype">bool</span> <a class="code" href="classOsclExclusiveArrayPtr.html#a8">set</a>(T* ptr)
00302 {
00303 <span class="keywordflow">if</span> ((<a class="code" href="classOsclExclusiveArrayPtr.html#n0">_Ptr</a> == <a class="code" href="group__osclbase.html#a81">NULL</a>))
00304 {
00305 <a class="code" href="classOsclExclusiveArrayPtr.html#n0">_Ptr</a> = ptr;
00306 <span class="keywordflow">return</span> <span class="keyword">true</span>;
00307 }
00308 <span class="keywordflow">return</span> <span class="keyword">false</span>;
00309 }
00310
00311 };
00312
00313
<a name="l00330"></a><a class="code" href="classOsclExclusivePtrA.html">00330</a> <span class="keyword">template</span>&lt;<span class="keyword">class</span> T, <span class="keyword">class</span> Alloc&gt; <span class="keyword">class </span><a class="code" href="classOsclExclusivePtrA.html">OsclExclusivePtrA</a>
00331 {
00332 <span class="keyword">protected</span>:
<a name="l00333"></a><a class="code" href="classOsclExclusivePtrA.html#n0">00333</a> T* <a class="code" href="classOsclExclusivePtrA.html#n0">_Ptr</a>;
00334
00335 <span class="keyword">public</span>:
00336
<a name="l00341"></a><a class="code" href="classOsclExclusivePtrA.html#a0">00341</a> <span class="keyword">explicit</span> <a class="code" href="classOsclExclusivePtrA.html#a0">OsclExclusivePtrA</a>(T* inPtr = 0) : <a class="code" href="classOsclExclusivePtrA.html#n0">_Ptr</a>(inPtr) {};
00342
<a name="l00350"></a><a class="code" href="classOsclExclusivePtrA.html#a1">00350</a> <a class="code" href="classOsclExclusivePtrA.html#a0">OsclExclusivePtrA</a>(<a class="code" href="classOsclExclusivePtrA.html">OsclExclusivePtrA&lt;T, Alloc&gt;</a>&amp; _Y): <a class="code" href="classOsclExclusivePtrA.html#n0">_Ptr</a>(_Y.<a class="code" href="classOsclExclusivePtrA.html#a7">release</a>()) {};
00351
00352
<a name="l00366"></a><a class="code" href="classOsclExclusivePtrA.html#a2">00366</a> <a class="code" href="classOsclExclusivePtrA.html">OsclExclusivePtrA&lt;T, Alloc&gt;</a>&amp; <a class="code" href="classOsclExclusivePtrA.html#a2">operator=</a>(<a class="code" href="classOsclExclusivePtrA.html">OsclExclusivePtrA&lt;T, Alloc&gt;</a>&amp; _Y)
00367 {
00368 <span class="keywordflow">if</span> (<span class="keyword">this</span> != &amp;_Y)
00369 {
00370 <span class="keywordflow">if</span> (<a class="code" href="classOsclExclusivePtrA.html#n0">_Ptr</a> != _Y.<a class="code" href="classOsclExclusivePtrA.html#a6">get</a>())
00371 {
00372 defAlloc.deallocate(<a class="code" href="classOsclExclusivePtrA.html#n0">_Ptr</a>);
00373 }
00374 <a class="code" href="classOsclExclusivePtrA.html#n0">_Ptr</a> = _Y.<a class="code" href="classOsclExclusivePtrA.html#a7">release</a>();
00375 }
00376 <span class="keywordflow">return</span> (*this);
00377 }
00378
<a name="l00384"></a><a class="code" href="classOsclExclusivePtrA.html#a3">00384</a> <span class="keyword">virtual</span> <a class="code" href="classOsclExclusivePtrA.html#a3">~OsclExclusivePtrA</a>()
00385 {
00386 defAlloc.deallocate(<a class="code" href="classOsclExclusivePtrA.html#n0">_Ptr</a>);
00387 }
00388
<a name="l00396"></a><a class="code" href="classOsclExclusivePtrA.html#a4">00396</a> T&amp; <a class="code" href="classOsclExclusivePtrA.html#a4">operator*</a>()<span class="keyword"> const</span>
00397 <span class="keyword"> </span>{
00398 <span class="keywordflow">return</span> (*<a class="code" href="classOsclExclusivePtrA.html#a6">get</a>());
00399 }
00400
<a name="l00408"></a><a class="code" href="classOsclExclusivePtrA.html#a5">00408</a> T *<a class="code" href="classOsclExclusivePtrA.html#a5">operator-&gt;</a>()<span class="keyword"> const</span>
00409 <span class="keyword"> </span>{
00410 <span class="keywordflow">return</span> (<a class="code" href="classOsclExclusivePtrA.html#a6">get</a>());
00411 }
00412
<a name="l00417"></a><a class="code" href="classOsclExclusivePtrA.html#a6">00417</a> T *<a class="code" href="classOsclExclusivePtrA.html#a6">get</a>()<span class="keyword"> const</span>
00418 <span class="keyword"> </span>{
00419 <span class="keywordflow">return</span> (_Ptr);
00420 }
00421
<a name="l00427"></a><a class="code" href="classOsclExclusivePtrA.html#a7">00427</a> T *<a class="code" href="classOsclExclusivePtrA.html#a7">release</a>()
00428 {
00429 T *tmp = <a class="code" href="classOsclExclusivePtrA.html#n0">_Ptr</a>;
00430 <a class="code" href="classOsclExclusivePtrA.html#n0">_Ptr</a> = <a class="code" href="group__osclbase.html#a81">NULL</a>;
00431 <span class="keywordflow">return</span> (tmp);
00432 }
00433
<a name="l00440"></a><a class="code" href="classOsclExclusivePtrA.html#a8">00440</a> <span class="keywordtype">bool</span> <a class="code" href="classOsclExclusivePtrA.html#a8">set</a>(T* ptr)
00441 {
00442 <span class="keywordflow">if</span> ((<a class="code" href="classOsclExclusivePtrA.html#n0">_Ptr</a> == <a class="code" href="group__osclbase.html#a81">NULL</a>))
00443 {
00444 <a class="code" href="classOsclExclusivePtrA.html#n0">_Ptr</a> = ptr;
00445 <span class="keywordflow">return</span> <span class="keyword">true</span>;
00446 }
00447 <span class="keywordflow">return</span> <span class="keyword">false</span>;
00448 }
00449
00450 <span class="keyword">private</span>:
00451 <a class="code" href="classOscl__TAlloc.html">Oscl_TAlloc&lt;T, Alloc&gt;</a> defAlloc;
00452 };
00453
00457 <span class="preprocessor">#endif //OSCL_EXCLUSIVE_PTR_H_INCLUDED</span>
00458 <span class="preprocessor"></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>