Sophie

Sophie

distrib > Mandriva > 2011.0 > i586 > by-pkgid > 092973e3430682b17a7d74261285ae23 > files > 264

loki-lib-doc-0.1.7-1.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>Loki: Factory</title>
<link href="tabs.css" rel="stylesheet" type="text/css">
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.8 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
    <li>
      <form action="search.php" method="get">
        <table cellspacing="0" cellpadding="0" border="0">
          <tr>
            <td><label>&nbsp;<u>S</u>earch&nbsp;for&nbsp;</label></td>
            <td><input type="text" name="query" value="" size="20" accesskey="s"/></td>
          </tr>
        </table>
      </form>
    </li>
    </ul>
  </div>
</div>
<div class="contents">
<h1>Factory<br>
<small>
[<a class="el" href="a00198.html">Factories</a>]</small>
</h1>Implements a generic object factory.  
<a href="#_details">More...</a>
<p>

<p>
<div class="dynheader">
Collaboration diagram for Factory:</div>
<div class="dynsection">
</div>
<table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Classes</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">class &nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00055.html">Loki::Factory&lt; AbstractProduct, IdentifierType, CreatorParmTList, FactoryErrorPolicy &gt;</a></td></tr>

<tr><td colspan="2"><br><h2>Modules</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00206.html">Factory Error Policies</a></td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Manages the "Unknown Type" error in an object factory. <br></td></tr>

<p>
</table>
<hr><a name="_details"></a><h2>Detailed Description</h2>
Implements a generic object factory. 
<p>
<em>The Factory Method pattern is an object-oriented design pattern. Like other creational patterns, it deals with the problem of creating objects (products) without specifying the exact class of object that will be created. Factory Method, one of the patterns from the Design Patterns book, handles this problem by defining a separate method for creating the objects, which subclasses can then override to specify the derived type of product that will be created. <br>
 More generally, the term Factory Method is often used to refer to any method whose main purpose is creation of objects.</em> <div align="RIGHT"><a href="http://en.wikipedia.org/wiki/Factory_method_pattern">Wikipedia</a></div><p>
<a class="el" href="a00192.html">Loki</a> proposes a generic version of the Factory. Here is a typical use.<br>
 <code><br>
 1. Factory&lt; AbstractProduct, int &gt; aFactory;<br>
 2. aFactory.Register( 1, createProductNull );<br>
 3. aFactory.CreateObject( 1 ); <br>
 </code><br>
 <br>
<ul>
<li>1. The declaration<br>
 You want a Factory that produces AbstractProduct.<br>
 The client will refer to a creation method through an int.<br>
</li><li>2.The registration<br>
 The code that will contribute to the Factory will now need to declare its ProductCreator by registering them into the Factory.<br>
 A ProductCreator is a just a function that will return the right object. ie <br>
 <code> Product* createProductNull()<br>
 {<br>
 return new Product<br>
 }<br>
 </code><br>
</li><li>3. The use<br>
 Now the client can create object by calling the Factory's CreateObject method with the right identifier. If the ProductCreator were to have arguments (<em>ie :Product* createProductParm( int a, int b )</em>) </li></ul>
</div>
<hr size="1"><address style="text-align: right;"><small>Generated on Thu Jan 29 18:51:40 2009 for Loki by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.8 </small></address>
</body>
</html>