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