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">
5 Copyright Douglas Gregor 2001-2004
6 Copyright Frank Mori Hess 2007-2009
8 Distributed under the Boost Software License, Version 1.0. (See accompanying
9 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
11 <section last-revision=
"$Date: 2007-06-12 14:01:23 -0400 (Tue, 12 Jun 2007) $" id=
"signals2.examples">
12 <title>Example programs
</title>
14 <using-namespace name=
"boost::signals2"/>
15 <using-namespace name=
"boost"/>
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>
22 This example is a basic example of connecting a slot to a signal
23 and then invoking the signal.
26 Download
<ulink url=
"boost:/libs/signals2/example/hello_world_slot.cpp">hello_world_slot.cpp
</ulink>.
29 <section id=
"signals2.examples.tutorial.hello_world_multi_slot">
30 <title>hello_world_multi_slot
</title>
32 This example extends the hello_world_slot example slightly by connecting more than one
33 slot to the signal before invoking it.
36 Download
<ulink url=
"boost:/libs/signals2/example/hello_world_multi_slot.cpp">hello_world_multi_slot.cpp
</ulink>.
39 <section id=
"signals2.examples.tutorial.ordering_slots">
40 <title>ordering_slots
</title>
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.
47 Download
<ulink url=
"boost:/libs/signals2/example/ordering_slots.cpp">ordering_slots.cpp
</ulink>.
50 <section id=
"signals2.examples.tutorial.slot_arguments">
51 <title>slot_arguments
</title>
53 The slot_arguments program shows how to pass arguments from a signal invocation to slots.
56 Download
<ulink url=
"boost:/libs/signals2/example/slot_arguments.cpp">slot_arguments.cpp
</ulink>.
59 <section id=
"signals2.examples.tutorial.signal_return_value">
60 <title>signal_return_value
</title>
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.
66 Download
<ulink url=
"boost:/libs/signals2/example/signal_return_value.cpp">signal_return_value.cpp
</ulink>.
69 <section id=
"signals2.examples.tutorial.custom_combiners">
70 <title>custom_combiners
</title>
72 This example shows more returning of values from slots to the signal invocation.
73 This time, custom combiners are defined and used.
76 Download
<ulink url=
"boost:/libs/signals2/example/custom_combiners.cpp">custom_combiners.cpp
</ulink>.
79 <section id=
"signals2.examples.tutorial.disconnect_and_block">
80 <title>disconnect_and_block
</title>
82 This example demonstrates various means of manually disconnecting slots, as well as temporarily
83 blocking them via
<classname>shared_connection_block
</classname>.
86 Download
<ulink url=
"boost:/libs/signals2/example/disconnect_and_block.cpp">disconnect_and_block.cpp
</ulink>.
89 <section id=
"signals2.examples.tutorial.passing_slots">
90 <title>passing_slots
</title>
92 This example demonstrates the passing of slot functions to a private signal
93 through a non-template interface.
96 Download
<ulink url=
"boost:/libs/signals2/example/passing_slots.cpp">passing_slots.cpp
</ulink>.
99 <section id=
"signals2.examples.tutorial.extended_slot">
100 <title>extended_slot
</title>
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.
107 Download
<ulink url=
"boost:/libs/signals2/example/extended_slot.cpp">extended_slot.cpp
</ulink>.
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>
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
122 Download
<ulink url=
"boost:/libs/signals2/example/doc_view.cpp">doc_view.cpp
</ulink>.
125 <section id=
"signals2.examples.document-view.doc_view_acm">
126 <title>doc_view_acm
</title>
128 This program modifies the original doc_view.cpp example to employ
129 automatic connection management.
132 Download
<ulink url=
"boost:/libs/signals2/example/doc_view_acm.cpp">doc_view_acm.cpp
</ulink>.
135 <section id=
"signals2.examples.document-view.doc_view_acm_deconstruct">
136 <title>doc_view_acm_deconstruct
</title>
138 This program modifies the doc_view_acm.cpp example to use postconstructors
139 and the
<functionname>deconstruct()
</functionname> factory function.
142 Download
<ulink url=
"boost:/libs/signals2/example/doc_view_acm_deconstruct.cpp">doc_view_acm_deconstruct.cpp
</ulink>.
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>
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.
155 Download
<ulink url=
"boost:/libs/signals2/example/postconstructor_ex1.cpp">postconstructor_ex1
</ulink>.
158 <section id=
"signals2.examples.deconstruct.postconstructor_ex2">
159 <title>postconstructor_ex2
</title>
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
166 Download
<ulink url=
"boost:/libs/signals2/example/postconstructor_ex2.cpp">postconstructor_ex2
</ulink>.
169 <section id=
"signals2.examples.deconstruct.predestructor_example">
170 <title>predestructor_example
</title>
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.
176 Download
<ulink url=
"boost:/libs/signals2/example/predestructor_example.cpp">predestructor_example
</ulink>.