blob: 63b910d918d31cf1fe3f409fcfaa81a733ca1162 [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> TemplateOsclExclusivePtr&lt; T &gt; 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> &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>OsclExclusivePtr&lt; T &gt; Class Template Reference<br>
<small>
[<a class="el" href="group__osclbase.html">OSCL Base</a>]</small>
</h1>The OsclExclusivePtr class is a template class that defines a pointer like object intended to be assigned an address obtanined (directly or or indirectly) by new. When the OsclExclusivePtr expires, its destructor uses delete to free the memory.
<a href="#_details">More...</a>
<p>
<code>#include &lt;<a class="el" href="oscl__exclusive__ptr_8h-source.html">oscl_exclusive_ptr.h</a>&gt;</code>
<p>
<table border=0 cellpadding=0 cellspacing=0>
<tr><td></td></tr>
<tr><td colspan=2><br><h2>Public Methods</h2></td></tr>
<tr><td nowrap align=right valign=top>&nbsp;</td><td valign=bottom><a class="el" href="classOsclExclusivePtr.html#a0">OsclExclusivePtr</a> (T *inPtr=0)</td></tr>
<tr><td>&nbsp;</td><td><font size=-1><em>Default constructor Initializes the pointer and takes ownership.</em> <a href="#a0"></a><em></em></font><br><br></td></tr>
<tr><td nowrap align=right valign=top>&nbsp;</td><td valign=bottom><a class="el" href="classOsclExclusivePtr.html#a1">OsclExclusivePtr</a> (OsclExclusivePtr&lt; T &gt; &amp;_Y)</td></tr>
<tr><td>&nbsp;</td><td><font size=-1><em>Copy constructor.</em> <a href="#a1"></a><em></em></font><br><br></td></tr>
<tr><td nowrap align=right valign=top>OsclExclusivePtr&lt; T &gt; &amp;&nbsp;</td><td valign=bottom><a class="el" href="classOsclExclusivePtr.html#a2">operator=</a> (OsclExclusivePtr&lt; T &gt; &amp;_Y)</td></tr>
<tr><td>&nbsp;</td><td><font size=-1><em>Assignment operator from an another OsclExclusivePtr.</em> <a href="#a2"></a><em></em></font><br><br></td></tr>
<tr><td nowrap align=right valign=top>virtual&nbsp;</td><td valign=bottom><a class="el" href="classOsclExclusivePtr.html#a3">~OsclExclusivePtr</a> ()</td></tr>
<tr><td>&nbsp;</td><td><font size=-1><em>Destructor.</em> <a href="#a3"></a><em></em></font><br><br></td></tr>
<tr><td nowrap align=right valign=top>T &amp;&nbsp;</td><td valign=bottom><a class="el" href="classOsclExclusivePtr.html#a4">operator *</a> () const</td></tr>
<tr><td>&nbsp;</td><td><font size=-1><em>The indirection operator (*) accesses a value indirectly, through a pointer.</em> <a href="#a4"></a><em></em></font><br><br></td></tr>
<tr><td nowrap align=right valign=top>T *&nbsp;</td><td valign=bottom><a class="el" href="classOsclExclusivePtr.html#a5">operator-&gt;</a> () const</td></tr>
<tr><td>&nbsp;</td><td><font size=-1><em>The indirection operator (-&gt;) accesses a value indirectly, through a pointer.</em> <a href="#a5"></a><em></em></font><br><br></td></tr>
<tr><td nowrap align=right valign=top>T *&nbsp;</td><td valign=bottom><a class="el" href="classOsclExclusivePtr.html#a6">get</a> () const</td></tr>
<tr><td>&nbsp;</td><td><font size=-1><em><a class="el" href="classOsclExclusivePtr.html#a6">get()</a> method returns the pointer, currently owned by the class.</em> <a href="#a6"></a><em></em></font><br><br></td></tr>
<tr><td nowrap align=right valign=top>T *&nbsp;</td><td valign=bottom><a class="el" href="classOsclExclusivePtr.html#a7">release</a> ()</td></tr>
<tr><td>&nbsp;</td><td><font size=-1><em><a class="el" href="classOsclExclusivePtr.html#a7">release()</a> method releases ownership of the pointer, currently owned by the class. It returns the pointer as well.</em> <a href="#a7"></a><em></em></font><br><br></td></tr>
<tr><td nowrap align=right valign=top>bool&nbsp;</td><td valign=bottom><a class="el" href="classOsclExclusivePtr.html#a8">set</a> (T *ptr)</td></tr>
<tr><td>&nbsp;</td><td><font size=-1><em><a class="el" href="classOsclExclusivePtr.html#a8">set()</a> method sets ownership to the pointer, passed. This method is needed when the class is created with a default constructor. Returns false in case the class is non-empty.</em> <a href="#a8"></a><em></em></font><br><br></td></tr>
<tr><td colspan=2><br><h2>Protected Attributes</h2></td></tr>
<tr><td nowrap align=right valign=top>T *&nbsp;</td><td valign=bottom><a class="el" href="classOsclExclusivePtr.html#n0">_Ptr</a></td></tr>
</table>
<hr><a name="_details"></a><h2>Detailed Description</h2>
<h3>template&lt;class T&gt;<br>
class OsclExclusivePtr&lt; T &gt;</h3>
The OsclExclusivePtr class is a template class that defines a pointer like object intended to be assigned an address obtanined (directly or or indirectly) by new. When the OsclExclusivePtr expires, its destructor uses delete to free the memory.
<p>
The purpose of this class is to provide a way to prevent accidental memory leaks in a class or a method, due to "not remembering to delete" variables allocated on the heap. Thus if you assign an address returned by new to an OsclExclusivePtr object, you don't have to remember to free the memory later, it will be freed automatically when the object goes out of scope. The OsclExclusivePtr is an example of a smart pointer, an object that acts like a pointer, but with additional features. The class is defined so that it acts like a regular pointer in most respects
<p>
<hr><h2>Constructor &amp; Destructor Documentation</h2>
<a name="a0" doxytag="OsclExclusivePtr::OsclExclusivePtr"></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&lt;class T&gt; </td>
</tr>
<tr>
<td class="md" nowrap valign="top"> OsclExclusivePtr&lt; T &gt;::OsclExclusivePtr </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="md" nowrap valign="top">T *&nbsp;</td>
<td class="mdname1" valign="top" nowrap>&nbsp; <em>inPtr</em> = 0 </td>
<td class="md" valign="top">)&nbsp;</td>
<td class="md" nowrap><code> [inline, explicit]</code></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
&nbsp;
</td>
<td>
<p>
Default constructor Initializes the pointer and takes ownership.
<p>
</td>
</tr>
</table>
<a name="a1" doxytag="OsclExclusivePtr::OsclExclusivePtr"></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&lt;class T&gt; </td>
</tr>
<tr>
<td class="md" nowrap valign="top"> OsclExclusivePtr&lt; T &gt;::OsclExclusivePtr </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="md" nowrap valign="top">OsclExclusivePtr&lt; T &gt; &amp;&nbsp;</td>
<td class="mdname1" valign="top" nowrap>&nbsp; <em>_Y</em> </td>
<td class="md" valign="top">)&nbsp;</td>
<td class="md" nowrap><code> [inline]</code></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
&nbsp;
</td>
<td>
<p>
Copy constructor.
<p>
Initializes the pointer and takes ownership from another OsclExclusivePtr. Note that the other class does NOT own the pointer any longer, and hence it is NOT its responsibility to free it. </td>
</tr>
</table>
<a name="a3" doxytag="OsclExclusivePtr::~OsclExclusivePtr"></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&lt;class T&gt; </td>
</tr>
<tr>
<td class="md" nowrap valign="top"> virtual OsclExclusivePtr&lt; T &gt;::~OsclExclusivePtr </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="mdname1" valign="top" nowrap>&nbsp; </td>
<td class="md" valign="top">)&nbsp;</td>
<td class="md" nowrap><code> [inline, virtual]</code></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
&nbsp;
</td>
<td>
<p>
Destructor.
<p>
The pointer is deleted in case this class still has ownership </td>
</tr>
</table>
<hr><h2>Member Function Documentation</h2>
<a name="a6" doxytag="OsclExclusivePtr::get"></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&lt;class T&gt; </td>
</tr>
<tr>
<td class="md" nowrap valign="top"> T* OsclExclusivePtr&lt; T &gt;::get </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="mdname1" valign="top" nowrap>&nbsp; </td>
<td class="md" valign="top">)&nbsp;</td>
<td class="md" nowrap> const<code> [inline]</code></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
&nbsp;
</td>
<td>
<p>
<a class="el" href="classOsclExclusivePtr.html#a6">get()</a> method returns the pointer, currently owned by the class.
<p>
</td>
</tr>
</table>
<a name="a4" doxytag="OsclExclusivePtr::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&lt;class T&gt; </td>
</tr>
<tr>
<td class="md" nowrap valign="top"> T&amp; OsclExclusivePtr&lt; T &gt;::operator * </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="mdname1" valign="top" nowrap>&nbsp; </td>
<td class="md" valign="top">)&nbsp;</td>
<td class="md" nowrap> const<code> [inline]</code></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
&nbsp;
</td>
<td>
<p>
The indirection operator (*) accesses a value indirectly, through a pointer.
<p>
This operator ensures that the OsclExclusivePtr can be used like the regular pointer that it was initialized with. </td>
</tr>
</table>
<a name="a5" doxytag="OsclExclusivePtr::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&lt;class T&gt; </td>
</tr>
<tr>
<td class="md" nowrap valign="top"> T* OsclExclusivePtr&lt; T &gt;::operator-&gt; </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="mdname1" valign="top" nowrap>&nbsp; </td>
<td class="md" valign="top">)&nbsp;</td>
<td class="md" nowrap> const<code> [inline]</code></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
&nbsp;
</td>
<td>
<p>
The indirection operator (-&gt;) accesses a value indirectly, through a pointer.
<p>
This operator ensures that the OsclExclusivePtr can be used like the regular pointer that it was initialized with. </td>
</tr>
</table>
<a name="a2" doxytag="OsclExclusivePtr::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&lt;class T&gt; </td>
</tr>
<tr>
<td class="md" nowrap valign="top"> OsclExclusivePtr&lt;T&gt;&amp; OsclExclusivePtr&lt; T &gt;::operator= </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="md" nowrap valign="top">OsclExclusivePtr&lt; T &gt; &amp;&nbsp;</td>
<td class="mdname1" valign="top" nowrap>&nbsp; <em>_Y</em> </td>
<td class="md" valign="top">)&nbsp;</td>
<td class="md" nowrap><code> [inline]</code></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
&nbsp;
</td>
<td>
<p>
Assignment operator from an another OsclExclusivePtr.
<p>
<dl compact><dt><b>Parameters: </b></dt><dd>
<table border=0 cellspacing=2 cellpadding=0>
<tr><td valign=top><em>_Y</em>&nbsp;</td><td>
The value parameter should be another OsclExclusivePtr </td></tr>
</table>
</dl><dl compact><dt><b>Returns: </b></dt><dd>
Returns a reference to this OsclExclusivePtr instance with pointer initialized. </dl><dl compact><dt><b>Precondition: </b></dt><dd>
The input class should be non-null and should point to a valid pointer.</dl>This assignment operator initializes the class to the contents of the OsclExclusivePtr given as the input parameter. The ownership of the pointer is transferred. </td>
</tr>
</table>
<a name="a7" doxytag="OsclExclusivePtr::release"></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&lt;class T&gt; </td>
</tr>
<tr>
<td class="md" nowrap valign="top"> T* OsclExclusivePtr&lt; T &gt;::release </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="mdname1" valign="top" nowrap>&nbsp; </td>
<td class="md" valign="top">)&nbsp;</td>
<td class="md" nowrap><code> [inline]</code></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
&nbsp;
</td>
<td>
<p>
<a class="el" href="classOsclExclusivePtr.html#a7">release()</a> method releases ownership of the pointer, currently owned by the class. It returns the pointer as well.
<p>
</td>
</tr>
</table>
<a name="a8" doxytag="OsclExclusivePtr::set"></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&lt;class T&gt; </td>
</tr>
<tr>
<td class="md" nowrap valign="top"> bool OsclExclusivePtr&lt; T &gt;::set </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="md" nowrap valign="top">T *&nbsp;</td>
<td class="mdname1" valign="top" nowrap>&nbsp; <em>ptr</em> </td>
<td class="md" valign="top">)&nbsp;</td>
<td class="md" nowrap><code> [inline]</code></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
&nbsp;
</td>
<td>
<p>
<a class="el" href="classOsclExclusivePtr.html#a8">set()</a> method sets ownership to the pointer, passed. This method is needed when the class is created with a default constructor. Returns false in case the class is non-empty.
<p>
</td>
</tr>
</table>
<hr><h2>Field Documentation</h2>
<a name="n0" doxytag="OsclExclusivePtr::_Ptr"></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&lt;class T&gt; </td>
</tr>
<tr>
<td class="md" nowrap valign="top"> T* OsclExclusivePtr&lt; T &gt;::_Ptr<code> [protected]</code>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
&nbsp;
</td>
<td>
<p>
</td>
</tr>
</table>
<hr>The documentation for this class was generated from the following file:<ul>
<li><a class="el" href="oscl__exclusive__ptr_8h-source.html">oscl_exclusive_ptr.h</a></ul>
<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>