diff options
author | Anas Nashif <anas.nashif@intel.com> | 2012-10-30 12:57:26 -0700 |
---|---|---|
committer | Anas Nashif <anas.nashif@intel.com> | 2012-10-30 12:57:26 -0700 |
commit | 1a78a62555be32868418fe52f8e330c9d0f95d5a (patch) | |
tree | d3765a80e7d3b9640ec2e930743630cd6b9fce2b /doc/html/signals/s05.html | |
download | boost-1a78a62555be32868418fe52f8e330c9d0f95d5a.tar.gz boost-1a78a62555be32868418fe52f8e330c9d0f95d5a.tar.bz2 boost-1a78a62555be32868418fe52f8e330c9d0f95d5a.zip |
Imported Upstream version 1.49.0upstream/1.49.0
Diffstat (limited to 'doc/html/signals/s05.html')
-rwxr-xr-x | doc/html/signals/s05.html | 212 |
1 files changed, 212 insertions, 0 deletions
diff --git a/doc/html/signals/s05.html b/doc/html/signals/s05.html new file mode 100755 index 0000000000..3ab9d2d4b4 --- /dev/null +++ b/doc/html/signals/s05.html @@ -0,0 +1,212 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>Design Overview</title> +<link rel="stylesheet" href="../../../doc/src/boostbook.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.76.1"> +<link rel="home" href="../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset"> +<link rel="up" href="../signals.html" title="Chapter 24. Boost.Signals"> +<link rel="prev" href="s04.html" title="Frequently Asked Questions"> +<link rel="next" href="s06.html" title="Design Rationale"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"><tr> +<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../boost.png"></td> +<td align="center"><a href="../../../index.html">Home</a></td> +<td align="center"><a href="../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> +<td align="center"><a href="../../../more/index.htm">More</a></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="s04.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../signals.html"><img src="../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="s06.html"><img src="../../../doc/src/images/next.png" alt="Next"></a> +</div> +<div class="section"> +<div class="titlepage"><div><div><h2 class="title" style="clear: both"> +<a name="id3149052"></a>Design Overview</h2></div></div></div> +<div class="toc"><dl> +<dt><span class="section"><a href="s05.html#id3149057">Type Erasure</a></span></dt> +<dt><span class="section"><a href="s05.html#id3149127"><code class="computeroutput">connection</code> class</a></span></dt> +<dt><span class="section"><a href="s05.html#id3149245">Slot Call Iterator</a></span></dt> +<dt><span class="section"><a href="s05.html#id3149443"><code class="computeroutput">visit_each</code> function template</a></span></dt> +</dl></div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="id3149057"></a>Type Erasure</h3></div></div></div> +<p>"Type erasure", where static type information is eliminated + by the use of dynamically dispatched interfaces, is used + extensively within the Boost.Signals library to reduce the amount + of code generated by template instantiation. Each signal must + manage a list of slots and their associated connections, along + with a <code class="computeroutput">std::map</code> to map from group identifiers to + their associated connections. However, instantiating this map for + every token type, and perhaps within each translation unit (for + some popular template instantiation strategies) increase compile + time overhead and space overhead.</p> +<p> To combat this so-called "template bloat", we use + Boost.Function and Boost.Any to store unknown types and + operations. Then, all of the code for handling the list of slots + and the mapping from slot identifiers to connections is factored + into the class <code class="computeroutput">signal_base</code> + that deals exclusively with the <code class="computeroutput">any</code> and + <code class="computeroutput"><a class="link" href="../boost/function.html" title="Class template function">function</a></code> objects, hiding the + actual implementations using the well-known pimpl idiom. The + actual <code class="computeroutput"><a class="link" href="../boost/signalN.html" title="Class template signalN">signalN</a></code> class templates + deal only with code that will change depending on the number of + arguments or which is inherently template-dependent (such as + connection).</p> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="id3149127"></a><code class="computeroutput">connection</code> class</h3></div></div></div> +<p> The <code class="computeroutput"><a class="link" href="../boost/signals/connection.html" title="Class connection">connection</a></code> class is + central to the behavior of the Boost.Signals library. It is the + only entity within the Boost.Signals system that has knowledge of + all objects that are associated by a given connection. To be + specific, the <code class="computeroutput"><a class="link" href="../boost/signals/connection.html" title="Class connection">connection</a></code> class + itself is merely a thin wrapper over a + <code class="computeroutput">shared_ptr</code> to a + <code class="computeroutput">basic_connection</code> object.</p> +<p> <code class="computeroutput"><a class="link" href="../boost/signals/connection.html" title="Class connection">connection</a></code> objects are + stored by all participants in the Signals system: each + <code class="computeroutput"><a class="link" href="../boost/signals/trackable.html" title="Class trackable">trackable</a></code> object contains a + list of <code class="computeroutput"><a class="link" href="../boost/signals/connection.html" title="Class connection">connection</a></code> objects + describing all connections it is a part of; similarly, all signals + contain a set of pairs that define a slot. The pairs consist of a + slot function object (generally a Boost.Function object) and a + <code class="computeroutput"><a class="link" href="../boost/signals/connection.html" title="Class connection">connection</a></code> object (that will + disconnect on destruction). Finally, the mapping from slot groups + to slots is based on the key value in a + <code class="computeroutput">std::multimap</code> (the stored data + in the <code class="computeroutput">std::multimap</code> is the + slot pair).</p> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="id3149245"></a>Slot Call Iterator</h3></div></div></div> +<p> The slot call iterator is conceptually a stack of iterator + adaptors that modify the behavior of the underlying iterator + through the list of slots. The following table describes the type + and behavior of each iterator adaptor required. Note that this is + only a conceptual model: the implementation collapses all these + layers into a single iterator adaptor because several popular + compilers failed to compile the implementation of the conceptual + model.</p> +<div class="informaltable"><table class="table"> +<colgroup> +<col> +<col> +</colgroup> +<thead><tr> +<th align="left">Iterator Adaptor</th> +<th align="left">Purpose</th> +</tr></thead> +<tbody> +<tr> +<td align="left"><p>Slot List Iterator</p></td> +<td align="left"><p>An iterator through the list of slots + connected to a signal. The <code class="computeroutput">value_type</code> of this + iterator will be + <code class="computeroutput">std::pair<any, + connection></code>, where the + <code class="computeroutput"><a class="link" href="../boost/any.html" title="Class any">any</a></code> contains an + instance of the slot function type.</p></td> +</tr> +<tr> +<td align="left"><p>Filter Iterator Adaptor</p></td> +<td align="left"><p>This filtering iterator adaptor filters out + slots that have been disconnected, so we never see a + disconnected slot in later stages.</p></td> +</tr> +<tr> +<td align="left"><p>Projection Iterator Adaptor</p></td> +<td align="left"><p>The projection iterator adaptor returns a + reference to the first member of the pair that constitutes + a connected slot (e.g., just the + <code class="computeroutput"><a class="link" href="../boost/any.html" title="Class any">boost::any</a></code> object that + holds the slot function).</p></td> +</tr> +<tr> +<td align="left"><p>Transform Iterator Adaptor</p></td> +<td align="left"><p>This transform iterator adaptor performs an + <code class="computeroutput"><a class="link" href="../boost/any_cast.html" title="Function any_cast">any_cast</a></code> to + extract a reference to the slot function with the + appropriate slot function type.</p></td> +</tr> +<tr> +<td align="left"><p>Transform Iterator Adaptor</p></td> +<td align="left"><p>This transform iterator adaptor calls the + function object returned by dereferencing the underlying + iterator with the set of arguments given to the signal + itself, and returns the result of that slot + call.</p></td> +</tr> +<tr> +<td align="left"><p>Input Caching Iterator Adaptor</p></td> +<td align="left"><p>This iterator adaptor caches the result of + dereferencing the underlying iterator. Therefore, + dereferencing this iterator multiple times will only + result in the underlying iterator being dereferenced once; + thus, a slot can only be called once but its result can be + used multiple times.</p></td> +</tr> +<tr> +<td align="left"><p>Slot Call Iterator</p></td> +<td align="left"><p>Iterates over calls to each slot.</p></td> +</tr> +</tbody> +</table></div> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="id3149443"></a><code class="computeroutput">visit_each</code> function template</h3></div></div></div> +<p> The <code class="computeroutput"><a class="link" href="../boost/visit_each.html" title="Function template visit_each">visit_each</a></code> + function template is a mechanism for discovering objects that are + stored within another object. Function template + <code class="computeroutput"><a class="link" href="../boost/visit_each.html" title="Function template visit_each">visit_each</a></code> takes three + arguments: an object to explore, a visitor function object that is + invoked with each subobject, and the <code class="computeroutput">int</code> 0. </p> +<p> The third parameter is merely a temporary solution to the + widespread lack of proper function template partial ordering. The + primary <code class="computeroutput"><a class="link" href="../boost/visit_each.html" title="Function template visit_each">visit_each</a></code> + function template specifies this third parameter type to be + <code class="computeroutput">long</code>, whereas any user specializations must specify + their third parameter to be of type <code class="computeroutput">int</code>. Thus, even + though a broken compiler cannot tell the ordering between, e.g., a + match against a parameter <code class="computeroutput">T</code> and a parameter + <code class="computeroutput">A<T></code>, it can determine that the conversion from + the integer 0 to <code class="computeroutput">int</code> is better than the conversion to + <code class="computeroutput">long</code>. The ordering determined by this conversion thus + achieves partial ordering of the function templates in a limited, + but successful, way. The following example illustrates the use of + this technique:</p> +<pre class="programlisting"> +template<typename> class A {}; +template<typename T> void foo(T, long); +template<typename T> void foo(A<T>, int); +A<T> at; +foo(at, 0); +</pre> +<p> In this example, we assume that our compiler can not tell + that <code class="computeroutput">A<T></code> is a better match than + <code class="computeroutput">T</code>, and therefore assume that the function templates + cannot be ordered based on that parameter. Then the conversion + from 0 to <code class="computeroutput">int</code> is better than the conversion from 0 to + <code class="computeroutput">long</code>, and the second function template is + chosen. </p> +</div> +</div> +<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> +<td align="left"><p><small>Last revised: November 25, 2007 at 18:38:02 +0000</small></p></td> +<td align="right"><div class="copyright-footer">Copyright © 2001-2004 Douglas Gregor<p>Use, modification and distribution is subject to the Boost + Software License, Version 1.0. (See accompanying file + <code class="filename">LICENSE_1_0.txt</code> or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)</p> +</div></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="s04.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../signals.html"><img src="../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="s06.html"><img src="../../../doc/src/images/next.png" alt="Next"></a> +</div> +</body> +</html> |