1 <?xml version="1.0" encoding="utf-8"?>
2 <!DOCTYPE header PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
3 "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd">
4 <header name="boost/signal.hpp" last-revision="$Date$">
5 <namespace name="boost">
6 <namespace name="signals">
7 <enum name="connect_position">
8 <enumvalue name="at_front"/>
9 <enumvalue name="at_back"/>
12 <class name="signalN">
14 <template-type-parameter name="R"/>
15 <template-type-parameter name="T1"/>
16 <template-type-parameter name="T2"/>
18 <template-type-parameter name="TN"/>
19 <template-type-parameter name="Combiner">
20 <default><classname>last_value</classname><R></default>
21 </template-type-parameter>
22 <template-type-parameter name="Group">
23 <default>int</default>
24 </template-type-parameter>
25 <template-type-parameter name="GroupCompare">
26 <default><classname>std::less</classname><Group></default>
27 </template-type-parameter>
28 <template-type-parameter name="SlotFunction">
29 <default><classname>functionN</classname><R, T1, T2, ..., TN></default>
30 </template-type-parameter>
32 <inherit access="public"><classname>signals::trackable</classname></inherit>
33 <inherit access="private">
34 <type><classname>noncopyable</classname></type>
35 <purpose>Exposition only</purpose>
38 <purpose>Set of safe multicast callback types.</purpose>
41 <para>The class template <classname>signalN</classname> covers
42 several related classes signal0, signal1, signal2, etc.,
43 where the number suffix describes the number of function
44 parameters the signal and its connected slots will
45 take. Instead of enumerating all classes, a single pattern
46 <classname>signalN</classname> will be described, where N
47 represents the number of function parameters.</para>
50 <typedef name="result_type">
51 <type>typename Combiner::result_type</type>
53 <typedef name="combiner_type"><type>Combiner</type></typedef>
54 <typedef name="group_type"><type>Group</type></typedef>
55 <typedef name="group_compare_type"><type>GroupCompare</type></typedef>
56 <typedef name="slot_function_type"><type>SlotFunction</type></typedef>
57 <typedef name="slot_type">
58 <type><classname>slot</classname><SlotFunction></type>
60 <typedef name="slot_result_type">
61 <type><emphasis>unspecified</emphasis></type>
63 <typedef name="slot_call_iterator">
64 <type><emphasis>unspecified</emphasis></type>
66 <typedef name="argument_type">
68 <purpose>If N == 1</purpose>
70 <typedef name="first_argument_type">
72 <purpose>If N == 2</purpose>
74 <typedef name="second_argument_type">
76 <purpose>If N == 2</purpose>
78 <typedef name="arg1_type"><type>T1</type></typedef>
79 <typedef name="arg2_type"><type>T2</type></typedef>
80 <typedef name="..."><type/></typedef>
81 <typedef name="argN_type"><type>TN</type></typedef>
83 <static-constant name="arity">
89 <parameter name="combiner">
90 <paramtype>const combiner_type&</paramtype>
91 <default>combiner_type()</default>
93 <parameter name="compare">
94 <paramtype>const group_compare_type&</paramtype>
95 <default>group_compare_type()</default>
98 <effects><simpara>Initializes the signal to contain no slots, copies the given combiner into internal storage, and stores the given group comparison function object to compare groups.</simpara></effects>
100 <postconditions><simpara><computeroutput>this-><methodname>empty</methodname>()</computeroutput></simpara></postconditions>
104 <effects><simpara>Disconnects all slots connected to <computeroutput>*this</computeroutput>.</simpara></effects>
107 <method-group name="connection management">
108 <overloaded-method name="connect">
110 <type><classname>signals::connection</classname></type>
111 <parameter name="slot">
112 <paramtype>const slot_type&</paramtype>
114 <parameter name="at">
115 <paramtype>signals::connect_position</paramtype>
116 <default>signals::at_back</default>
121 <type><classname>signals::connection</classname></type>
122 <parameter name="group">
123 <paramtype>const group_type&</paramtype>
125 <parameter name="slot">
126 <paramtype>const slot_type&</paramtype>
128 <parameter name="at">
129 <paramtype>signals::connect_position</paramtype>
130 <default>signals::at_back</default>
134 <effects><simpara>Connects the signal this to the incoming
135 slot. If the slot is inactive, i.e., any of the trackable
136 objects bound by the slot call have been destroyed, then the
137 call to connect is a no-op. If the second version of
138 <computeroutput>connect</computeroutput> is invoked, the
139 slot is associated with the given group. The <code>at</code>
140 parameter specifies where the slot should be connected:
141 <code>at_front</code> indicates that the slot will be
142 connected at the front of the list or group of slots and
143 <code>at_back</code> indicates that the slot will be
144 connected at the back of the list or group of
145 slots.</simpara></effects>
148 <computeroutput><classname>signals::connection</classname></computeroutput>
149 object that references the newly-created connection between
150 the signal and the slot; if the slot is inactive, returns a
151 disconnected connection.</simpara></returns>
153 <throws><simpara>This routine meets the strong exception guarantee,
154 where any exception thrown will cause the slot to not be
155 connected to the signal.</simpara></throws>
157 <complexity><simpara>Constant time when connecting a slot
158 without a group name or logarithmic in the number of groups
159 when connecting to a particular
160 group.</simpara></complexity>
162 <notes><simpara>It is unspecified whether connecting a slot while the
163 signal is calling will result in the slot being called
164 immediately.</simpara></notes>
167 <overloaded-method name="disconnect">
170 <parameter name="group">
171 <paramtype>const group_type&</paramtype>
176 <template-type-parameter name="Slot"/>
179 <parameter name="slot">
180 <paramtype>const Slot&</paramtype>
184 <effects><simpara>If the parameter is (convertible to) a
185 group name, any slots in the given group are
186 disconnected. Otherwise, any slots equal to the given slot
187 are disconnected.</simpara></effects>
189 <throws><simpara>Will not throw unless a user destructor or
190 equality operator <code>==</code> throws. If either throws,
191 not all slots may be disconnected.</simpara></throws>
193 <complexity><simpara>If a group is given, O(lg g) + k where
194 g is the number of groups in the signal and k is the
195 number of slots in the group. Otherwise, linear in the
196 number of slots connected to the
197 signal.</simpara></complexity>
200 <method name="disconnect_all_slots">
202 <effects><simpara>Disconnects all slots connected to the signal.</simpara></effects>
204 <postconditions><simpara><computeroutput>this-><methodname>empty</methodname>()</computeroutput>.</simpara></postconditions>
206 <throws><simpara>If disconnecting a slot causes an exception to be
207 thrown, not all slots may be disconnected.</simpara></throws>
209 <complexity><simpara>Linear in the number of slots known to the
210 signal.</simpara></complexity>
212 <notes><simpara>May be called at any time within the lifetime of the
213 signal, including during calls to the signal's slots.</simpara></notes>
216 <method name="empty" cv="const">
218 <returns><simpara><computeroutput>true</computeroutput> if no slots
219 are connected to the signal, and
220 <computeroutput>false</computeroutput> otherwise.</simpara></returns>
222 <throws><simpara>Will not throw.</simpara></throws>
224 <complexity><simpara>Linear in the number of slots known to the
225 signal.</simpara></complexity>
227 <rationale><simpara>Slots can disconnect at any point in time,
228 including while those same slots are being invoked. It is
229 therefore possible that the implementation must search
230 through a list of disconnected slots to determine if any
231 slots are still connected.</simpara></rationale>
234 <method name="num_slots" cv="const">
235 <type>std::size_t</type>
236 <returns><simpara>The number of slots connected to the signal</simpara></returns>
238 <throws><simpara>Will not throw.</simpara></throws>
240 <complexity><simpara>Linear in the number of slots known to the
241 signal.</simpara></complexity>
243 <rationale><simpara>Slots can disconnect at any point in time,
244 including while those same slots are being invoked. It is
245 therefore possible that the implementation must search
246 through a list of disconnected slots to determine how many
247 slots are still connected.</simpara></rationale>
251 <method-group name="invocation">
252 <overloaded-method name="operator()">
254 <type>result_type</type>
255 <parameter name="a1"><paramtype>arg1_type</paramtype></parameter>
256 <parameter name="a2"><paramtype>arg2_type</paramtype></parameter>
257 <parameter><paramtype>...</paramtype></parameter>
258 <parameter name="aN"><paramtype>argN_type</paramtype></parameter>
261 <signature cv="const">
262 <type>result_type</type>
263 <parameter name="a1"><paramtype>arg1_type</paramtype></parameter>
264 <parameter name="a2"><paramtype>arg2_type</paramtype></parameter>
265 <parameter><paramtype>...</paramtype></parameter>
266 <parameter name="aN"><paramtype>argN_type</paramtype></parameter>
269 <effects><simpara>Invokes the combiner with a
270 <computeroutput>slot_call_iterator</computeroutput> range
271 [first, last) corresponding to the sequence of calls to the
272 slots connected to signal
273 <computeroutput>*this</computeroutput>. Dereferencing an
274 iterator in this range causes a slot call with the given set
275 of parameters <computeroutput>(a1, a2, ...,
276 aN)</computeroutput>, the result of which is returned from
277 the iterator dereference operation.</simpara></effects>
279 <returns><simpara>The result returned by the combiner.</simpara></returns>
281 <throws><simpara>If an exception is thrown by a slot call, or if the
282 combiner does not dereference any slot past some given slot,
283 all slots after that slot in the internal list of connected
284 slots will not be invoked.</simpara></throws>
286 <notes><simpara>Only the slots associated with iterators that are
287 actually dereferenced will be invoked. Multiple dereferences
288 of the same iterator will not result in multiple slot
289 invocations, because the return value of the slot will be
292 <simpara>The <computeroutput>const</computeroutput> version of
293 the function call operator will invoke the combiner as
294 <computeroutput>const</computeroutput>, whereas the
295 non-<computeroutput>const</computeroutput> version will
296 invoke the combiner as
297 non-<computeroutput>const</computeroutput>.</simpara>
299 <simpara>Calling the function call operator may invoke undefined
300 behavior if no slots are connected to the signal, depending
301 on the combiner used. The default combiner is well-defined
302 for zero slots when the return type is void but is undefined
303 when the return type is any other type (because there is no
304 way to synthesize a return value).</simpara></notes>
308 <method-group name="combiner access">
309 <overloaded-method name="combiner">
311 <type>combiner_type&</type>
313 <signature cv="const">
314 <type>const combiner_type&</type>
317 <returns><simpara>A reference to the stored combiner.</simpara></returns>
318 <throws><simpara>Will not throw.</simpara></throws>
323 <class name="signal">
325 <template-type-parameter name="Signature">
326 <purpose>Function type R (T1, T2, ..., TN)</purpose>
327 </template-type-parameter>
328 <template-type-parameter name="Combiner">
329 <default><classname>last_value</classname><R></default>
330 </template-type-parameter>
331 <template-type-parameter name="Group">
332 <default>int</default>
333 </template-type-parameter>
334 <template-type-parameter name="GroupCompare">
335 <default><classname>std::less</classname><Group></default>
336 </template-type-parameter>
337 <template-type-parameter name="SlotFunction">
338 <default><classname>functionN</classname><Signature></default>
339 </template-type-parameter>
342 <inherit access="public"><classname>signalN</classname><R, T1, T2, ..., TN, Combiner, Group, GroupCompare, SlotFunction></inherit>
343 <purpose>Safe multicast callback.</purpose>
346 <para>Class template <classname>signal</classname> is a thin
347 wrapper around the numbered class templates <classname
348 alt="signalN">signal0</classname>, <classname
349 alt="signalN">signal1</classname>, etc. It accepts a function
350 type with N arguments instead of N separate arguments, and
351 derives from the appropriate <classname>signalN</classname>
352 instantiation.</para>
354 <para>All functionality of this class template is in its base
355 class <classname>signalN</classname>.</para>
359 <parameter name="combiner">
360 <paramtype>const combiner_type&</paramtype>
361 <default>combiner_type()</default>
363 <parameter name="compare">
364 <paramtype>const group_compare_type&</paramtype>
365 <default>group_compare_type()</default>
368 <effects><simpara>Initializes the base class with the given combiner
369 and comparison objects.</simpara></effects>