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> TemplateOSCLMemAutoPtr< T, _Allocator > class Reference</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> <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> 9 <hr><h1>OSCLMemAutoPtr< T, _Allocator > Class Template Reference<br> 10 <small> 11 [<a class="el" href="group__osclmemory.html">OSCL Memory</a>]</small> 12 </h1>The oscl_auto_ptr 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 oscl_auto_ptr expires, its destructor uses delete to free the memory. 13 <a href="#_details">More...</a> 14 <p> 15 <code>#include <<a class="el" href="oscl__mem__auto__ptr_8h-source.html">oscl_mem_auto_ptr.h</a>></code> 16 <p> 17 <table border=0 cellpadding=0 cellspacing=0> 18 <tr><td></td></tr> 19 <tr><td colspan=2><br><h2>Public Methods</h2></td></tr> 20 <tr><td nowrap align=right valign=top> </td><td valign=bottom><a class="el" href="classOSCLMemAutoPtr.html#a0">OSCLMemAutoPtr</a> (T *inPtr=0)</td></tr> 21 <tr><td> </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> 22 <tr><td nowrap align=right valign=top> </td><td valign=bottom><a class="el" href="classOSCLMemAutoPtr.html#a1">OSCLMemAutoPtr</a> (const OSCLMemAutoPtr< T > &_Y)</td></tr> 23 <tr><td> </td><td><font size=-1><em>Copy constructor.</em> <a href="#a1"></a><em></em></font><br><br></td></tr> 24 <tr><td nowrap align=right valign=top>OSCLMemAutoPtr< T, _Allocator > & </td><td valign=bottom><a class="el" href="classOSCLMemAutoPtr.html#a2">operator=</a> (const OSCLMemAutoPtr< T, _Allocator > &_Y)</td></tr> 25 <tr><td> </td><td><font size=-1><em>Assignment operator from an another oscl_auto_ptr.</em> <a href="#a2"></a><em></em></font><br><br></td></tr> 26 <tr><td nowrap align=right valign=top> </td><td valign=bottom><a class="el" href="classOSCLMemAutoPtr.html#a3">~OSCLMemAutoPtr</a> ()</td></tr> 27 <tr><td> </td><td><font size=-1><em>Destructor.</em> <a href="#a3"></a><em></em></font><br><br></td></tr> 28 <tr><td nowrap align=right valign=top>T & </td><td valign=bottom><a class="el" href="classOSCLMemAutoPtr.html#a4">operator *</a> () const</td></tr> 29 <tr><td> </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> 30 <tr><td nowrap align=right valign=top>T * </td><td valign=bottom><a class="el" href="classOSCLMemAutoPtr.html#a5">operator-></a> () const</td></tr> 31 <tr><td> </td><td><font size=-1><em>The indirection operator (->) accesses a value indirectly, through a pointer.</em> <a href="#a5"></a><em></em></font><br><br></td></tr> 32 <tr><td nowrap align=right valign=top>void </td><td valign=bottom><a class="el" href="classOSCLMemAutoPtr.html#a6">takeOwnership</a> (T *ptr)</td></tr> 33 <tr><td> </td><td><font size=-1><em>The takeOwnership function assigns the value with ownership.</em> <a href="#a6"></a><em></em></font><br><br></td></tr> 34 <tr><td nowrap align=right valign=top>void </td><td valign=bottom><a class="el" href="classOSCLMemAutoPtr.html#a7">allocate</a> (<a class="el" href="osclconfig__ansi__memory_8h.html#a1">oscl_memsize_t</a> size)</td></tr> 35 <tr><td nowrap align=right valign=top>void </td><td valign=bottom><a class="el" href="classOSCLMemAutoPtr.html#a8">setWithoutOwnership</a> (T *ptr)</td></tr> 36 <tr><td> </td><td><font size=-1><em>The takeOwnership function assigns the value with ownership.</em> <a href="#a8"></a><em></em></font><br><br></td></tr> 37 <tr><td nowrap align=right valign=top>T * </td><td valign=bottom><a class="el" href="classOSCLMemAutoPtr.html#a9">get</a> () const</td></tr> 38 <tr><td> </td><td><font size=-1><em><a class="el" href="classOSCLMemAutoPtr.html#a9">get()</a> method returns the pointer, currently owned by the class.</em> <a href="#a9"></a><em></em></font><br><br></td></tr> 39 <tr><td nowrap align=right valign=top>T * </td><td valign=bottom><a class="el" href="classOSCLMemAutoPtr.html#a10">release</a> () const</td></tr> 40 <tr><td> </td><td><font size=-1><em><a class="el" href="classOSCLMemAutoPtr.html#a10">release()</a> method releases ownership of the pointer, currently owned by the class. It returns the pointer as well.</em> <a href="#a10"></a><em></em></font><br><br></td></tr> 41 <tr><td colspan=2><br><h2>Static Public Methods</h2></td></tr> 42 <tr><td nowrap align=right valign=top>void </td><td valign=bottom><a class="el" href="classOSCLMemAutoPtr.html#d0">deallocate</a> (T *ptr)</td></tr> 43 <tr><td colspan=2><br><h2>Data Fields</h2></td></tr> 44 <tr><td nowrap align=right valign=top>bool </td><td valign=bottom><a class="el" href="classOSCLMemAutoPtr.html#m0">_Ownership</a></td></tr> 45 </table> 46 <hr><a name="_details"></a><h2>Detailed Description</h2> 47 <h3>template<class T, class _Allocator = Oscl_TAlloc<T, OsclMemAllocator>><br> 48 class OSCLMemAutoPtr< T, _Allocator ></h3> 49 50 The oscl_auto_ptr 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 oscl_auto_ptr expires, its destructor uses delete to free the memory. 51 <p> 52 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 oscl_auto_ptr 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 oscl_auto_ptr 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 53 <p> 54 <hr><h2>Constructor & Destructor Documentation</h2> 55 <a name="a0" doxytag="OSCLMemAutoPtr::OSCLMemAutoPtr"></a><p> 56 <table width="100%" cellpadding="2" cellspacing="0" border="0"> 57 <tr> 58 <td class="md"> 59 <table cellpadding="0" cellspacing="0" border="0"> 60 <tr> 61 <td class="md" colspan="4"> 62 template<class T, class _Allocator = Oscl_TAlloc<T, OsclMemAllocator>> </td> 63 </tr> 64 <tr> 65 <td class="md" nowrap valign="top"> OSCLMemAutoPtr< T, _Allocator >::OSCLMemAutoPtr </td> 66 <td class="md" valign="top">( </td> 67 <td class="md" nowrap valign="top">T * </td> 68 <td class="mdname1" valign="top" nowrap> <em>inPtr</em> = 0 </td> 69 <td class="md" valign="top">) </td> 70 <td class="md" nowrap><code> [inline, explicit]</code></td> 71 </tr> 72 73 </table> 74 </td> 75 </tr> 76 </table> 77 <table cellspacing=5 cellpadding=0 border=0> 78 <tr> 79 <td> 80 81 </td> 82 <td> 83 84 <p> 85 Default constructor Initializes the pointer and takes ownership. 86 <p> 87 </td> 88 </tr> 89 </table> 90 <a name="a1" doxytag="OSCLMemAutoPtr::OSCLMemAutoPtr"></a><p> 91 <table width="100%" cellpadding="2" cellspacing="0" border="0"> 92 <tr> 93 <td class="md"> 94 <table cellpadding="0" cellspacing="0" border="0"> 95 <tr> 96 <td class="md" colspan="4"> 97 template<class T, class _Allocator = Oscl_TAlloc<T, OsclMemAllocator>> </td> 98 </tr> 99 <tr> 100 <td class="md" nowrap valign="top"> OSCLMemAutoPtr< T, _Allocator >::OSCLMemAutoPtr </td> 101 <td class="md" valign="top">( </td> 102 <td class="md" nowrap valign="top">const OSCLMemAutoPtr< T > & </td> 103 <td class="mdname1" valign="top" nowrap> <em>_Y</em> </td> 104 <td class="md" valign="top">) </td> 105 <td class="md" nowrap><code> [inline]</code></td> 106 </tr> 107 108 </table> 109 </td> 110 </tr> 111 </table> 112 <table cellspacing=5 cellpadding=0 border=0> 113 <tr> 114 <td> 115 116 </td> 117 <td> 118 119 <p> 120 Copy constructor. 121 <p> 122 Initializes the pointer and takes ownership from another oscl_auto_ptr. Note that the other class does NOT own the pointer any longer, and hence it is NOT its responsibility to free it. </td> 123 </tr> 124 </table> 125 <a name="a3" doxytag="OSCLMemAutoPtr::~OSCLMemAutoPtr"></a><p> 126 <table width="100%" cellpadding="2" cellspacing="0" border="0"> 127 <tr> 128 <td class="md"> 129 <table cellpadding="0" cellspacing="0" border="0"> 130 <tr> 131 <td class="md" colspan="4"> 132 template<class T, class _Allocator = Oscl_TAlloc<T, OsclMemAllocator>> </td> 133 </tr> 134 <tr> 135 <td class="md" nowrap valign="top"> OSCLMemAutoPtr< T, _Allocator >::~OSCLMemAutoPtr </td> 136 <td class="md" valign="top">( </td> 137 <td class="mdname1" valign="top" nowrap> </td> 138 <td class="md" valign="top">) </td> 139 <td class="md" nowrap><code> [inline]</code></td> 140 </tr> 141 142 </table> 143 </td> 144 </tr> 145 </table> 146 <table cellspacing=5 cellpadding=0 border=0> 147 <tr> 148 <td> 149 150 </td> 151 <td> 152 153 <p> 154 Destructor. 155 <p> 156 The pointer is deleted in case this class still has ownership </td> 157 </tr> 158 </table> 159 <hr><h2>Member Function Documentation</h2> 160 <a name="a7" doxytag="OSCLMemAutoPtr::allocate"></a><p> 161 <table width="100%" cellpadding="2" cellspacing="0" border="0"> 162 <tr> 163 <td class="md"> 164 <table cellpadding="0" cellspacing="0" border="0"> 165 <tr> 166 <td class="md" colspan="4"> 167 template<class T, class _Allocator = Oscl_TAlloc<T, OsclMemAllocator>> </td> 168 </tr> 169 <tr> 170 <td class="md" nowrap valign="top"> void OSCLMemAutoPtr< T, _Allocator >::allocate </td> 171 <td class="md" valign="top">( </td> 172 <td class="md" nowrap valign="top"><a class="el" href="osclconfig__ansi__memory_8h.html#a1">oscl_memsize_t</a> </td> 173 <td class="mdname1" valign="top" nowrap> <em>size</em> </td> 174 <td class="md" valign="top">) </td> 175 <td class="md" nowrap><code> [inline]</code></td> 176 </tr> 177 178 </table> 179 </td> 180 </tr> 181 </table> 182 <table cellspacing=5 cellpadding=0 border=0> 183 <tr> 184 <td> 185 186 </td> 187 <td> 188 189 <p> 190 </td> 191 </tr> 192 </table> 193 <a name="d0" doxytag="OSCLMemAutoPtr::deallocate"></a><p> 194 <table width="100%" cellpadding="2" cellspacing="0" border="0"> 195 <tr> 196 <td class="md"> 197 <table cellpadding="0" cellspacing="0" border="0"> 198 <tr> 199 <td class="md" colspan="4"> 200 template<class T, class _Allocator = Oscl_TAlloc<T, OsclMemAllocator>> </td> 201 </tr> 202 <tr> 203 <td class="md" nowrap valign="top"> void OSCLMemAutoPtr< T, _Allocator >::deallocate </td> 204 <td class="md" valign="top">( </td> 205 <td class="md" nowrap valign="top">T * </td> 206 <td class="mdname1" valign="top" nowrap> <em>ptr</em> </td> 207 <td class="md" valign="top">) </td> 208 <td class="md" nowrap><code> [inline, static]</code></td> 209 </tr> 210 211 </table> 212 </td> 213 </tr> 214 </table> 215 <table cellspacing=5 cellpadding=0 border=0> 216 <tr> 217 <td> 218 219 </td> 220 <td> 221 222 <p> 223 </td> 224 </tr> 225 </table> 226 <a name="a9" doxytag="OSCLMemAutoPtr::get"></a><p> 227 <table width="100%" cellpadding="2" cellspacing="0" border="0"> 228 <tr> 229 <td class="md"> 230 <table cellpadding="0" cellspacing="0" border="0"> 231 <tr> 232 <td class="md" colspan="4"> 233 template<class T, class _Allocator = Oscl_TAlloc<T, OsclMemAllocator>> </td> 234 </tr> 235 <tr> 236 <td class="md" nowrap valign="top"> T* OSCLMemAutoPtr< T, _Allocator >::get </td> 237 <td class="md" valign="top">( </td> 238 <td class="mdname1" valign="top" nowrap> </td> 239 <td class="md" valign="top">) </td> 240 <td class="md" nowrap> const<code> [inline]</code></td> 241 </tr> 242 243 </table> 244 </td> 245 </tr> 246 </table> 247 <table cellspacing=5 cellpadding=0 border=0> 248 <tr> 249 <td> 250 251 </td> 252 <td> 253 254 <p> 255 <a class="el" href="classOSCLMemAutoPtr.html#a9">get()</a> method returns the pointer, currently owned by the class. 256 <p> 257 </td> 258 </tr> 259 </table> 260 <a name="a4" doxytag="OSCLMemAutoPtr::operator *"></a><p> 261 <table width="100%" cellpadding="2" cellspacing="0" border="0"> 262 <tr> 263 <td class="md"> 264 <table cellpadding="0" cellspacing="0" border="0"> 265 <tr> 266 <td class="md" colspan="4"> 267 template<class T, class _Allocator = Oscl_TAlloc<T, OsclMemAllocator>> </td> 268 </tr> 269 <tr> 270 <td class="md" nowrap valign="top"> T& OSCLMemAutoPtr< T, _Allocator >::operator * </td> 271 <td class="md" valign="top">( </td> 272 <td class="mdname1" valign="top" nowrap> </td> 273 <td class="md" valign="top">) </td> 274 <td class="md" nowrap> const<code> [inline]</code></td> 275 </tr> 276 277 </table> 278 </td> 279 </tr> 280 </table> 281 <table cellspacing=5 cellpadding=0 border=0> 282 <tr> 283 <td> 284 285 </td> 286 <td> 287 288 <p> 289 The indirection operator (*) accesses a value indirectly, through a pointer. 290 <p> 291 This operator ensures that the OSCLMemAutoPtr can be used like the regular pointer that it was initialized with. </td> 292 </tr> 293 </table> 294 <a name="a5" doxytag="OSCLMemAutoPtr::operator->"></a><p> 295 <table width="100%" cellpadding="2" cellspacing="0" border="0"> 296 <tr> 297 <td class="md"> 298 <table cellpadding="0" cellspacing="0" border="0"> 299 <tr> 300 <td class="md" colspan="4"> 301 template<class T, class _Allocator = Oscl_TAlloc<T, OsclMemAllocator>> </td> 302 </tr> 303 <tr> 304 <td class="md" nowrap valign="top"> T* OSCLMemAutoPtr< T, _Allocator >::operator-> </td> 305 <td class="md" valign="top">( </td> 306 <td class="mdname1" valign="top" nowrap> </td> 307 <td class="md" valign="top">) </td> 308 <td class="md" nowrap> const<code> [inline]</code></td> 309 </tr> 310 311 </table> 312 </td> 313 </tr> 314 </table> 315 <table cellspacing=5 cellpadding=0 border=0> 316 <tr> 317 <td> 318 319 </td> 320 <td> 321 322 <p> 323 The indirection operator (->) accesses a value indirectly, through a pointer. 324 <p> 325 This operator ensures that the OSCLMemAutoPtr can be used like the regular pointer that it was initialized with. </td> 326 </tr> 327 </table> 328 <a name="a2" doxytag="OSCLMemAutoPtr::operator="></a><p> 329 <table width="100%" cellpadding="2" cellspacing="0" border="0"> 330 <tr> 331 <td class="md"> 332 <table cellpadding="0" cellspacing="0" border="0"> 333 <tr> 334 <td class="md" colspan="4"> 335 template<class T, class _Allocator = Oscl_TAlloc<T, OsclMemAllocator>> </td> 336 </tr> 337 <tr> 338 <td class="md" nowrap valign="top"> OSCLMemAutoPtr<T, _Allocator>& OSCLMemAutoPtr< T, _Allocator >::operator= </td> 339 <td class="md" valign="top">( </td> 340 <td class="md" nowrap valign="top">const OSCLMemAutoPtr< T, _Allocator > & </td> 341 <td class="mdname1" valign="top" nowrap> <em>_Y</em> </td> 342 <td class="md" valign="top">) </td> 343 <td class="md" nowrap><code> [inline]</code></td> 344 </tr> 345 346 </table> 347 </td> 348 </tr> 349 </table> 350 <table cellspacing=5 cellpadding=0 border=0> 351 <tr> 352 <td> 353 354 </td> 355 <td> 356 357 <p> 358 Assignment operator from an another oscl_auto_ptr. 359 <p> 360 <dl compact><dt><b>Parameters: </b></dt><dd> 361 <table border=0 cellspacing=2 cellpadding=0> 362 <tr><td valign=top><em>_Y</em> </td><td> 363 The value parameter should be another oscl_auto_ptr </td></tr> 364 </table> 365 </dl><dl compact><dt><b>Returns: </b></dt><dd> 366 Returns a reference to this oscl_auto_ptr instance with pointer initialized. </dl><dl compact><dt><b>Precondition: </b></dt><dd> 367 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 oscl_auto_ptr given as the input parameter. The ownership of the pointer is transferred. </td> 368 </tr> 369 </table> 370 <a name="a10" doxytag="OSCLMemAutoPtr::release"></a><p> 371 <table width="100%" cellpadding="2" cellspacing="0" border="0"> 372 <tr> 373 <td class="md"> 374 <table cellpadding="0" cellspacing="0" border="0"> 375 <tr> 376 <td class="md" colspan="4"> 377 template<class T, class _Allocator = Oscl_TAlloc<T, OsclMemAllocator>> </td> 378 </tr> 379 <tr> 380 <td class="md" nowrap valign="top"> T* OSCLMemAutoPtr< T, _Allocator >::release </td> 381 <td class="md" valign="top">( </td> 382 <td class="mdname1" valign="top" nowrap> </td> 383 <td class="md" valign="top">) </td> 384 <td class="md" nowrap> const<code> [inline]</code></td> 385 </tr> 386 387 </table> 388 </td> 389 </tr> 390 </table> 391 <table cellspacing=5 cellpadding=0 border=0> 392 <tr> 393 <td> 394 395 </td> 396 <td> 397 398 <p> 399 <a class="el" href="classOSCLMemAutoPtr.html#a10">release()</a> method releases ownership of the pointer, currently owned by the class. It returns the pointer as well. 400 <p> 401 </td> 402 </tr> 403 </table> 404 <a name="a8" doxytag="OSCLMemAutoPtr::setWithoutOwnership"></a><p> 405 <table width="100%" cellpadding="2" cellspacing="0" border="0"> 406 <tr> 407 <td class="md"> 408 <table cellpadding="0" cellspacing="0" border="0"> 409 <tr> 410 <td class="md" colspan="4"> 411 template<class T, class _Allocator = Oscl_TAlloc<T, OsclMemAllocator>> </td> 412 </tr> 413 <tr> 414 <td class="md" nowrap valign="top"> void OSCLMemAutoPtr< T, _Allocator >::setWithoutOwnership </td> 415 <td class="md" valign="top">( </td> 416 <td class="md" nowrap valign="top">T * </td> 417 <td class="mdname1" valign="top" nowrap> <em>ptr</em> </td> 418 <td class="md" valign="top">) </td> 419 <td class="md" nowrap><code> [inline]</code></td> 420 </tr> 421 422 </table> 423 </td> 424 </tr> 425 </table> 426 <table cellspacing=5 cellpadding=0 border=0> 427 <tr> 428 <td> 429 430 </td> 431 <td> 432 433 <p> 434 The takeOwnership function assigns the value with ownership. 435 <p> 436 </td> 437 </tr> 438 </table> 439 <a name="a6" doxytag="OSCLMemAutoPtr::takeOwnership"></a><p> 440 <table width="100%" cellpadding="2" cellspacing="0" border="0"> 441 <tr> 442 <td class="md"> 443 <table cellpadding="0" cellspacing="0" border="0"> 444 <tr> 445 <td class="md" colspan="4"> 446 template<class T, class _Allocator = Oscl_TAlloc<T, OsclMemAllocator>> </td> 447 </tr> 448 <tr> 449 <td class="md" nowrap valign="top"> void OSCLMemAutoPtr< T, _Allocator >::takeOwnership </td> 450 <td class="md" valign="top">( </td> 451 <td class="md" nowrap valign="top">T * </td> 452 <td class="mdname1" valign="top" nowrap> <em>ptr</em> </td> 453 <td class="md" valign="top">) </td> 454 <td class="md" nowrap><code> [inline]</code></td> 455 </tr> 456 457 </table> 458 </td> 459 </tr> 460 </table> 461 <table cellspacing=5 cellpadding=0 border=0> 462 <tr> 463 <td> 464 465 </td> 466 <td> 467 468 <p> 469 The takeOwnership function assigns the value with ownership. 470 <p> 471 </td> 472 </tr> 473 </table> 474 <hr><h2>Field Documentation</h2> 475 <a name="m0" doxytag="OSCLMemAutoPtr::_Ownership"></a><p> 476 <table width="100%" cellpadding="2" cellspacing="0" border="0"> 477 <tr> 478 <td class="md"> 479 <table cellpadding="0" cellspacing="0" border="0"> 480 <tr> 481 <td class="md" colspan="4"> 482 template<class T, class _Allocator = Oscl_TAlloc<T, OsclMemAllocator>> </td> 483 </tr> 484 <tr> 485 <td class="md" nowrap valign="top"> bool OSCLMemAutoPtr< T, _Allocator >::_Ownership 486 </table> 487 </td> 488 </tr> 489 </table> 490 <table cellspacing=5 cellpadding=0 border=0> 491 <tr> 492 <td> 493 494 </td> 495 <td> 496 497 <p> 498 </td> 499 </tr> 500 </table> 501 <hr>The documentation for this class was generated from the following file:<ul> 502 <li><a class="el" href="oscl__mem__auto__ptr_8h-source.html">oscl_mem_auto_ptr.h</a></ul> 503 <hr size="1"><img src="pvlogo_small.jpg"><address style="align: right;"><small>OSCL API</small> 504 <address style="align: left;"><small>Posting Version: OPENCORE_20090310 </small> 505 </small></address> 506 </body> 507 </html> 508