1 // Boost.Signals library
3 // Copyright (C) 2001 Doug Gregor (gregod@cs.rpi.edu)
5 // Permission to copy, use, sell and distribute this software is granted
6 // provided this copyright notice appears in all copies.
7 // Permission to modify the code and to distribute modified code is granted
8 // provided this copyright notice appears in all copies, and a notice
9 // that the code was modified is included with the copyright notice.
11 // This software is provided "as is" without express or implied warranty,
12 // and with no claim as to its suitability for any purpose.
14 // For more information, see http://www.boost.org
16 #ifndef BOOST_SIGNAL_HPP
17 #define BOOST_SIGNAL_HPP
19 #define BOOST_SIGNALS_MAX_ARGS 10
21 #include <boost/config.hpp>
22 #include <boost/signals/signal0.hpp>
23 #include <boost/signals/signal1.hpp>
24 #include <boost/signals/signal2.hpp>
25 #include <boost/signals/signal3.hpp>
26 #include <boost/signals/signal4.hpp>
27 #include <boost/signals/signal5.hpp>
28 #include <boost/signals/signal6.hpp>
29 #include <boost/signals/signal7.hpp>
30 #include <boost/signals/signal8.hpp>
31 #include <boost/signals/signal9.hpp>
32 #include <boost/signals/signal10.hpp>
35 namespace BOOST_SIGNALS_NAMESPACE {
37 // The unusable class is a placeholder for unused function arguments.
40 // value=1 if the given type is not "unused"
44 BOOST_STATIC_CONSTANT(int, value = 1);
47 // value=0 for unused types
49 struct count_if_used<unused>
51 BOOST_STATIC_CONSTANT(int, value = 0);
54 // Count the number of arguments (from the given set) which are not
55 // "unused" (therefore, count those arguments that are used).
56 template<typename T1, typename T2, typename T3, typename T4,
57 typename T5, typename T6, typename T7, typename T8,
58 typename T9, typename T10>
59 struct count_used_args
61 BOOST_STATIC_CONSTANT(int, value =
62 (count_if_used<T1>::value +
63 count_if_used<T2>::value +
64 count_if_used<T3>::value +
65 count_if_used<T4>::value +
66 count_if_used<T5>::value +
67 count_if_used<T6>::value +
68 count_if_used<T7>::value +
69 count_if_used<T8>::value +
70 count_if_used<T9>::value +
71 count_if_used<T10>::value));
74 // Choose the appropriate underlying implementation
75 template<int Args> struct real_get_signal_impl {};
78 struct real_get_signal_impl<0>
96 typedef signal0<R, Combiner> type;
101 struct real_get_signal_impl<1>
119 typedef signal1<R, T1, Combiner> type;
124 struct real_get_signal_impl<2>
142 typedef signal2<R, T1, T2, Combiner> type;
147 struct real_get_signal_impl<3>
165 typedef signal3<R, T1, T2, T3, Combiner> type;
170 struct real_get_signal_impl<4>
188 typedef signal4<R, T1, T2, T3, T4, Combiner> type;
193 struct real_get_signal_impl<5>
211 typedef signal5<R, T1, T2, T3, T4, T5, Combiner>
217 struct real_get_signal_impl<6>
235 typedef signal6<R, T1, T2, T3, T4, T5, T6, Combiner> type;
240 struct real_get_signal_impl<7>
258 typedef signal7<R, T1, T2, T3, T4, T5, T6, T7, Combiner> type;
263 struct real_get_signal_impl<8>
281 typedef signal8<R, T1, T2, T3, T4, T5, T6, T7, T8, Combiner> type;
286 struct real_get_signal_impl<9>
304 typedef signal9<R, T1, T2, T3, T4, T5, T6, T7, T8, T9, Combiner> type;
309 struct real_get_signal_impl<10>
327 typedef signal10<R, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10,
346 struct get_signal_impl
349 typedef real_get_signal_impl<
350 (::boost::BOOST_SIGNALS_NAMESPACE::detail::count_used_args<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>::value)> t1;
351 typedef typename t1::template params<R, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10,
354 typedef typename t2::type type;
356 } // end namespace detail
357 } // end namespace BOOST_SIGNALS_NAMESPACE
359 // Very lightweight wrapper around the signalN classes that allows signals to
360 // be created where the number of arguments does not need to be part of the
364 typename T1 = BOOST_SIGNALS_NAMESPACE::detail::unused,
365 typename T2 = BOOST_SIGNALS_NAMESPACE::detail::unused,
366 typename T3 = BOOST_SIGNALS_NAMESPACE::detail::unused,
367 typename T4 = BOOST_SIGNALS_NAMESPACE::detail::unused,
368 typename T5 = BOOST_SIGNALS_NAMESPACE::detail::unused,
369 typename T6 = BOOST_SIGNALS_NAMESPACE::detail::unused,
370 typename T7 = BOOST_SIGNALS_NAMESPACE::detail::unused,
371 typename T8 = BOOST_SIGNALS_NAMESPACE::detail::unused,
372 typename T9 = BOOST_SIGNALS_NAMESPACE::detail::unused,
373 typename T10 = BOOST_SIGNALS_NAMESPACE::detail::unused
376 public BOOST_SIGNALS_NAMESPACE::detail::get_signal_impl<R, T1, T2, T3, T4, T5, T6, T7,
377 T8, T9, T10, boost::last_value<R> >::type
380 template<typename Combiner>
383 typedef BOOST_SIGNALS_NAMESPACE::detail::get_signal_impl<R, T1, T2, T3, T4, T5,
384 T6, T7, T8, T9, T10, Combiner> t1;
386 typedef typename t1::type type;
389 } // end namespace boost
391 #endif // BOOST_SIGNAL_HPP