1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 2<html> 3<head> 4<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 5<title>Example programs</title> 6<link rel="stylesheet" href="../../../doc/src/boostbook.css" type="text/css"> 7<meta name="generator" content="DocBook XSL Stylesheets V1.79.1"> 8<link rel="home" href="../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset"> 9<link rel="up" href="../signals2.html" title="Chapter 35. Boost.Signals2"> 10<link rel="prev" href="tutorial.html" title="Tutorial"> 11<link rel="next" href="reference.html" title="Reference"> 12</head> 13<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> 14<table cellpadding="2" width="100%"><tr> 15<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../boost.png"></td> 16<td align="center"><a href="../../../index.html">Home</a></td> 17<td align="center"><a href="../../../libs/libraries.htm">Libraries</a></td> 18<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> 19<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> 20<td align="center"><a href="../../../more/index.htm">More</a></td> 21</tr></table> 22<hr> 23<div class="spirit-nav"> 24<a accesskey="p" href="tutorial.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../signals2.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="reference.html"><img src="../../../doc/src/images/next.png" alt="Next"></a> 25</div> 26<div class="section"> 27<div class="titlepage"><div><div><h2 class="title" style="clear: both"> 28<a name="signals2.examples"></a>Example programs</h2></div></div></div> 29<div class="toc"><dl class="toc"> 30<dt><span class="section"><a href="examples.html#signals2.examples.misc">Miscellaneous Tutorial Examples</a></span></dt> 31<dt><span class="section"><a href="examples.html#signals2.examples.document-view">Document-View</a></span></dt> 32<dt><span class="section"><a href="examples.html#signals2.examples.deconstruct">Postconstructors and Predestructors with <code class="computeroutput">deconstruct()</code></a></span></dt> 33</dl></div> 34<div class="section"> 35<div class="titlepage"><div><div><h3 class="title"> 36<a name="signals2.examples.misc"></a>Miscellaneous Tutorial Examples</h3></div></div></div> 37<div class="toc"><dl class="toc"> 38<dt><span class="section"><a href="examples.html#signals2.examples.tutorial.hello_world_slot">hello_world_slot</a></span></dt> 39<dt><span class="section"><a href="examples.html#signals2.examples.tutorial.hello_world_multi_slot">hello_world_multi_slot</a></span></dt> 40<dt><span class="section"><a href="examples.html#signals2.examples.tutorial.ordering_slots">ordering_slots</a></span></dt> 41<dt><span class="section"><a href="examples.html#signals2.examples.tutorial.slot_arguments">slot_arguments</a></span></dt> 42<dt><span class="section"><a href="examples.html#signals2.examples.tutorial.signal_return_value">signal_return_value</a></span></dt> 43<dt><span class="section"><a href="examples.html#signals2.examples.tutorial.custom_combiners">custom_combiners</a></span></dt> 44<dt><span class="section"><a href="examples.html#signals2.examples.tutorial.disconnect_and_block">disconnect_and_block</a></span></dt> 45<dt><span class="section"><a href="examples.html#signals2.examples.tutorial.passing_slots">passing_slots</a></span></dt> 46<dt><span class="section"><a href="examples.html#signals2.examples.tutorial.extended_slot">extended_slot</a></span></dt> 47</dl></div> 48<div class="section"> 49<div class="titlepage"><div><div><h4 class="title"> 50<a name="signals2.examples.tutorial.hello_world_slot"></a>hello_world_slot</h4></div></div></div> 51<p> 52 This example is a basic example of connecting a slot to a signal 53 and then invoking the signal. 54 </p> 55<p> 56 Download <a href="../../../libs/signals2/example/hello_world_slot.cpp" target="_top">hello_world_slot.cpp</a>. 57 </p> 58</div> 59<div class="section"> 60<div class="titlepage"><div><div><h4 class="title"> 61<a name="signals2.examples.tutorial.hello_world_multi_slot"></a>hello_world_multi_slot</h4></div></div></div> 62<p> 63 This example extends the hello_world_slot example slightly by connecting more than one 64 slot to the signal before invoking it. 65 </p> 66<p> 67 Download <a href="../../../libs/signals2/example/hello_world_multi_slot.cpp" target="_top">hello_world_multi_slot.cpp</a>. 68 </p> 69</div> 70<div class="section"> 71<div class="titlepage"><div><div><h4 class="title"> 72<a name="signals2.examples.tutorial.ordering_slots"></a>ordering_slots</h4></div></div></div> 73<p> 74 This example extends the hello_world_multi_slot example slightly by 75 using slot groups to specify 76 the order slots should be invoked. 77 </p> 78<p> 79 Download <a href="../../../libs/signals2/example/ordering_slots.cpp" target="_top">ordering_slots.cpp</a>. 80 </p> 81</div> 82<div class="section"> 83<div class="titlepage"><div><div><h4 class="title"> 84<a name="signals2.examples.tutorial.slot_arguments"></a>slot_arguments</h4></div></div></div> 85<p> 86 The slot_arguments program shows how to pass arguments from a signal invocation to slots. 87 </p> 88<p> 89 Download <a href="../../../libs/signals2/example/slot_arguments.cpp" target="_top">slot_arguments.cpp</a>. 90 </p> 91</div> 92<div class="section"> 93<div class="titlepage"><div><div><h4 class="title"> 94<a name="signals2.examples.tutorial.signal_return_value"></a>signal_return_value</h4></div></div></div> 95<p> 96 This example shows how to return a value from slots to the signal invocation. 97 It uses the default <code class="computeroutput"><a class="link" href="../boost/signals2/optional_last_value.html" title="Class template optional_last_value">optional_last_value</a></code> combiner. 98 </p> 99<p> 100 Download <a href="../../../libs/signals2/example/signal_return_value.cpp" target="_top">signal_return_value.cpp</a>. 101 </p> 102</div> 103<div class="section"> 104<div class="titlepage"><div><div><h4 class="title"> 105<a name="signals2.examples.tutorial.custom_combiners"></a>custom_combiners</h4></div></div></div> 106<p> 107 This example shows more returning of values from slots to the signal invocation. 108 This time, custom combiners are defined and used. 109 </p> 110<p> 111 Download <a href="../../../libs/signals2/example/custom_combiners.cpp" target="_top">custom_combiners.cpp</a>. 112 </p> 113</div> 114<div class="section"> 115<div class="titlepage"><div><div><h4 class="title"> 116<a name="signals2.examples.tutorial.disconnect_and_block"></a>disconnect_and_block</h4></div></div></div> 117<p> 118 This example demonstrates various means of manually disconnecting slots, as well as temporarily 119 blocking them via <code class="computeroutput"><a class="link" href="../boost/signals2/shared_connection_block.html" title="Class shared_connection_block">shared_connection_block</a></code>. 120 </p> 121<p> 122 Download <a href="../../../libs/signals2/example/disconnect_and_block.cpp" target="_top">disconnect_and_block.cpp</a>. 123 </p> 124</div> 125<div class="section"> 126<div class="titlepage"><div><div><h4 class="title"> 127<a name="signals2.examples.tutorial.passing_slots"></a>passing_slots</h4></div></div></div> 128<p> 129 This example demonstrates the passing of slot functions to a private signal 130 through a non-template interface. 131 </p> 132<p> 133 Download <a href="../../../libs/signals2/example/passing_slots.cpp" target="_top">passing_slots.cpp</a>. 134 </p> 135</div> 136<div class="section"> 137<div class="titlepage"><div><div><h4 class="title"> 138<a name="signals2.examples.tutorial.extended_slot"></a>extended_slot</h4></div></div></div> 139<p> 140 This example demonstrates connecting an extended slot to a signal. An extended slot 141 accepts a reference to its invoking signal-slot connection as an additional argument, 142 permitting the slot to temporarily block or permanently disconnect itself. 143 </p> 144<p> 145 Download <a href="../../../libs/signals2/example/extended_slot.cpp" target="_top">extended_slot.cpp</a>. 146 </p> 147</div> 148</div> 149<div class="section"> 150<div class="titlepage"><div><div><h3 class="title"> 151<a name="signals2.examples.document-view"></a>Document-View</h3></div></div></div> 152<div class="toc"><dl class="toc"> 153<dt><span class="section"><a href="examples.html#signals2.examples.document-view.doc_view">doc_view</a></span></dt> 154<dt><span class="section"><a href="examples.html#signals2.examples.document-view.doc_view_acm">doc_view_acm</a></span></dt> 155<dt><span class="section"><a href="examples.html#signals2.examples.document-view.doc_view_acm_deconstruct">doc_view_acm_deconstruct</a></span></dt> 156</dl></div> 157<div class="section"> 158<div class="titlepage"><div><div><h4 class="title"> 159<a name="signals2.examples.document-view.doc_view"></a>doc_view</h4></div></div></div> 160<p> 161 This is the document-view example program which is described in the 162 <a class="link" href="tutorial.html#signals2.tutorial.document-view" title="Example: Document-View">tutorial</a>. It shows 163 usage of a signal and slots to implement two different views of 164 a text document. 165 </p> 166<p> 167 Download <a href="../../../libs/signals2/example/doc_view.cpp" target="_top">doc_view.cpp</a>. 168 </p> 169</div> 170<div class="section"> 171<div class="titlepage"><div><div><h4 class="title"> 172<a name="signals2.examples.document-view.doc_view_acm"></a>doc_view_acm</h4></div></div></div> 173<p> 174 This program modifies the original doc_view.cpp example to employ 175 automatic connection management. 176 </p> 177<p> 178 Download <a href="../../../libs/signals2/example/doc_view_acm.cpp" target="_top">doc_view_acm.cpp</a>. 179 </p> 180</div> 181<div class="section"> 182<div class="titlepage"><div><div><h4 class="title"> 183<a name="signals2.examples.document-view.doc_view_acm_deconstruct"></a>doc_view_acm_deconstruct</h4></div></div></div> 184<p> 185 This program modifies the doc_view_acm.cpp example to use postconstructors 186 and the <code class="computeroutput"><a class="link" href="../boost/signals2/deconstruct.html" title="Function deconstruct">deconstruct()</a></code> factory function. 187 </p> 188<p> 189 Download <a href="../../../libs/signals2/example/doc_view_acm_deconstruct.cpp" target="_top">doc_view_acm_deconstruct.cpp</a>. 190 </p> 191</div> 192</div> 193<div class="section"> 194<div class="titlepage"><div><div><h3 class="title"> 195<a name="signals2.examples.deconstruct"></a>Postconstructors and Predestructors with <code class="computeroutput">deconstruct()</code> 196</h3></div></div></div> 197<div class="toc"><dl class="toc"> 198<dt><span class="section"><a href="examples.html#signals2.examples.deconstruct.postconstructor_ex1">postconstructor_ex1</a></span></dt> 199<dt><span class="section"><a href="examples.html#signals2.examples.deconstruct.postconstructor_ex2">postconstructor_ex2</a></span></dt> 200<dt><span class="section"><a href="examples.html#signals2.examples.deconstruct.predestructor_example">predestructor_example</a></span></dt> 201</dl></div> 202<div class="section"> 203<div class="titlepage"><div><div><h4 class="title"> 204<a name="signals2.examples.deconstruct.postconstructor_ex1"></a>postconstructor_ex1</h4></div></div></div> 205<p> 206 This program is a basic example of how to define a class with a postconstructor which 207 uses <code class="computeroutput"><a class="link" href="../boost/signals2/deconstruct.html" title="Function deconstruct">deconstruct()</a></code> as its factory function. 208 </p> 209<p> 210 Download <a href="../../../libs/signals2/example/postconstructor_ex1.cpp" target="_top">postconstructor_ex1</a>. 211 </p> 212</div> 213<div class="section"> 214<div class="titlepage"><div><div><h4 class="title"> 215<a name="signals2.examples.deconstruct.postconstructor_ex2"></a>postconstructor_ex2</h4></div></div></div> 216<p> 217 This program extends the postconstructor_ex1 example slightly, by additionally passing arguments from 218 the <code class="computeroutput"><a class="link" href="../boost/signals2/deconstruct.html" title="Function deconstruct">deconstruct()</a></code> call through to the class' constructor 219 and postconstructor. 220 </p> 221<p> 222 Download <a href="../../../libs/signals2/example/postconstructor_ex2.cpp" target="_top">postconstructor_ex2</a>. 223 </p> 224</div> 225<div class="section"> 226<div class="titlepage"><div><div><h4 class="title"> 227<a name="signals2.examples.deconstruct.predestructor_example"></a>predestructor_example</h4></div></div></div> 228<p> 229 This program is a basic example of how to define a class with a predestructor which 230 uses <code class="computeroutput"><a class="link" href="../boost/signals2/deconstruct.html" title="Function deconstruct">deconstruct()</a></code> as its factory function. 231 </p> 232<p> 233 Download <a href="../../../libs/signals2/example/predestructor_example.cpp" target="_top">predestructor_example</a>. 234 </p> 235</div> 236</div> 237</div> 238<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 239<td align="left"><p><small>Last revised: June 12, 2007 at 14:01:23 -0400</small></p></td> 240<td align="right"><div class="copyright-footer">Copyright © 2001-2004 Douglas Gregor<br>Copyright © 2007-2009 Frank Mori Hess<p>Distributed under the Boost 241 Software License, Version 1.0. (See accompanying file 242 <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> 243</div></td> 244</tr></table> 245<hr> 246<div class="spirit-nav"> 247<a accesskey="p" href="tutorial.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../signals2.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="reference.html"><img src="../../../doc/src/images/next.png" alt="Next"></a> 248</div> 249</body> 250</html> 251