1// Boost.Signals library
2
3// Copyright Douglas Gregor 2001-2006. Use, modification and
4// distribution is subject to the Boost Software License, Version
5// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
6// http://www.boost.org/LICENSE_1_0.txt)
7
8// For more information, see http://www.boost.org/libs/signals
9
10#ifndef BOOST_SIGNAL_HPP
11#define BOOST_SIGNAL_HPP
12
13#ifndef BOOST_SIGNALS_NO_DEPRECATION_WARNING
14# if defined(_MSC_VER) || defined(__BORLANDC__) || defined(__DMC__)
15# pragma message ("Warning: Boost.Signals is no longer being maintained and is now deprecated. Please switch to Boost.Signals2. To disable this warning message, define BOOST_SIGNALS_NO_DEPRECATION_WARNING.")
16# elif defined(__GNUC__) || defined(__HP_aCC) || defined(__SUNPRO_CC) || defined(__IBMCPP__)
17# warning "Boost.Signals is no longer being maintained and is now deprecated. Please switch to Boost.Signals2. To disable this warning message, define BOOST_SIGNALS_NO_DEPRECATION_WARNING."
18# endif
19#endif
20
21#ifndef BOOST_SIGNALS_MAX_ARGS
22# define BOOST_SIGNALS_MAX_ARGS 10
23#endif
24
25#include <boost/config.hpp>
26#include <boost/type_traits/function_traits.hpp>
27#include <boost/signals/signal0.hpp>
28#include <boost/signals/signal1.hpp>
29#include <boost/signals/signal2.hpp>
30#include <boost/signals/signal3.hpp>
31#include <boost/signals/signal4.hpp>
32#include <boost/signals/signal5.hpp>
33#include <boost/signals/signal6.hpp>
34#include <boost/signals/signal7.hpp>
35#include <boost/signals/signal8.hpp>
36#include <boost/signals/signal9.hpp>
37#include <boost/signals/signal10.hpp>
38#include <boost/function.hpp>
39
40#ifdef BOOST_HAS_ABI_HEADERS
41# include BOOST_ABI_PREFIX
42#endif
43
44namespace boost {
45#ifndef BOOST_FUNCTION_NO_FUNCTION_TYPE_SYNTAX
46 namespace BOOST_SIGNALS_NAMESPACE {
47 namespace detail {
48 template<int Arity,
49 typename Signature,
50 typename Combiner,
51 typename Group,
52 typename GroupCompare,
53 typename SlotFunction>
54 class real_get_signal_impl;
55
56 template<typename Signature,
57 typename Combiner,
58 typename Group,
59 typename GroupCompare,
60 typename SlotFunction>
61 class real_get_signal_impl<0, Signature, Combiner, Group, GroupCompare,
62 SlotFunction>
63 {
64 typedef function_traits<Signature> traits;
65
66 public:
67 typedef signal0<typename traits::result_type,
68 Combiner,
69 Group,
70 GroupCompare,
71 SlotFunction> type;
72 };
73
74 template<typename Signature,
75 typename Combiner,
76 typename Group,
77 typename GroupCompare,
78 typename SlotFunction>
79 class real_get_signal_impl<1, Signature, Combiner, Group, GroupCompare,
80 SlotFunction>
81 {
82 typedef function_traits<Signature> traits;
83
84 public:
85 typedef signal1<typename traits::result_type,
86 typename traits::arg1_type,
87 Combiner,
88 Group,
89 GroupCompare,
90 SlotFunction> type;
91 };
92
93 template<typename Signature,
94 typename Combiner,
95 typename Group,
96 typename GroupCompare,
97 typename SlotFunction>
98 class real_get_signal_impl<2, Signature, Combiner, Group, GroupCompare,
99 SlotFunction>
100 {
101 typedef function_traits<Signature> traits;
102
103 public:
104 typedef signal2<typename traits::result_type,
105 typename traits::arg1_type,
106 typename traits::arg2_type,
107 Combiner,
108 Group,
109 GroupCompare,
110 SlotFunction> type;
111 };
112
113 template<typename Signature,
114 typename Combiner,
115 typename Group,
116 typename GroupCompare,
117 typename SlotFunction>
118 class real_get_signal_impl<3, Signature, Combiner, Group, GroupCompare,
119 SlotFunction>
120 {
121 typedef function_traits<Signature> traits;
122
123 public:
124 typedef signal3<typename traits::result_type,
125 typename traits::arg1_type,
126 typename traits::arg2_type,
127 typename traits::arg3_type,
128 Combiner,
129 Group,
130 GroupCompare,
131 SlotFunction> type;
132 };
133
134 template<typename Signature,
135 typename Combiner,
136 typename Group,
137 typename GroupCompare,
138 typename SlotFunction>
139 class real_get_signal_impl<4, Signature, Combiner, Group, GroupCompare,
140 SlotFunction>
141 {
142 typedef function_traits<Signature> traits;
143
144 public:
145 typedef signal4<typename traits::result_type,
146 typename traits::arg1_type,
147 typename traits::arg2_type,
148 typename traits::arg3_type,
149 typename traits::arg4_type,
150 Combiner,
151 Group,
152 GroupCompare,
153 SlotFunction> type;
154 };
155
156 template<typename Signature,
157 typename Combiner,
158 typename Group,
159 typename GroupCompare,
160 typename SlotFunction>
161 class real_get_signal_impl<5, Signature, Combiner, Group, GroupCompare,
162 SlotFunction>
163 {
164 typedef function_traits<Signature> traits;
165
166 public:
167 typedef signal5<typename traits::result_type,
168 typename traits::arg1_type,
169 typename traits::arg2_type,
170 typename traits::arg3_type,
171 typename traits::arg4_type,
172 typename traits::arg5_type,
173 Combiner,
174 Group,
175 GroupCompare,
176 SlotFunction> type;
177 };
178
179 template<typename Signature,
180 typename Combiner,
181 typename Group,
182 typename GroupCompare,
183 typename SlotFunction>
184 class real_get_signal_impl<6, Signature, Combiner, Group, GroupCompare,
185 SlotFunction>
186 {
187 typedef function_traits<Signature> traits;
188
189 public:
190 typedef signal6<typename traits::result_type,
191 typename traits::arg1_type,
192 typename traits::arg2_type,
193 typename traits::arg3_type,
194 typename traits::arg4_type,
195 typename traits::arg5_type,
196 typename traits::arg6_type,
197 Combiner,
198 Group,
199 GroupCompare,
200 SlotFunction> type;
201 };
202
203 template<typename Signature,
204 typename Combiner,
205 typename Group,
206 typename GroupCompare,
207 typename SlotFunction>
208 class real_get_signal_impl<7, Signature, Combiner, Group, GroupCompare,
209 SlotFunction>
210 {
211 typedef function_traits<Signature> traits;
212
213 public:
214 typedef signal7<typename traits::result_type,
215 typename traits::arg1_type,
216 typename traits::arg2_type,
217 typename traits::arg3_type,
218 typename traits::arg4_type,
219 typename traits::arg5_type,
220 typename traits::arg6_type,
221 typename traits::arg7_type,
222 Combiner,
223 Group,
224 GroupCompare,
225 SlotFunction> type;
226 };
227
228 template<typename Signature,
229 typename Combiner,
230 typename Group,
231 typename GroupCompare,
232 typename SlotFunction>
233 class real_get_signal_impl<8, Signature, Combiner, Group, GroupCompare,
234 SlotFunction>
235 {
236 typedef function_traits<Signature> traits;
237
238 public:
239 typedef signal8<typename traits::result_type,
240 typename traits::arg1_type,
241 typename traits::arg2_type,
242 typename traits::arg3_type,
243 typename traits::arg4_type,
244 typename traits::arg5_type,
245 typename traits::arg6_type,
246 typename traits::arg7_type,
247 typename traits::arg8_type,
248 Combiner,
249 Group,
250 GroupCompare,
251 SlotFunction> type;
252 };
253
254 template<typename Signature,
255 typename Combiner,
256 typename Group,
257 typename GroupCompare,
258 typename SlotFunction>
259 class real_get_signal_impl<9, Signature, Combiner, Group, GroupCompare,
260 SlotFunction>
261 {
262 typedef function_traits<Signature> traits;
263
264 public:
265 typedef signal9<typename traits::result_type,
266 typename traits::arg1_type,
267 typename traits::arg2_type,
268 typename traits::arg3_type,
269 typename traits::arg4_type,
270 typename traits::arg5_type,
271 typename traits::arg6_type,
272 typename traits::arg7_type,
273 typename traits::arg8_type,
274 typename traits::arg9_type,
275 Combiner,
276 Group,
277 GroupCompare,
278 SlotFunction> type;
279 };
280
281 template<typename Signature,
282 typename Combiner,
283 typename Group,
284 typename GroupCompare,
285 typename SlotFunction>
286 class real_get_signal_impl<10, Signature, Combiner, Group, GroupCompare,
287 SlotFunction>
288 {
289 typedef function_traits<Signature> traits;
290
291 public:
292 typedef signal10<typename traits::result_type,
293 typename traits::arg1_type,
294 typename traits::arg2_type,
295 typename traits::arg3_type,
296 typename traits::arg4_type,
297 typename traits::arg5_type,
298 typename traits::arg6_type,
299 typename traits::arg7_type,
300 typename traits::arg8_type,
301 typename traits::arg9_type,
302 typename traits::arg10_type,
303 Combiner,
304 Group,
305 GroupCompare,
306 SlotFunction> type;
307 };
308
309 template<typename Signature,
310 typename Combiner,
311 typename Group,
312 typename GroupCompare,
313 typename SlotFunction>
314 struct get_signal_impl :
315 public real_get_signal_impl<(function_traits<Signature>::arity),
316 Signature,
317 Combiner,
318 Group,
319 GroupCompare,
320 SlotFunction>
321 {
322 };
323
324 } // end namespace detail
325 } // end namespace BOOST_SIGNALS_NAMESPACE
326
327 // Very lightweight wrapper around the signalN classes that allows signals to
328 // be created where the number of arguments does not need to be part of the
329 // class name.
330 template<
331 typename Signature, // function type R (T1, T2, ..., TN)
332 typename Combiner = last_value<typename function_traits<Signature>::result_type>,
333 typename Group = int,
334 typename GroupCompare = std::less<Group>,
335 typename SlotFunction = function<Signature>
336 >
337 class signal :
338 public BOOST_SIGNALS_NAMESPACE::detail::get_signal_impl<Signature,
339 Combiner,
340 Group,
341 GroupCompare,
342 SlotFunction>::type
343 {
344 typedef typename BOOST_SIGNALS_NAMESPACE::detail::get_signal_impl<
345 Signature,
346 Combiner,
347 Group,
348 GroupCompare,
349 SlotFunction>::type base_type;
350
351 public:
352 explicit signal(const Combiner& combiner = Combiner(),
353 const GroupCompare& group_compare = GroupCompare()) :
354 base_type(combiner, group_compare)
355 {
356 }
357 };
358#endif // ndef BOOST_FUNCTION_NO_FUNCTION_TYPE_SYNTAX
359
360} // end namespace boost
361
362#ifdef BOOST_HAS_ABI_HEADERS
363# include BOOST_ABI_SUFFIX
364#endif
365
366#endif // BOOST_SIGNAL_HPP
367

source code of boost/boost/signal.hpp