Boost logo

Boost-Commit :

From: mconsoni_at_[hidden]
Date: 2007-06-26 18:26:26


Author: mconsoni
Date: 2007-06-26 18:26:25 EDT (Tue, 26 Jun 2007)
New Revision: 7182
URL: http://svn.boost.org/trac/boost/changeset/7182

Log:

- this ones were generated as part of the new info class section and appendices.

Added:
   sandbox/libs/extension/doc/html/boost_extension/appendices/
   sandbox/libs/extension/doc/html/boost_extension/appendices/appendix_a.html
   sandbox/libs/extension/doc/html/boost_extension/info.html

Added: sandbox/libs/extension/doc/html/boost_extension/appendices/appendix_a.html
==============================================================================
--- (empty file)
+++ sandbox/libs/extension/doc/html/boost_extension/appendices/appendix_a.html 2007-06-26 18:26:25 EDT (Tue, 26 Jun 2007)
@@ -0,0 +1,75 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title> Appendix A - Windows Export and Import Declarations</title>
+<link rel="stylesheet" href="../../boostbook.css" type="text/css">
+<meta name="generator" content="DocBook XSL Stylesheets V1.68.1">
+<link rel="start" href="../../index.html" title="Chapter 1. Boost.Extension 1.0">
+<link rel="up" href="../appendices.html" title=" Appendices">
+<link rel="prev" href="../appendices.html" title=" Appendices">
+</head>
+<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
+<table cellpadding="2" width="100%">
+<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../boost.png"></td>
+<td align="center">Home</td>
+<td align="center">Libraries</td>
+<td align="center">People</td>
+<td align="center">FAQ</td>
+<td align="center">More</td>
+</table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="../appendices.html"><img src="../../images/prev.png" alt="Prev"></a><a accesskey="u" href="../appendices.html"><img src="../../images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../images/home.png" alt="Home"></a>
+</div>
+<div class="section" lang="en">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_extension.appendices.appendix_a"></a> Appendix A - Windows Export and Import Declarations</h3></div></div></div>
+<p>
+ On the Windows platform, special export declarations are required to make
+ functions or classes in a .dll file accessible to the outside world. For
+ normal usage of Boost.Extension, the only place this is required is in the
+ one function that is exported from each .dll. The Hello World sample program
+ illustrates how this is done using <code class="computeroutput"><span class="identifier">BOOST_EXTENSION_EXPORT</span></code>.
+ </p>
+<p>
+ For implementation inheritance across shared libraries, such as that in the
+ Multiple Inheritance sample, each class that is not header-only that needs
+ to be exported must have these declarations included. To make it more difficult,
+ they must be different depending on whether the class is being imported into
+ or exported from the current module. The Multiple Inheritance sample shows
+ how this is done.
+ </p>
+<a name="boost_extension.appendices.appendix_a.warning"></a><h3>
+<a name="id2576093"></a>
+ Warning
+ </h3>
+<p>
+ Now for a word of warning that many of you will ignore: In the great majority
+ of cases, even if non-header-only implementation inheritance across shared
+ libraries seems like a good idea, there is probably a better solution. Although
+ it certainly has its uses, it can cause problems like the following:
+ </p>
+<div class="itemizedlist"><ul type="disc">
+<li>
+ Version problems - if the original implementation changes at all, every
+ dependent shared library must be recompiled with the new implementation.
+ </li>
+<li>
+ Tight coupling between shared libraries. One of the primary reasons for
+ using shared libraries is to decrease coupling, and promote reuse.
+ </li>
+<li>
+ It can lead to overly complicated, over-designed class hierarchies.
+ </li>
+</ul></div>
+</div>
+<table width="100%"><tr>
+<td align="left"></td>
+<td align="right"><small>Copyright © 2007 Jeremy Pack, Mariano G. Consoni</small></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="../appendices.html"><img src="../../images/prev.png" alt="Prev"></a><a accesskey="u" href="../appendices.html"><img src="../../images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../images/home.png" alt="Home"></a>
+</div>
+</body>
+</html>

Added: sandbox/libs/extension/doc/html/boost_extension/info.html
==============================================================================
--- (empty file)
+++ sandbox/libs/extension/doc/html/boost_extension/info.html 2007-06-26 18:26:25 EDT (Tue, 26 Jun 2007)
@@ -0,0 +1,240 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title> Info Classes</title>
+<link rel="stylesheet" href="../boostbook.css" type="text/css">
+<meta name="generator" content="DocBook XSL Stylesheets V1.68.1">
+<link rel="start" href="../index.html" title="Chapter 1. Boost.Extension 1.0">
+<link rel="up" href="../index.html" title="Chapter 1. Boost.Extension 1.0">
+<link rel="prev" href="shared_libraries.html" title=" Shared Libraries">
+<link rel="next" href="performance_analysis.html" title=" Performance Analysis">
+</head>
+<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
+<table cellpadding="2" width="100%">
+<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../boost.png"></td>
+<td align="center">Home</td>
+<td align="center">Libraries</td>
+<td align="center">People</td>
+<td align="center">FAQ</td>
+<td align="center">More</td>
+</table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="shared_libraries.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="performance_analysis.html"><img src="../images/next.png" alt="Next"></a>
+</div>
+<div class="section" lang="en">
+<div class="titlepage"><div><div><h2 class="title" style="clear: both">
+<a name="boost_extension.info"></a> Info Classes</h2></div></div></div>
+<p>
+ In this section we explain how to use Info classes in Boost.Extensions.
+ </p>
+<p>
+ Info classes is a mechanism that allows you to store important information
+ of each implementation. The type and utility of this information is arbitrary
+ as the Info class is a template argument of the factories where the user registers
+ its own implementations, and for that reason any kind of information could
+ be stored.
+ </p>
+<p>
+ Let's see how can we use it with an example first and then we will be able
+ to summarize the concepts.
+ </p>
+<p>
+ Surely you remember our very first example, that of course it's called HelloWorld.
+ Well, let's imagine that we now want a multi-language Hello World. Of course
+ there are better ways of designing it, but as we want to picture how the Info
+ class could be used we'll take this approach.
+ </p>
+<p>
+ First, we define an implementation of the <code class="literal">word</code> interface
+ for each combination of word and language. Then we have for example the class
+ <code class="literal">monde</code> that implements the <code class="literal">word</code> interface
+ for the french language in this case.
+ </p>
+<p>
+ Let's see the code:
+ </p>
+<p>
+
+</p>
+<pre class="programlisting">
+<span class="keyword">class</span> <span class="identifier">world</span> <span class="special">:</span> <span class="keyword">public</span> <span class="identifier">word</span>
+<span class="special">{</span>
+<span class="keyword">public</span><span class="special">:</span>
+ <span class="keyword">virtual</span> <span class="keyword">const</span> <span class="keyword">char</span> <span class="special">*</span> <span class="identifier">get_val</span><span class="special">(){</span><span class="keyword">return</span> <span class="string">"world!"</span><span class="special">;}</span>
+<span class="special">};</span>
+
+<span class="keyword">class</span> <span class="identifier">mundo</span> <span class="special">:</span> <span class="keyword">public</span> <span class="identifier">word</span>
+<span class="special">{</span>
+<span class="keyword">public</span><span class="special">:</span>
+ <span class="keyword">virtual</span> <span class="keyword">const</span> <span class="keyword">char</span> <span class="special">*</span> <span class="identifier">get_val</span><span class="special">(){</span><span class="keyword">return</span> <span class="string">"mundo!"</span><span class="special">;}</span>
+<span class="special">};</span>
+
+<span class="keyword">class</span> <span class="identifier">monde</span> <span class="special">:</span> <span class="keyword">public</span> <span class="identifier">word</span>
+<span class="special">{</span>
+<span class="keyword">public</span><span class="special">:</span>
+ <span class="keyword">virtual</span> <span class="keyword">const</span> <span class="keyword">char</span> <span class="special">*</span> <span class="identifier">get_val</span><span class="special">(){</span><span class="keyword">return</span> <span class="string">"monde!"</span><span class="special">;}</span>
+<span class="special">};</span>
+
+<span class="keyword">class</span> <span class="identifier">mondo</span> <span class="special">:</span> <span class="keyword">public</span> <span class="identifier">word</span>
+<span class="special">{</span>
+<span class="keyword">public</span><span class="special">:</span>
+ <span class="keyword">virtual</span> <span class="keyword">const</span> <span class="keyword">char</span> <span class="special">*</span> <span class="identifier">get_val</span><span class="special">(){</span><span class="keyword">return</span> <span class="string">"mondo!"</span><span class="special">;}</span>
+<span class="special">};</span>
+
+
+<span class="keyword">class</span> <span class="identifier">hello</span> <span class="special">:</span> <span class="keyword">public</span> <span class="identifier">word</span>
+<span class="special">{</span>
+<span class="keyword">public</span><span class="special">:</span>
+ <span class="keyword">virtual</span> <span class="keyword">const</span> <span class="keyword">char</span> <span class="special">*</span> <span class="identifier">get_val</span><span class="special">(){</span><span class="keyword">return</span> <span class="string">"hello"</span><span class="special">;}</span>
+<span class="special">};</span>
+
+<span class="keyword">class</span> <span class="identifier">hola</span> <span class="special">:</span> <span class="keyword">public</span> <span class="identifier">word</span>
+<span class="special">{</span>
+<span class="keyword">public</span><span class="special">:</span>
+ <span class="keyword">virtual</span> <span class="keyword">const</span> <span class="keyword">char</span> <span class="special">*</span> <span class="identifier">get_val</span><span class="special">(){</span><span class="keyword">return</span> <span class="string">"hola"</span><span class="special">;}</span>
+<span class="special">};</span>
+
+<span class="keyword">class</span> <span class="identifier">bonjour</span> <span class="special">:</span> <span class="keyword">public</span> <span class="identifier">word</span>
+<span class="special">{</span>
+<span class="keyword">public</span><span class="special">:</span>
+ <span class="keyword">virtual</span> <span class="keyword">const</span> <span class="keyword">char</span> <span class="special">*</span> <span class="identifier">get_val</span><span class="special">(){</span><span class="keyword">return</span> <span class="string">"bonjour"</span><span class="special">;}</span>
+<span class="special">};</span>
+
+<span class="keyword">class</span> <span class="identifier">buonasera</span> <span class="special">:</span> <span class="keyword">public</span> <span class="identifier">word</span>
+<span class="special">{</span>
+<span class="keyword">public</span><span class="special">:</span>
+ <span class="keyword">virtual</span> <span class="keyword">const</span> <span class="keyword">char</span> <span class="special">*</span> <span class="identifier">get_val</span><span class="special">(){</span><span class="keyword">return</span> <span class="string">"buonasera"</span><span class="special">;}</span>
+<span class="special">};</span>
+</pre>
+<p>
+ </p>
+<p>
+ Now we have the word 'hello' and 'world' implemented in several languages.
+ </p>
+<p>
+ And then, how can we specify, given an implementation of <code class="literal">word</code>
+ interface, in which language is the translation and which is the original word
+ (in a reference language, english in this case)? Well, as we want to store
+ implementation specific information we could use the Info class for this implementations.
+ </p>
+<p>
+ We define a new class called <code class="literal">word_description</code> where we can
+ define the language and the original word. This will be our Info class:
+ </p>
+<p>
+
+</p>
+<pre class="programlisting">
+<span class="keyword">struct</span> <span class="identifier">word_description</span>
+<span class="special">{</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="identifier">language</span><span class="special">;</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="identifier">english_translation</span><span class="special">;</span>
+
+ <span class="identifier">word_description</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="identifier">language</span><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="identifier">english_translation</span><span class="special">)</span>
+ <span class="special">:</span> <span class="identifier">language</span><span class="special">(</span><span class="identifier">language</span><span class="special">),</span> <span class="identifier">english_translation</span><span class="special">(</span><span class="identifier">english_translation</span><span class="special">)</span> <span class="special">{}</span>
+<span class="special">};</span>
+</pre>
+<p>
+ </p>
+<p>
+ Finally, just store a <code class="literal">word_description</code> instance when adding
+ the words to the factory map, describing the original word and the language:
+ </p>
+<p>
+
+</p>
+<pre class="programlisting">
+<span class="keyword">extern</span> <span class="string">"C"</span> <span class="keyword">void</span> <span class="identifier">BOOST_EXTENSION_EXPORT_DECL</span> <span class="identifier">extension_export_multilanguage_word</span><span class="special">(</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">extensions</span><span class="special">::</span><span class="identifier">factory_map</span> <span class="special">&amp;</span> <span class="identifier">fm</span><span class="special">)</span>
+<span class="special">{</span>
+ <span class="identifier">fm</span><span class="special">.</span><span class="identifier">add</span><span class="special">&lt;</span><span class="identifier">hola</span><span class="special">,</span> <span class="identifier">word</span><span class="special">,</span> <span class="identifier">word_description</span><span class="special">&gt;(</span><span class="identifier">word_description</span><span class="special">(</span><span class="string">"spanish"</span><span class="special">,</span> <span class="string">"hello"</span><span class="special">));</span>
+ <span class="identifier">fm</span><span class="special">.</span><span class="identifier">add</span><span class="special">&lt;</span><span class="identifier">mundo</span><span class="special">,</span> <span class="identifier">word</span><span class="special">,</span> <span class="identifier">word_description</span><span class="special">&gt;(</span><span class="identifier">word_description</span><span class="special">(</span><span class="string">"spanish"</span><span class="special">,</span> <span class="string">"world!"</span><span class="special">));</span>
+
+ <span class="identifier">fm</span><span class="special">.</span><span class="identifier">add</span><span class="special">&lt;</span><span class="identifier">bonjour</span><span class="special">,</span> <span class="identifier">word</span><span class="special">,</span> <span class="identifier">word_description</span><span class="special">&gt;(</span><span class="identifier">word_description</span><span class="special">(</span><span class="string">"french"</span><span class="special">,</span> <span class="string">"hello"</span><span class="special">));</span>
+ <span class="identifier">fm</span><span class="special">.</span><span class="identifier">add</span><span class="special">&lt;</span><span class="identifier">monde</span><span class="special">,</span> <span class="identifier">word</span><span class="special">,</span> <span class="identifier">word_description</span><span class="special">&gt;(</span><span class="identifier">word_description</span><span class="special">(</span><span class="string">"french"</span><span class="special">,</span> <span class="string">"world!"</span><span class="special">));</span>
+
+ <span class="identifier">fm</span><span class="special">.</span><span class="identifier">add</span><span class="special">&lt;</span><span class="identifier">buonasera</span><span class="special">,</span> <span class="identifier">word</span><span class="special">,</span> <span class="identifier">word_description</span><span class="special">&gt;(</span><span class="identifier">word_description</span><span class="special">(</span><span class="string">"italian"</span><span class="special">,</span> <span class="string">"hello"</span><span class="special">));</span>
+ <span class="identifier">fm</span><span class="special">.</span><span class="identifier">add</span><span class="special">&lt;</span><span class="identifier">mondo</span><span class="special">,</span> <span class="identifier">word</span><span class="special">,</span> <span class="identifier">word_description</span><span class="special">&gt;(</span><span class="identifier">word_description</span><span class="special">(</span><span class="string">"italian"</span><span class="special">,</span> <span class="string">"world!"</span><span class="special">));</span>
+
+ <span class="identifier">fm</span><span class="special">.</span><span class="identifier">add</span><span class="special">&lt;</span><span class="identifier">hello</span><span class="special">,</span> <span class="identifier">word</span><span class="special">,</span> <span class="identifier">word_description</span><span class="special">&gt;(</span><span class="identifier">word_description</span><span class="special">(</span><span class="string">"english"</span><span class="special">,</span> <span class="string">"hello"</span><span class="special">));</span>
+ <span class="identifier">fm</span><span class="special">.</span><span class="identifier">add</span><span class="special">&lt;</span><span class="identifier">world</span><span class="special">,</span> <span class="identifier">word</span><span class="special">,</span> <span class="identifier">word_description</span><span class="special">&gt;(</span><span class="identifier">word_description</span><span class="special">(</span><span class="string">"english"</span><span class="special">,</span> <span class="string">"world!"</span><span class="special">));</span>
+<span class="special">}</span>
+</pre>
+<p>
+ </p>
+<p>
+ In the code we could see that add argument is a Info class instance. In this
+ case is <code class="literal">word_description</code> which receives the language and
+ word as arguments.
+ </p>
+<p>
+ Now we could start using that information in the main code. Rerieving Info
+ class is easy, you should just call <code class="literal">get_info()</code> method of
+ the factory.
+ </p>
+<p>
+ Let's see some code using the multilanguage hello world words:
+ </p>
+<p>
+
+</p>
+<pre class="programlisting">
+<span class="keyword">for</span> <span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">list</span><span class="special">&lt;</span><span class="identifier">factory</span><span class="special">&lt;</span><span class="identifier">word</span><span class="special">,</span> <span class="identifier">word_description</span><span class="special">&gt;</span> <span class="special">&gt;::</span><span class="identifier">iterator</span> <span class="identifier">current_word</span> <span class="special">=</span> <span class="identifier">factory_list</span><span class="special">.</span><span class="identifier">begin</span><span class="special">();</span>
+ <span class="identifier">current_word</span> <span class="special">!=</span> <span class="identifier">factory_list</span><span class="special">.</span><span class="identifier">end</span><span class="special">();</span> <span class="special">++</span><span class="identifier">current_word</span><span class="special">)</span>
+<span class="special">{</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">auto_ptr</span><span class="special">&lt;</span><span class="identifier">word</span><span class="special">&gt;</span> <span class="identifier">word_ptr</span><span class="special">(</span><span class="identifier">current_word</span><span class="special">-&gt;</span><span class="identifier">create</span><span class="special">());</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">word_ptr</span><span class="special">-&gt;</span><span class="identifier">get_val</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="string">" is "</span> <span class="special">&lt;&lt;</span> <span class="identifier">current_word</span><span class="special">-&gt;</span><span class="identifier">get_info</span><span class="special">().</span><span class="identifier">english_translation</span>
+ <span class="special">&lt;&lt;</span> <span class="string">" in "</span> <span class="special">&lt;&lt;</span> <span class="identifier">current_word</span><span class="special">-&gt;</span><span class="identifier">get_info</span><span class="special">().</span><span class="identifier">language</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
+<span class="special">}</span>
+<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
+</pre>
+<p>
+ </p>
+<p>
+ And we get the following output:
+ </p>
+<div class="informaltable">
+<h4>
+<a name="id2575920"></a>
+ </h4>
+<table class="table">
+<colgroup><col></colgroup>
+<tbody><tr><td><code class="literal">hola is hello in spanish<br> mundo! is world! in spanish<br>
+ bonjour is hello in french<br> monde! is world! in french<br> buonasera
+ is hello in italian<br> mondo! is world! in italian<br> hello is
+ hello in english<br> world! is world! in english<br> </code></td></tr></tbody>
+</table>
+</div>
+<p>
+ Now that we have described our example the major parts could be summarized:
+ </p>
+<div class="orderedlist"><ol type="1">
+<li>
+ We just define our interface and implementations normally.
+ </li>
+<li>
+ We define the Info class.
+ </li>
+<li>
+ When we add the implementations to the factory_map we construct a new Info
+ class instance for each implementation, storing the needed data.
+ </li>
+<li>
+ Finally, we could use the <code class="literal">get_info</code> method in the main
+ file to retrieve the data.
+ </li>
+</ol></div>
+<p>
+ Tutorial 5 describes a more complex example of the use of the Info class.
+ </p>
+</div>
+<table width="100%"><tr>
+<td align="left"></td>
+<td align="right"><small>Copyright © 2007 Jeremy Pack, Mariano G. Consoni</small></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="shared_libraries.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="performance_analysis.html"><img src="../images/next.png" alt="Next"></a>
+</div>
+</body>
+</html>


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk