Click here to Skip to main content
15,893,722 members
Articles / Desktop Programming / MFC

Genetic Algorithm Library

Rate me:
Please Sign up or sign in to vote.
4.93/5 (175 votes)
7 Apr 2012GPL358 min read 439.4K   34.7K   555  
A framework for genetic algorithms
<!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: Common::GaCatalogueEntry&lt; T &gt; Class Template 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&nbsp;Page</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li class="current"><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div class="tabs">
    <ul>
      <li><a href="annotated.html"><span>Class&nbsp;List</span></a></li>
      <li><a href="hierarchy.html"><span>Class&nbsp;Hierarchy</span></a></li>
      <li><a href="functions.html"><span>Class&nbsp;Members</span></a></li>
    </ul>
  </div>
  <div class="navpath"><a class="el" href="namespace_common.html">Common</a>::<a class="el" href="class_common_1_1_ga_catalogue_entry.html">GaCatalogueEntry</a>
  </div>
</div>
<div class="contents">
<h1>Common::GaCatalogueEntry&lt; T &gt; Class Template Reference</h1><!-- doxytag: class="Common::GaCatalogueEntry" -->This template class manages key and pointer to data of a catalogue entry. Catalogue entry stores key's string value and pointer to data. Entry stores copied string value of a key. After binding data to an entry, entry object takes over responsibility for memory occupied by data. Data must be located at heap.  
<a href="#_details">More...</a>
<p>
<code>#include &lt;source/Catalogue.h&gt;</code>
<p>

<p>
<a href="class_common_1_1_ga_catalogue_entry-members.html">List of all members.</a><table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_common_1_1_ga_catalogue_entry.html#40a4fc4e259e44654301be2985940006">GaCatalogueEntry</a> (const char *name, T *data)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Constructor makes copy of key and stores pointer to copied key and pointer to user specified data.  <a href="#40a4fc4e259e44654301be2985940006"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_common_1_1_ga_catalogue_entry.html#0c20f35dc47bd1f9355354c8e86cf9ee">~GaCatalogueEntry</a> ()</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Frees memory used by the data and the key.  <a href="#0c20f35dc47bd1f9355354c8e86cf9ee"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">const char *GACALL&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_common_1_1_ga_catalogue_entry.html#e4f836a01c63e196938b55e0139b6338">GetName</a> () const </td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">This method is not thread-safe.  <a href="#e4f836a01c63e196938b55e0139b6338"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void GACALL&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_common_1_1_ga_catalogue_entry.html#69e6a8fde6e7d0423b1addec36841f55">SetName</a> (const char *name)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight"><code>SetName</code> method copies key's string and stores pointer to the copied string.  <a href="#69e6a8fde6e7d0423b1addec36841f55"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int GACALL&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_common_1_1_ga_catalogue_entry.html#19511ff2ee5b77beffbc887c249dca3d">GetNameLength</a> () const </td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">This method is not thread-safe.  <a href="#19511ff2ee5b77beffbc887c249dca3d"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">T *GACALL&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_common_1_1_ga_catalogue_entry.html#44e0d1d9a8884e97c7faaf25c5bc5f5b">GetData</a> () const </td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">This method is not thread-safe.  <a href="#44e0d1d9a8884e97c7faaf25c5bc5f5b"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void GACALL&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_common_1_1_ga_catalogue_entry.html#3e7a3e5a0a61d8dd1143c4e4c6ed62de">SetData</a> (T *data)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight"><code>SetData</code> method stores pointer to data.  <a href="#3e7a3e5a0a61d8dd1143c4e4c6ed62de"></a><br></td></tr>
<tr><td colspan="2"><br><h2>Private Attributes</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">char *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_common_1_1_ga_catalogue_entry.html#50a5bd10bd5a87c0559a0bc41e51fa06">_name</a></td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Pointer to string representing key of the catalogue's entry.  <a href="#50a5bd10bd5a87c0559a0bc41e51fa06"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_common_1_1_ga_catalogue_entry.html#2ed5d9ceba68826760e29254364f748e">_nameLength</a></td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Stores length of string (key) without null-terminating character.  <a href="#2ed5d9ceba68826760e29254364f748e"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">T *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_common_1_1_ga_catalogue_entry.html#7f5b42cae10fbe8966bc10147834159a">_data</a></td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Pointer to the data.  <a href="#7f5b42cae10fbe8966bc10147834159a"></a><br></td></tr>
<tr><td colspan="2"><br><h2>Friends</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">class&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_common_1_1_ga_catalogue_entry.html#b1ed3ae66b825ed22c8202f5488fbd0c">GaCatalogue&lt; T &gt;</a></td></tr>

</table>
<hr><a name="_details"></a><h2>Detailed Description</h2>
<h3>template&lt;typename T&gt;<br>
 class Common::GaCatalogueEntry&lt; T &gt;</h3>

This template class manages key and pointer to data of a catalogue entry. Catalogue entry stores key's string value and pointer to data. Entry stores copied string value of a key. After binding data to an entry, entry object takes over responsibility for memory occupied by data. Data must be located at heap. 
<p>
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. No public or private methods are thread-safe. <dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>T</em>&nbsp;</td><td>type of stored data in the entry.</td></tr>
  </table>
</dl>
<hr><h2>Constructor &amp; Destructor Documentation</h2>
<a class="anchor" name="40a4fc4e259e44654301be2985940006"></a><!-- doxytag: member="Common::GaCatalogueEntry::GaCatalogueEntry" ref="40a4fc4e259e44654301be2985940006" args="(const char *name, T *data)" -->
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T&gt; </div>
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="class_common_1_1_ga_catalogue_entry.html">Common::GaCatalogueEntry</a>&lt; T &gt;::<a class="el" href="class_common_1_1_ga_catalogue_entry.html">GaCatalogueEntry</a>           </td>
          <td>(</td>
          <td class="paramtype">const char *&nbsp;</td>
          <td class="paramname"> <em>name</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">T *&nbsp;</td>
          <td class="paramname"> <em>data</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td width="100%"><code> [inline]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Constructor makes copy of key and stores pointer to copied key and pointer to user specified data. 
<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>name</em>&nbsp;</td><td>key of the entry (null-terminating string).</td></tr>
    <tr><td valign="top"></td><td valign="top"><em>data</em>&nbsp;</td><td>data which will be stored in the entry.</td></tr>
  </table>
</dl>

</div>
</div><p>
<a class="anchor" name="0c20f35dc47bd1f9355354c8e86cf9ee"></a><!-- doxytag: member="Common::GaCatalogueEntry::~GaCatalogueEntry" ref="0c20f35dc47bd1f9355354c8e86cf9ee" args="()" -->
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T&gt; </div>
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="class_common_1_1_ga_catalogue_entry.html">Common::GaCatalogueEntry</a>&lt; T &gt;::~<a class="el" href="class_common_1_1_ga_catalogue_entry.html">GaCatalogueEntry</a>           </td>
          <td>(</td>
          <td class="paramname">          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"><code> [inline]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Frees memory used by the data and the key. 
<p>

</div>
</div><p>
<hr><h2>Member Function Documentation</h2>
<a class="anchor" name="e4f836a01c63e196938b55e0139b6338"></a><!-- doxytag: member="Common::GaCatalogueEntry::GetName" ref="e4f836a01c63e196938b55e0139b6338" args="() const " -->
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T&gt; </div>
      <table class="memname">
        <tr>
          <td class="memname">const char* GACALL <a class="el" href="class_common_1_1_ga_catalogue_entry.html">Common::GaCatalogueEntry</a>&lt; T &gt;::GetName           </td>
          <td>(</td>
          <td class="paramname">          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"> const<code> [inline]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
This method is not thread-safe. 
<p>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>Method returns pointer to string representing key of the entry.</dd></dl>

</div>
</div><p>
<a class="anchor" name="69e6a8fde6e7d0423b1addec36841f55"></a><!-- doxytag: member="Common::GaCatalogueEntry::SetName" ref="69e6a8fde6e7d0423b1addec36841f55" args="(const char *name)" -->
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T&gt; </div>
      <table class="memname">
        <tr>
          <td class="memname">void GACALL <a class="el" href="class_common_1_1_ga_catalogue_entry.html">Common::GaCatalogueEntry</a>&lt; T &gt;::SetName           </td>
          <td>(</td>
          <td class="paramtype">const char *&nbsp;</td>
          <td class="paramname"> <em>name</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"><code> [inline]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
<code>SetName</code> method copies key's string and stores pointer to the copied string. 
<p>
This method is not thread-safe. <dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>name</em>&nbsp;</td><td>pointer to string which represents new key.</td></tr>
  </table>
</dl>

</div>
</div><p>
<a class="anchor" name="19511ff2ee5b77beffbc887c249dca3d"></a><!-- doxytag: member="Common::GaCatalogueEntry::GetNameLength" ref="19511ff2ee5b77beffbc887c249dca3d" args="() const " -->
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T&gt; </div>
      <table class="memname">
        <tr>
          <td class="memname">int GACALL <a class="el" href="class_common_1_1_ga_catalogue_entry.html">Common::GaCatalogueEntry</a>&lt; T &gt;::GetNameLength           </td>
          <td>(</td>
          <td class="paramname">          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"> const<code> [inline]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
This method is not thread-safe. 
<p>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>Method returns length of the key.</dd></dl>

</div>
</div><p>
<a class="anchor" name="44e0d1d9a8884e97c7faaf25c5bc5f5b"></a><!-- doxytag: member="Common::GaCatalogueEntry::GetData" ref="44e0d1d9a8884e97c7faaf25c5bc5f5b" args="() const " -->
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T&gt; </div>
      <table class="memname">
        <tr>
          <td class="memname">T* GACALL <a class="el" href="class_common_1_1_ga_catalogue_entry.html">Common::GaCatalogueEntry</a>&lt; T &gt;::GetData           </td>
          <td>(</td>
          <td class="paramname">          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"> const<code> [inline]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
This method is not thread-safe. 
<p>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>Method returns reference to the data.</dd></dl>

</div>
</div><p>
<a class="anchor" name="3e7a3e5a0a61d8dd1143c4e4c6ed62de"></a><!-- doxytag: member="Common::GaCatalogueEntry::SetData" ref="3e7a3e5a0a61d8dd1143c4e4c6ed62de" args="(T *data)" -->
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T&gt; </div>
      <table class="memname">
        <tr>
          <td class="memname">void GACALL <a class="el" href="class_common_1_1_ga_catalogue_entry.html">Common::GaCatalogueEntry</a>&lt; T &gt;::SetData           </td>
          <td>(</td>
          <td class="paramtype">T *&nbsp;</td>
          <td class="paramname"> <em>data</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"><code> [inline]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
<code>SetData</code> method stores pointer to data. 
<p>
This method is not thread-safe. <dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>data</em>&nbsp;</td><td>reference to new data.</td></tr>
  </table>
</dl>

</div>
</div><p>
<hr><h2>Friends And Related Function Documentation</h2>
<a class="anchor" name="b1ed3ae66b825ed22c8202f5488fbd0c"></a><!-- doxytag: member="Common::GaCatalogueEntry::GaCatalogue&lt; T &gt;" ref="b1ed3ae66b825ed22c8202f5488fbd0c" args="" -->
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T&gt; </div>
      <table class="memname">
        <tr>
          <td class="memname">friend class <a class="el" href="class_common_1_1_ga_catalogue.html">GaCatalogue</a>&lt; T &gt;<code> [friend]</code>          </td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>

</div>
</div><p>
<hr><h2>Member Data Documentation</h2>
<a class="anchor" name="50a5bd10bd5a87c0559a0bc41e51fa06"></a><!-- doxytag: member="Common::GaCatalogueEntry::_name" ref="50a5bd10bd5a87c0559a0bc41e51fa06" args="" -->
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T&gt; </div>
      <table class="memname">
        <tr>
          <td class="memname">char* <a class="el" href="class_common_1_1_ga_catalogue_entry.html">Common::GaCatalogueEntry</a>&lt; T &gt;::<a class="el" href="class_common_1_1_ga_catalogue_entry.html#50a5bd10bd5a87c0559a0bc41e51fa06">_name</a><code> [private]</code>          </td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Pointer to string representing key of the catalogue's entry. 
<p>

</div>
</div><p>
<a class="anchor" name="2ed5d9ceba68826760e29254364f748e"></a><!-- doxytag: member="Common::GaCatalogueEntry::_nameLength" ref="2ed5d9ceba68826760e29254364f748e" args="" -->
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T&gt; </div>
      <table class="memname">
        <tr>
          <td class="memname">int <a class="el" href="class_common_1_1_ga_catalogue_entry.html">Common::GaCatalogueEntry</a>&lt; T &gt;::<a class="el" href="class_common_1_1_ga_catalogue_entry.html#2ed5d9ceba68826760e29254364f748e">_nameLength</a><code> [private]</code>          </td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Stores length of string (key) without null-terminating character. 
<p>

</div>
</div><p>
<a class="anchor" name="7f5b42cae10fbe8966bc10147834159a"></a><!-- doxytag: member="Common::GaCatalogueEntry::_data" ref="7f5b42cae10fbe8966bc10147834159a" args="" -->
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T&gt; </div>
      <table class="memname">
        <tr>
          <td class="memname">T* <a class="el" href="class_common_1_1_ga_catalogue_entry.html">Common::GaCatalogueEntry</a>&lt; T &gt;::<a class="el" href="class_common_1_1_ga_catalogue_entry.html#7f5b42cae10fbe8966bc10147834159a">_data</a><code> [private]</code>          </td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Pointer to the data. 
<p>

</div>
</div><p>
<hr>The documentation for this class was generated from the following file:<ul>
<li>source/<a class="el" href="_catalogue_8h.html">Catalogue.h</a></ul>
</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 Service 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.

License

This article, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)


Written By
Software Developer
Serbia Serbia
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions