1<?xml version="1.0" encoding="utf-8"?> 2<!DOCTYPE section PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN" 3 "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd"> 4<!-- 5Copyright Douglas Gregor 2001-2004 6Copyright Frank Mori Hess 2007-2009 7 8Distributed under the Boost Software License, Version 1.0. (See accompanying 9file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 10--> 11<section last-revision="$Date: 2007-06-12 14:01:23 -0400 (Tue, 12 Jun 2007) $" id="signals2.examples"> 12 <title>Example programs</title> 13 14 <using-namespace name="boost::signals2"/> 15 <using-namespace name="boost"/> 16 17 <section id="signals2.examples.misc"> 18 <title>Miscellaneous Tutorial Examples</title> 19 <section id="signals2.examples.tutorial.hello_world_slot"> 20 <title>hello_world_slot</title> 21 <para> 22 This example is a basic example of connecting a slot to a signal 23 and then invoking the signal. 24 </para> 25 <para> 26 Download <ulink url="boost:/libs/signals2/example/hello_world_slot.cpp">hello_world_slot.cpp</ulink>. 27 </para> 28 </section> 29 <section id="signals2.examples.tutorial.hello_world_multi_slot"> 30 <title>hello_world_multi_slot</title> 31 <para> 32 This example extends the hello_world_slot example slightly by connecting more than one 33 slot to the signal before invoking it. 34 </para> 35 <para> 36 Download <ulink url="boost:/libs/signals2/example/hello_world_multi_slot.cpp">hello_world_multi_slot.cpp</ulink>. 37 </para> 38 </section> 39 <section id="signals2.examples.tutorial.ordering_slots"> 40 <title>ordering_slots</title> 41 <para> 42 This example extends the hello_world_multi_slot example slightly by 43 using slot groups to specify 44 the order slots should be invoked. 45 </para> 46 <para> 47 Download <ulink url="boost:/libs/signals2/example/ordering_slots.cpp">ordering_slots.cpp</ulink>. 48 </para> 49 </section> 50 <section id="signals2.examples.tutorial.slot_arguments"> 51 <title>slot_arguments</title> 52 <para> 53 The slot_arguments program shows how to pass arguments from a signal invocation to slots. 54 </para> 55 <para> 56 Download <ulink url="boost:/libs/signals2/example/slot_arguments.cpp">slot_arguments.cpp</ulink>. 57 </para> 58 </section> 59 <section id="signals2.examples.tutorial.signal_return_value"> 60 <title>signal_return_value</title> 61 <para> 62 This example shows how to return a value from slots to the signal invocation. 63 It uses the default <classname>optional_last_value</classname> combiner. 64 </para> 65 <para> 66 Download <ulink url="boost:/libs/signals2/example/signal_return_value.cpp">signal_return_value.cpp</ulink>. 67 </para> 68 </section> 69 <section id="signals2.examples.tutorial.custom_combiners"> 70 <title>custom_combiners</title> 71 <para> 72 This example shows more returning of values from slots to the signal invocation. 73 This time, custom combiners are defined and used. 74 </para> 75 <para> 76 Download <ulink url="boost:/libs/signals2/example/custom_combiners.cpp">custom_combiners.cpp</ulink>. 77 </para> 78 </section> 79 <section id="signals2.examples.tutorial.disconnect_and_block"> 80 <title>disconnect_and_block</title> 81 <para> 82 This example demonstrates various means of manually disconnecting slots, as well as temporarily 83 blocking them via <classname>shared_connection_block</classname>. 84 </para> 85 <para> 86 Download <ulink url="boost:/libs/signals2/example/disconnect_and_block.cpp">disconnect_and_block.cpp</ulink>. 87 </para> 88 </section> 89 <section id="signals2.examples.tutorial.passing_slots"> 90 <title>passing_slots</title> 91 <para> 92 This example demonstrates the passing of slot functions to a private signal 93 through a non-template interface. 94 </para> 95 <para> 96 Download <ulink url="boost:/libs/signals2/example/passing_slots.cpp">passing_slots.cpp</ulink>. 97 </para> 98 </section> 99 <section id="signals2.examples.tutorial.extended_slot"> 100 <title>extended_slot</title> 101 <para> 102 This example demonstrates connecting an extended slot to a signal. An extended slot 103 accepts a reference to its invoking signal-slot connection as an additional argument, 104 permitting the slot to temporarily block or permanently disconnect itself. 105 </para> 106 <para> 107 Download <ulink url="boost:/libs/signals2/example/extended_slot.cpp">extended_slot.cpp</ulink>. 108 </para> 109 </section> 110 </section> 111 <section id="signals2.examples.document-view"> 112 <title>Document-View</title> 113 <section id="signals2.examples.document-view.doc_view"> 114 <title>doc_view</title> 115 <para> 116 This is the document-view example program which is described in the 117 <link linkend="signals2.tutorial.document-view">tutorial</link>. It shows 118 usage of a signal and slots to implement two different views of 119 a text document. 120 </para> 121 <para> 122 Download <ulink url="boost:/libs/signals2/example/doc_view.cpp">doc_view.cpp</ulink>. 123 </para> 124 </section> 125 <section id="signals2.examples.document-view.doc_view_acm"> 126 <title>doc_view_acm</title> 127 <para> 128 This program modifies the original doc_view.cpp example to employ 129 automatic connection management. 130 </para> 131 <para> 132 Download <ulink url="boost:/libs/signals2/example/doc_view_acm.cpp">doc_view_acm.cpp</ulink>. 133 </para> 134 </section> 135 <section id="signals2.examples.document-view.doc_view_acm_deconstruct"> 136 <title>doc_view_acm_deconstruct</title> 137 <para> 138 This program modifies the doc_view_acm.cpp example to use postconstructors 139 and the <functionname>deconstruct()</functionname> factory function. 140 </para> 141 <para> 142 Download <ulink url="boost:/libs/signals2/example/doc_view_acm_deconstruct.cpp">doc_view_acm_deconstruct.cpp</ulink>. 143 </para> 144 </section> 145 </section> 146 <section id="signals2.examples.deconstruct"> 147 <title>Postconstructors and Predestructors with <code>deconstruct()</code></title> 148 <section id="signals2.examples.deconstruct.postconstructor_ex1"> 149 <title>postconstructor_ex1</title> 150 <para> 151 This program is a basic example of how to define a class with a postconstructor which 152 uses <functionname>deconstruct()</functionname> as its factory function. 153 </para> 154 <para> 155 Download <ulink url="boost:/libs/signals2/example/postconstructor_ex1.cpp">postconstructor_ex1</ulink>. 156 </para> 157 </section> 158 <section id="signals2.examples.deconstruct.postconstructor_ex2"> 159 <title>postconstructor_ex2</title> 160 <para> 161 This program extends the postconstructor_ex1 example slightly, by additionally passing arguments from 162 the <functionname>deconstruct()</functionname> call through to the class' constructor 163 and postconstructor. 164 </para> 165 <para> 166 Download <ulink url="boost:/libs/signals2/example/postconstructor_ex2.cpp">postconstructor_ex2</ulink>. 167 </para> 168 </section> 169 <section id="signals2.examples.deconstruct.predestructor_example"> 170 <title>predestructor_example</title> 171 <para> 172 This program is a basic example of how to define a class with a predestructor which 173 uses <functionname>deconstruct()</functionname> as its factory function. 174 </para> 175 <para> 176 Download <ulink url="boost:/libs/signals2/example/predestructor_example.cpp">predestructor_example</ulink>. 177 </para> 178 </section> 179 </section> 180</section> 181