• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
3<title>oscl_exclusive_ptr.h Source File</title>
4<link href="doxygen.css" rel="stylesheet" type="text/css">
5</head><body>
6<!-- Generated by Doxygen 1.2.18 -->
7<center>
8<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>
9<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>
1000002 <span class="comment">// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =</span>
1100003
1200004 <span class="comment">//               O S C L _ E X C L U S I V E _ P T R</span>
1300005
1400006 <span class="comment">// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =</span>
1500007
1600023 <span class="preprocessor">#ifndef OSCL_EXCLUSIVE_PTR_H_INCLUDED</span>
1700024 <span class="preprocessor"></span><span class="preprocessor">#define OSCL_EXCLUSIVE_PTR_H_INCLUDED</span>
1800025 <span class="preprocessor"></span>
1900026 <span class="preprocessor">#ifndef OSCL_DEFALLOC_H_INCLUDED</span>
2000027 <span class="preprocessor"></span><span class="preprocessor">#include "<a class="code" href="oscl__defalloc_8h.html">oscl_defalloc.h</a>"</span>
2100028 <span class="preprocessor">#endif</span>
2200029 <span class="preprocessor"></span>
2300030 <span class="preprocessor">#ifndef OSCL_BASE_H_INCLUDED</span>
2400031 <span class="preprocessor"></span><span class="preprocessor">#include "<a class="code" href="oscl__base_8h.html">oscl_base.h</a>"</span>
2500032 <span class="preprocessor">#endif</span>
2600033 <span class="preprocessor"></span>
27<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>
2800052 {
2900053     <span class="keyword">protected</span>:
30<a name="l00054"></a><a class="code" href="classOsclExclusivePtr.html#n0">00054</a>         T* <a class="code" href="classOsclExclusivePtr.html#n0">_Ptr</a>;
3100055
3200056     <span class="keyword">public</span>:
3300057
34<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) {};
3500063
36<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>()) {};
3700072
3800073
39<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)
4000088         {
4100089             <span class="keywordflow">if</span> (<span class="keyword">this</span> != &amp;_Y)
4200090             {
4300091                 <span class="keywordflow">if</span> (<a class="code" href="classOsclExclusivePtr.html#n0">_Ptr</a> != _Y.<a class="code" href="classOsclExclusivePtr.html#a6">get</a>())
4400092                 {
4500093                     <span class="keyword">delete</span> <a class="code" href="classOsclExclusivePtr.html#n0">_Ptr</a>;
4600094                 }
4700095                 <a class="code" href="classOsclExclusivePtr.html#n0">_Ptr</a> = _Y.<a class="code" href="classOsclExclusivePtr.html#a7">release</a>();
4800096             }
4900097             <span class="keywordflow">return</span> (*this);
5000098         }
5100099
52<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>()
5300106         {
5400107             <span class="keywordflow">if</span> (_Ptr)
5500108                 <span class="keyword">delete</span> <a class="code" href="classOsclExclusivePtr.html#n0">_Ptr</a>;
5600109         }
5700110
58<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>
5900119 <span class="keyword">        </span>{
6000120             <span class="keywordflow">return</span> (*<a class="code" href="classOsclExclusivePtr.html#a6">get</a>());
6100121         }
6200122
63<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>
6400131 <span class="keyword">        </span>{
6500132             <span class="keywordflow">return</span> (<a class="code" href="classOsclExclusivePtr.html#a6">get</a>());
6600133         }
6700134
68<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>
6900140 <span class="keyword">        </span>{
7000141             <span class="keywordflow">return</span> (_Ptr);
7100142         }
7200143
73<a name="l00149"></a><a class="code" href="classOsclExclusivePtr.html#a7">00149</a>         T *<a class="code" href="classOsclExclusivePtr.html#a7">release</a>()
7400150         {
7500151             T *tmp = <a class="code" href="classOsclExclusivePtr.html#n0">_Ptr</a>;
7600152             <a class="code" href="classOsclExclusivePtr.html#n0">_Ptr</a> = <a class="code" href="group__osclbase.html#a81">NULL</a>;
7700153             <span class="keywordflow">return</span> (tmp);
7800154         }
7900155
80<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)
8100163         {
8200164             <span class="keywordflow">if</span> ((<a class="code" href="classOsclExclusivePtr.html#n0">_Ptr</a> == <a class="code" href="group__osclbase.html#a81">NULL</a>))
8300165             {
8400166                 <a class="code" href="classOsclExclusivePtr.html#n0">_Ptr</a> = ptr;
8500167                 <span class="keywordflow">return</span> <span class="keyword">true</span>;
8600168             }
8700169             <span class="keywordflow">return</span> <span class="keyword">false</span>;
8800170         }
8900171
9000172 };
9100173
92<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>
9300191 {
9400192     <span class="keyword">protected</span>:
95<a name="l00193"></a><a class="code" href="classOsclExclusiveArrayPtr.html#n0">00193</a>         T* <a class="code" href="classOsclExclusiveArrayPtr.html#n0">_Ptr</a>;
9600194
9700195     <span class="keyword">public</span>:
9800196
99<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) {};
10000202
101<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>()) {};
10200211
10300212
104<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)
10500227         {
10600228             <span class="keywordflow">if</span> (<span class="keyword">this</span> != &amp;_Y)
10700229             {
10800230                 <span class="keywordflow">if</span> (<a class="code" href="classOsclExclusiveArrayPtr.html#n0">_Ptr</a> != _Y.<a class="code" href="classOsclExclusiveArrayPtr.html#a6">get</a>())
10900231                 {
11000232                     <span class="keyword">delete</span> [] <a class="code" href="classOsclExclusiveArrayPtr.html#n0">_Ptr</a>;
11100233                 }
11200234                 <a class="code" href="classOsclExclusiveArrayPtr.html#n0">_Ptr</a> = _Y.<a class="code" href="classOsclExclusiveArrayPtr.html#a7">release</a>();
11300235             }
11400236             <span class="keywordflow">return</span> (*this);
11500237         }
11600238
117<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>()
11800245         {
11900246             <span class="keywordflow">if</span> (_Ptr)
12000247                 <span class="keyword">delete</span> [] <a class="code" href="classOsclExclusiveArrayPtr.html#n0">_Ptr</a>;
12100248         }
12200249
123<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>
12400258 <span class="keyword">        </span>{
12500259             <span class="keywordflow">return</span> (*<a class="code" href="classOsclExclusiveArrayPtr.html#a6">get</a>());
12600260         }
12700261
128<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>
12900270 <span class="keyword">        </span>{
13000271             <span class="keywordflow">return</span> (<a class="code" href="classOsclExclusiveArrayPtr.html#a6">get</a>());
13100272         }
13200273
133<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>
13400279 <span class="keyword">        </span>{
13500280             <span class="keywordflow">return</span> (_Ptr);
13600281         }
13700282
138<a name="l00288"></a><a class="code" href="classOsclExclusiveArrayPtr.html#a7">00288</a>         T *<a class="code" href="classOsclExclusiveArrayPtr.html#a7">release</a>()
13900289         {
14000290             T *tmp = <a class="code" href="classOsclExclusiveArrayPtr.html#n0">_Ptr</a>;
14100291             <a class="code" href="classOsclExclusiveArrayPtr.html#n0">_Ptr</a> = <a class="code" href="group__osclbase.html#a81">NULL</a>;
14200292             <span class="keywordflow">return</span> (tmp);
14300293         }
14400294
145<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)
14600302         {
14700303             <span class="keywordflow">if</span> ((<a class="code" href="classOsclExclusiveArrayPtr.html#n0">_Ptr</a> == <a class="code" href="group__osclbase.html#a81">NULL</a>))
14800304             {
14900305                 <a class="code" href="classOsclExclusiveArrayPtr.html#n0">_Ptr</a> = ptr;
15000306                 <span class="keywordflow">return</span> <span class="keyword">true</span>;
15100307             }
15200308             <span class="keywordflow">return</span> <span class="keyword">false</span>;
15300309         }
15400310
15500311 };
15600312
15700313
158<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>
15900331 {
16000332     <span class="keyword">protected</span>:
161<a name="l00333"></a><a class="code" href="classOsclExclusivePtrA.html#n0">00333</a>         T* <a class="code" href="classOsclExclusivePtrA.html#n0">_Ptr</a>;
16200334
16300335     <span class="keyword">public</span>:
16400336
165<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) {};
16600342
167<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>()) {};
16800351
16900352
170<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)
17100367         {
17200368             <span class="keywordflow">if</span> (<span class="keyword">this</span> != &amp;_Y)
17300369             {
17400370                 <span class="keywordflow">if</span> (<a class="code" href="classOsclExclusivePtrA.html#n0">_Ptr</a> != _Y.<a class="code" href="classOsclExclusivePtrA.html#a6">get</a>())
17500371                 {
17600372                     defAlloc.deallocate(<a class="code" href="classOsclExclusivePtrA.html#n0">_Ptr</a>);
17700373                 }
17800374                 <a class="code" href="classOsclExclusivePtrA.html#n0">_Ptr</a> = _Y.<a class="code" href="classOsclExclusivePtrA.html#a7">release</a>();
17900375             }
18000376             <span class="keywordflow">return</span> (*this);
18100377         }
18200378
183<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>()
18400385         {
18500386             defAlloc.deallocate(<a class="code" href="classOsclExclusivePtrA.html#n0">_Ptr</a>);
18600387         }
18700388
188<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>
18900397 <span class="keyword">        </span>{
19000398             <span class="keywordflow">return</span> (*<a class="code" href="classOsclExclusivePtrA.html#a6">get</a>());
19100399         }
19200400
193<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>
19400409 <span class="keyword">        </span>{
19500410             <span class="keywordflow">return</span> (<a class="code" href="classOsclExclusivePtrA.html#a6">get</a>());
19600411         }
19700412
198<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>
19900418 <span class="keyword">        </span>{
20000419             <span class="keywordflow">return</span> (_Ptr);
20100420         }
20200421
203<a name="l00427"></a><a class="code" href="classOsclExclusivePtrA.html#a7">00427</a>         T *<a class="code" href="classOsclExclusivePtrA.html#a7">release</a>()
20400428         {
20500429             T *tmp = <a class="code" href="classOsclExclusivePtrA.html#n0">_Ptr</a>;
20600430             <a class="code" href="classOsclExclusivePtrA.html#n0">_Ptr</a> = <a class="code" href="group__osclbase.html#a81">NULL</a>;
20700431             <span class="keywordflow">return</span> (tmp);
20800432         }
20900433
210<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)
21100441         {
21200442             <span class="keywordflow">if</span> ((<a class="code" href="classOsclExclusivePtrA.html#n0">_Ptr</a> == <a class="code" href="group__osclbase.html#a81">NULL</a>))
21300443             {
21400444                 <a class="code" href="classOsclExclusivePtrA.html#n0">_Ptr</a> = ptr;
21500445                 <span class="keywordflow">return</span> <span class="keyword">true</span>;
21600446             }
21700447             <span class="keywordflow">return</span> <span class="keyword">false</span>;
21800448         }
21900449
22000450     <span class="keyword">private</span>:
22100451         <a class="code" href="classOscl__TAlloc.html">Oscl_TAlloc&lt;T, Alloc&gt;</a> defAlloc;
22200452 };
22300453
22400457 <span class="preprocessor">#endif //OSCL_EXCLUSIVE_PTR_H_INCLUDED</span>
22500458 <span class="preprocessor"></span>
226</pre></div><hr size="1"><img src="pvlogo_small.jpg"><address style="align: right;"><small>OSCL API</small>
227<address style="align: left;"><small>Posting Version: OPENCORE_20090310 </small>
228</small></address>
229</body>
230</html>
231