<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> <title>Genetic Algorithm Library: source/SmartPtr.h File Reference</title> <link href="doxygen.css" rel="stylesheet" type="text/css"> <link href="tabs.css" rel="stylesheet" type="text/css"> </head><body> <!-- Generated by Doxygen 1.5.5 --> <div class="navigation" id="top"> <div class="tabs"> <ul> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li><a href="annotated.html"><span>Classes</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> </ul> </div> </div> <div class="contents"> <h1>source/SmartPtr.h File Reference</h1>This file contains declaration and implementation of template classes and datatypes that handles smart pointers used by the library. <a href="#_details">More...</a> <p> <code>#include "<a class="el" href="_platform_8h.html">Platform.h</a>"</code><br> <code>#include "<a class="el" href="_threading_8h.html">Threading.h</a>"</code><br> <table border="0" cellpadding="0" cellspacing="0"> <tr><td></td></tr> <tr><td colspan="2"><br><h2>Namespaces</h2></td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top">namespace </td><td class="memItemRight" valign="bottom"><a class="el" href="namespace_common.html">Common</a></td></tr> <tr><td colspan="2"><br><h2>Classes</h2></td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top">class </td><td class="memItemRight" valign="bottom"><a class="el" href="class_common_1_1_ga_smart_storage.html">Common::GaSmartStorage< T ></a></td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight"><code><a class="el" href="class_common_1_1_ga_smart_storage.html" title="GaSmartStorage template class provides reference-counting for smart pointers. GaSmartStorage...">GaSmartStorage</a></code> template class provides reference-counting for smart pointers. <code><a class="el" href="class_common_1_1_ga_smart_storage.html" title="GaSmartStorage template class provides reference-counting for smart pointers. GaSmartStorage...">GaSmartStorage</a></code> objects holds address of used data and number of references (smart pointers) which point to the data. Object of this class as well as the data are destroyed and memory is freed when there are no more references which points to the data. Arrays cannot be used with this class. This class has no built-in synchronizator, so <code>LOCK_OBJECT</code> and <code>LOCK_THIS_OBJECT</code> macros cannot be used with instances of this class, but all public method and operators are thread-safe. <a href="class_common_1_1_ga_smart_storage.html#_details">More...</a><br></td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top">class </td><td class="memItemRight" valign="bottom"><a class="el" href="class_common_1_1_ga_smart_ptr.html">Common::GaSmartPtr< T ></a></td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight"><code><a class="el" href="class_common_1_1_ga_smart_ptr.html" title="GaSmartPtr template class wraps C++ raw pointers, and takes over responsibility of...">GaSmartPtr</a></code> template class wraps C++ raw pointers, and takes over responsibility of managing the allocated memory. Smart pointer holds address of user data and reference to an object which is responsible for counting number of references to data, when there are no instances of <code><a class="el" href="class_common_1_1_ga_smart_ptr.html" title="GaSmartPtr template class wraps C++ raw pointers, and takes over responsibility of...">GaSmartPtr</a></code> pointing to location of the data (reference count of the location reaches 0), object is destroyed and memory used by the object is freed. Memory management by <code><a class="el" href="class_common_1_1_ga_smart_ptr.html" title="GaSmartPtr template class wraps C++ raw pointers, and takes over responsibility of...">GaSmartPtr</a></code> class is thread-safe, but after dereferencing smart pointer to access the data, it cannot be guaranteed that memory will not be freed if some other thread changes dereferenced pointer. Implemented smart pointers have some limitations: <br> 1. Dynamically allocated arrays cannot be managed by <a class="el" href="class_common_1_1_ga_smart_ptr.html" title="GaSmartPtr template class wraps C++ raw pointers, and takes over responsibility of...">GaSmartPtr</a> class. <br> 2. Circular references can cause memory leakage. <a href="class_common_1_1_ga_smart_ptr.html#_details">More...</a><br></td></tr> </table> <hr><a name="_details"></a><h2>Detailed Description</h2> This file contains declaration and implementation of template classes and datatypes that handles smart pointers used by the library. <p> </div> <br/><a href="http://www.coolsoft-sd.com/ProductVersion.aspx?vid=9">Genetic Algorithm Library</a><br/><a href="http://www.coolsoft-sd.com/">Coolsoft Software Development</a> </body> </html>
By viewing downloads associated with this article you agree to the Terms of use and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.
This article, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)
Skills that self-taught computer programmers lack