1 | <?xml version="1.0" encoding="utf-8"?> |
---|
2 | <!-- |
---|
3 | Copyright (c) 2002 Douglas Gregor <doug.gregor -at- gmail.com> |
---|
4 | |
---|
5 | Distributed under the Boost Software License, Version 1.0. |
---|
6 | (See accompanying file LICENSE_1_0.txt or copy at |
---|
7 | http://www.boost.org/LICENSE_1_0.txt) |
---|
8 | --> |
---|
9 | <!DOCTYPE header PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN" |
---|
10 | "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd"> |
---|
11 | <header name="boost/signal.hpp" last-revision="$Date: 2006/11/03 19:45:41 $"> |
---|
12 | <namespace name="boost"> |
---|
13 | <namespace name="signals"> |
---|
14 | <enum name="connect_position"> |
---|
15 | <enumvalue name="at_front"/> |
---|
16 | <enumvalue name="at_back"/> |
---|
17 | </enum> |
---|
18 | </namespace> |
---|
19 | <class name="signalN"> |
---|
20 | <template> |
---|
21 | <template-type-parameter name="R"/> |
---|
22 | <template-type-parameter name="T1"/> |
---|
23 | <template-type-parameter name="T2"/> |
---|
24 | <template-varargs/> |
---|
25 | <template-type-parameter name="TN"/> |
---|
26 | <template-type-parameter name="Combiner"> |
---|
27 | <default><classname>last_value</classname><R></default> |
---|
28 | </template-type-parameter> |
---|
29 | <template-type-parameter name="Group"> |
---|
30 | <default>int</default> |
---|
31 | </template-type-parameter> |
---|
32 | <template-type-parameter name="GroupCompare"> |
---|
33 | <default><classname>std::less</classname><Group></default> |
---|
34 | </template-type-parameter> |
---|
35 | <template-type-parameter name="SlotFunction"> |
---|
36 | <default><classname>functionN</classname><R, T1, T2, ..., TN></default> |
---|
37 | </template-type-parameter> |
---|
38 | </template> |
---|
39 | <inherit access="public"><classname>signals::trackable</classname></inherit> |
---|
40 | <inherit access="private"> |
---|
41 | <type><classname>noncopyable</classname></type> |
---|
42 | <purpose>Exposition only</purpose> |
---|
43 | </inherit> |
---|
44 | |
---|
45 | <purpose>Set of safe multicast callback types.</purpose> |
---|
46 | |
---|
47 | <description> |
---|
48 | <para>The class template <classname>signalN</classname> covers |
---|
49 | several related classes signal0, signal1, signal2, etc., |
---|
50 | where the number suffix describes the number of function |
---|
51 | parameters the signal and its connected slots will |
---|
52 | take. Instead of enumerating all classes, a single pattern |
---|
53 | <classname>signalN</classname> will be described, where N |
---|
54 | represents the number of function parameters.</para> |
---|
55 | </description> |
---|
56 | |
---|
57 | <typedef name="result_type"> |
---|
58 | <type>typename Combiner::result_type</type> |
---|
59 | </typedef> |
---|
60 | <typedef name="combiner_type"><type>Combiner</type></typedef> |
---|
61 | <typedef name="group_type"><type>Group</type></typedef> |
---|
62 | <typedef name="group_compare_type"><type>GroupCompare</type></typedef> |
---|
63 | <typedef name="slot_function_type"><type>SlotFunction</type></typedef> |
---|
64 | <typedef name="slot_type"> |
---|
65 | <type><classname>slot</classname><SlotFunction></type> |
---|
66 | </typedef> |
---|
67 | <typedef name="slot_result_type"> |
---|
68 | <type><emphasis>unspecified</emphasis></type> |
---|
69 | </typedef> |
---|
70 | <typedef name="slot_call_iterator"> |
---|
71 | <type><emphasis>unspecified</emphasis></type> |
---|
72 | </typedef> |
---|
73 | <typedef name="argument_type"> |
---|
74 | <type>T1</type> |
---|
75 | <purpose>If N == 1</purpose> |
---|
76 | </typedef> |
---|
77 | <typedef name="first_argument_type"> |
---|
78 | <type>T1</type> |
---|
79 | <purpose>If N == 2</purpose> |
---|
80 | </typedef> |
---|
81 | <typedef name="second_argument_type"> |
---|
82 | <type>T2</type> |
---|
83 | <purpose>If N == 2</purpose> |
---|
84 | </typedef> |
---|
85 | <typedef name="arg1_type"><type>T1</type></typedef> |
---|
86 | <typedef name="arg2_type"><type>T2</type></typedef> |
---|
87 | <typedef name="..."><type/></typedef> |
---|
88 | <typedef name="argN_type"><type>TN</type></typedef> |
---|
89 | |
---|
90 | <static-constant name="arity"> |
---|
91 | <type>int</type> |
---|
92 | <default>N</default> |
---|
93 | </static-constant> |
---|
94 | |
---|
95 | <constructor> |
---|
96 | <parameter name="combiner"> |
---|
97 | <paramtype>const combiner_type&</paramtype> |
---|
98 | <default>combiner_type()</default> |
---|
99 | </parameter> |
---|
100 | <parameter name="compare"> |
---|
101 | <paramtype>const group_compare_type&</paramtype> |
---|
102 | <default>group_compare_type()</default> |
---|
103 | </parameter> |
---|
104 | |
---|
105 | <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> |
---|
106 | |
---|
107 | <postconditions><simpara><computeroutput>this-><methodname>empty</methodname>()</computeroutput></simpara></postconditions> |
---|
108 | </constructor> |
---|
109 | |
---|
110 | <destructor> |
---|
111 | <effects><simpara>Disconnects all slots connected to <computeroutput>*this</computeroutput>.</simpara></effects> |
---|
112 | </destructor> |
---|
113 | |
---|
114 | <method-group name="connection management"> |
---|
115 | <overloaded-method name="connect"> |
---|
116 | <signature> |
---|
117 | <type><classname>signals::connection</classname></type> |
---|
118 | <parameter name="slot"> |
---|
119 | <paramtype>const slot_type&</paramtype> |
---|
120 | </parameter> |
---|
121 | <parameter name="at"> |
---|
122 | <paramtype>signals::connect_position</paramtype> |
---|
123 | <default>signals::at_back</default> |
---|
124 | </parameter> |
---|
125 | </signature> |
---|
126 | |
---|
127 | <signature> |
---|
128 | <type><classname>signals::connection</classname></type> |
---|
129 | <parameter name="group"> |
---|
130 | <paramtype>const group_type&</paramtype> |
---|
131 | </parameter> |
---|
132 | <parameter name="slot"> |
---|
133 | <paramtype>const slot_type&</paramtype> |
---|
134 | </parameter> |
---|
135 | <parameter name="at"> |
---|
136 | <paramtype>signals::connect_position</paramtype> |
---|
137 | <default>signals::at_back</default> |
---|
138 | </parameter> |
---|
139 | </signature> |
---|
140 | |
---|
141 | <effects><simpara>Connects the signal this to the incoming |
---|
142 | slot. If the slot is inactive, i.e., any of the trackable |
---|
143 | objects bound by the slot call have been destroyed, then the |
---|
144 | call to connect is a no-op. If the second version of |
---|
145 | <computeroutput>connect</computeroutput> is invoked, the |
---|
146 | slot is associated with the given group. The <code>at</code> |
---|
147 | parameter specifies where the slot should be connected: |
---|
148 | <code>at_front</code> indicates that the slot will be |
---|
149 | connected at the front of the list or group of slots and |
---|
150 | <code>at_back</code> indicates that the slot will be |
---|
151 | connected at the back of the list or group of |
---|
152 | slots.</simpara></effects> |
---|
153 | |
---|
154 | <returns><simpara>A |
---|
155 | <computeroutput><classname>signals::connection</classname></computeroutput> |
---|
156 | object that references the newly-created connection between |
---|
157 | the signal and the slot; if the slot is inactive, returns a |
---|
158 | disconnected connection.</simpara></returns> |
---|
159 | |
---|
160 | <throws><simpara>This routine meets the strong exception guarantee, |
---|
161 | where any exception thrown will cause the slot to not be |
---|
162 | connected to the signal.</simpara></throws> |
---|
163 | |
---|
164 | <complexity><simpara>Constant time when connecting a slot |
---|
165 | without a group name or logarithmic in the number of groups |
---|
166 | when connecting to a particular |
---|
167 | group.</simpara></complexity> |
---|
168 | |
---|
169 | <notes><simpara>It is unspecified whether connecting a slot while the |
---|
170 | signal is calling will result in the slot being called |
---|
171 | immediately.</simpara></notes> |
---|
172 | </overloaded-method> |
---|
173 | |
---|
174 | <overloaded-method name="disconnect"> |
---|
175 | <signature> |
---|
176 | <type>void</type> |
---|
177 | <parameter name="group"> |
---|
178 | <paramtype>const group_type&</paramtype> |
---|
179 | </parameter> |
---|
180 | </signature> |
---|
181 | <signature> |
---|
182 | <template> |
---|
183 | <template-type-parameter name="Slot"/> |
---|
184 | </template> |
---|
185 | <type>void</type> |
---|
186 | <parameter name="slot"> |
---|
187 | <paramtype>const Slot&</paramtype> |
---|
188 | </parameter> |
---|
189 | </signature> |
---|
190 | |
---|
191 | <effects><simpara>If the parameter is (convertible to) a |
---|
192 | group name, any slots in the given group are |
---|
193 | disconnected. Otherwise, any slots equal to the given slot |
---|
194 | are disconnected.</simpara></effects> |
---|
195 | |
---|
196 | <throws><simpara>Will not throw unless a user destructor or |
---|
197 | equality operator <code>==</code> throws. If either throws, |
---|
198 | not all slots may be disconnected.</simpara></throws> |
---|
199 | |
---|
200 | <complexity><simpara>If a group is given, O(lg g) + k where |
---|
201 | g is the number of groups in the signal and k is the |
---|
202 | number of slots in the group. Otherwise, linear in the |
---|
203 | number of slots connected to the |
---|
204 | signal.</simpara></complexity> |
---|
205 | </overloaded-method> |
---|
206 | |
---|
207 | <method name="disconnect_all_slots"> |
---|
208 | <type>void</type> |
---|
209 | <effects><simpara>Disconnects all slots connected to the signal.</simpara></effects> |
---|
210 | |
---|
211 | <postconditions><simpara><computeroutput>this-><methodname>empty</methodname>()</computeroutput>.</simpara></postconditions> |
---|
212 | |
---|
213 | <throws><simpara>If disconnecting a slot causes an exception to be |
---|
214 | thrown, not all slots may be disconnected.</simpara></throws> |
---|
215 | |
---|
216 | <complexity><simpara>Linear in the number of slots known to the |
---|
217 | signal.</simpara></complexity> |
---|
218 | |
---|
219 | <notes><simpara>May be called at any time within the lifetime of the |
---|
220 | signal, including during calls to the signal's slots.</simpara></notes> |
---|
221 | </method> |
---|
222 | |
---|
223 | <method name="empty" cv="const"> |
---|
224 | <type>bool</type> |
---|
225 | <returns><simpara><computeroutput>true</computeroutput> if no slots |
---|
226 | are connected to the signal, and |
---|
227 | <computeroutput>false</computeroutput> otherwise.</simpara></returns> |
---|
228 | |
---|
229 | <throws><simpara>Will not throw.</simpara></throws> |
---|
230 | |
---|
231 | <complexity><simpara>Linear in the number of slots known to the |
---|
232 | signal.</simpara></complexity> |
---|
233 | |
---|
234 | <rationale><simpara>Slots can disconnect at any point in time, |
---|
235 | including while those same slots are being invoked. It is |
---|
236 | therefore possible that the implementation must search |
---|
237 | through a list of disconnected slots to determine if any |
---|
238 | slots are still connected.</simpara></rationale> |
---|
239 | </method> |
---|
240 | |
---|
241 | <method name="num_slots" cv="const"> |
---|
242 | <type>std::size_t</type> |
---|
243 | <returns><simpara>The number of slots connected to the signal</simpara></returns> |
---|
244 | |
---|
245 | <throws><simpara>Will not throw.</simpara></throws> |
---|
246 | |
---|
247 | <complexity><simpara>Linear in the number of slots known to the |
---|
248 | signal.</simpara></complexity> |
---|
249 | |
---|
250 | <rationale><simpara>Slots can disconnect at any point in time, |
---|
251 | including while those same slots are being invoked. It is |
---|
252 | therefore possible that the implementation must search |
---|
253 | through a list of disconnected slots to determine how many |
---|
254 | slots are still connected.</simpara></rationale> |
---|
255 | </method> |
---|
256 | </method-group> |
---|
257 | |
---|
258 | <method-group name="invocation"> |
---|
259 | <overloaded-method name="operator()"> |
---|
260 | <signature> |
---|
261 | <type>result_type</type> |
---|
262 | <parameter name="a1"><paramtype>arg1_type</paramtype></parameter> |
---|
263 | <parameter name="a2"><paramtype>arg2_type</paramtype></parameter> |
---|
264 | <parameter><paramtype>...</paramtype></parameter> |
---|
265 | <parameter name="aN"><paramtype>argN_type</paramtype></parameter> |
---|
266 | </signature> |
---|
267 | |
---|
268 | <signature cv="const"> |
---|
269 | <type>result_type</type> |
---|
270 | <parameter name="a1"><paramtype>arg1_type</paramtype></parameter> |
---|
271 | <parameter name="a2"><paramtype>arg2_type</paramtype></parameter> |
---|
272 | <parameter><paramtype>...</paramtype></parameter> |
---|
273 | <parameter name="aN"><paramtype>argN_type</paramtype></parameter> |
---|
274 | </signature> |
---|
275 | |
---|
276 | <effects><simpara>Invokes the combiner with a |
---|
277 | <computeroutput>slot_call_iterator</computeroutput> range |
---|
278 | [first, last) corresponding to the sequence of calls to the |
---|
279 | slots connected to signal |
---|
280 | <computeroutput>*this</computeroutput>. Dereferencing an |
---|
281 | iterator in this range causes a slot call with the given set |
---|
282 | of parameters <computeroutput>(a1, a2, ..., |
---|
283 | aN)</computeroutput>, the result of which is returned from |
---|
284 | the iterator dereference operation.</simpara></effects> |
---|
285 | |
---|
286 | <returns><simpara>The result returned by the combiner.</simpara></returns> |
---|
287 | |
---|
288 | <throws><simpara>If an exception is thrown by a slot call, or if the |
---|
289 | combiner does not dereference any slot past some given slot, |
---|
290 | all slots after that slot in the internal list of connected |
---|
291 | slots will not be invoked.</simpara></throws> |
---|
292 | |
---|
293 | <notes><simpara>Only the slots associated with iterators that are |
---|
294 | actually dereferenced will be invoked. Multiple dereferences |
---|
295 | of the same iterator will not result in multiple slot |
---|
296 | invocations, because the return value of the slot will be |
---|
297 | cached.</simpara> |
---|
298 | |
---|
299 | <simpara>The <computeroutput>const</computeroutput> version of |
---|
300 | the function call operator will invoke the combiner as |
---|
301 | <computeroutput>const</computeroutput>, whereas the |
---|
302 | non-<computeroutput>const</computeroutput> version will |
---|
303 | invoke the combiner as |
---|
304 | non-<computeroutput>const</computeroutput>.</simpara> |
---|
305 | |
---|
306 | <simpara>Calling the function call operator may invoke undefined |
---|
307 | behavior if no slots are connected to the signal, depending |
---|
308 | on the combiner used. The default combiner is well-defined |
---|
309 | for zero slots when the return type is void but is undefined |
---|
310 | when the return type is any other type (because there is no |
---|
311 | way to synthesize a return value).</simpara></notes> |
---|
312 | </overloaded-method> |
---|
313 | </method-group> |
---|
314 | |
---|
315 | <method-group name="combiner access"> |
---|
316 | <overloaded-method name="combiner"> |
---|
317 | <signature> |
---|
318 | <type>combiner_type&</type> |
---|
319 | </signature> |
---|
320 | <signature cv="const"> |
---|
321 | <type>const combiner_type&</type> |
---|
322 | </signature> |
---|
323 | |
---|
324 | <returns><simpara>A reference to the stored combiner.</simpara></returns> |
---|
325 | <throws><simpara>Will not throw.</simpara></throws> |
---|
326 | </overloaded-method> |
---|
327 | </method-group> |
---|
328 | </class> |
---|
329 | |
---|
330 | <class name="signal"> |
---|
331 | <template> |
---|
332 | <template-type-parameter name="Signature"> |
---|
333 | <purpose>Function type R (T1, T2, ..., TN)</purpose> |
---|
334 | </template-type-parameter> |
---|
335 | <template-type-parameter name="Combiner"> |
---|
336 | <default><classname>last_value</classname><R></default> |
---|
337 | </template-type-parameter> |
---|
338 | <template-type-parameter name="Group"> |
---|
339 | <default>int</default> |
---|
340 | </template-type-parameter> |
---|
341 | <template-type-parameter name="GroupCompare"> |
---|
342 | <default><classname>std::less</classname><Group></default> |
---|
343 | </template-type-parameter> |
---|
344 | <template-type-parameter name="SlotFunction"> |
---|
345 | <default><classname>functionN</classname><Signature></default> |
---|
346 | </template-type-parameter> |
---|
347 | </template> |
---|
348 | |
---|
349 | <inherit access="public"><classname>signalN</classname><R, T1, T2, ..., TN, Combiner, Group, GroupCompare, SlotFunction></inherit> |
---|
350 | <purpose>Safe multicast callback.</purpose> |
---|
351 | |
---|
352 | <description> |
---|
353 | <para>Class template <classname>signal</classname> is a thin |
---|
354 | wrapper around the numbered class templates <classname |
---|
355 | alt="signalN">signal0</classname>, <classname |
---|
356 | alt="signalN">signal1</classname>, etc. It accepts a function |
---|
357 | type with N arguments instead of N separate arguments, and |
---|
358 | derives from the appropriate <classname>signalN</classname> |
---|
359 | instantiation.</para> |
---|
360 | |
---|
361 | <para>All functionality of this class template is in its base |
---|
362 | class <classname>signalN</classname>.</para> |
---|
363 | </description> |
---|
364 | |
---|
365 | <constructor> |
---|
366 | <parameter name="combiner"> |
---|
367 | <paramtype>const combiner_type&</paramtype> |
---|
368 | <default>combiner_type()</default> |
---|
369 | </parameter> |
---|
370 | <parameter name="compare"> |
---|
371 | <paramtype>const group_compare_type&</paramtype> |
---|
372 | <default>group_compare_type()</default> |
---|
373 | </parameter> |
---|
374 | |
---|
375 | <effects><simpara>Initializes the base class with the given combiner |
---|
376 | and comparison objects.</simpara></effects> |
---|
377 | </constructor> |
---|
378 | </class> |
---|
379 | </namespace> |
---|
380 | </header> |
---|