Chris@16
|
1 // Boost.Signals2 library
|
Chris@16
|
2
|
Chris@16
|
3 // Copyright Frank Mori Hess 2007-2009.
|
Chris@16
|
4 // Copyright Timmo Stange 2007.
|
Chris@16
|
5 // Copyright Douglas Gregor 2001-2004. Use, modification and
|
Chris@16
|
6 // distribution is subject to the Boost Software License, Version
|
Chris@16
|
7 // 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
Chris@16
|
8 // http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
9
|
Chris@16
|
10 // For more information, see http://www.boost.org
|
Chris@16
|
11
|
Chris@16
|
12 #ifndef BOOST_SIGNALS2_PREPROCESSED_SLOT_HPP
|
Chris@16
|
13 #define BOOST_SIGNALS2_PREPROCESSED_SLOT_HPP
|
Chris@16
|
14
|
Chris@16
|
15 #include <boost/preprocessor/repetition.hpp>
|
Chris@16
|
16 #include <boost/signals2/detail/preprocessed_arg_type.hpp>
|
Chris@16
|
17 #include <boost/type_traits/function_traits.hpp>
|
Chris@16
|
18
|
Chris@16
|
19 #ifndef BOOST_SIGNALS2_SLOT_MAX_BINDING_ARGS
|
Chris@16
|
20 #define BOOST_SIGNALS2_SLOT_MAX_BINDING_ARGS 10
|
Chris@16
|
21 #endif
|
Chris@16
|
22
|
Chris@16
|
23
|
Chris@16
|
24 // template<typename Func, typename BindArgT0, typename BindArgT1, ..., typename BindArgTN-1> slotN(...
|
Chris@16
|
25 #define BOOST_SIGNALS2_SLOT_N_BINDING_CONSTRUCTOR(z, n, data) \
|
Chris@16
|
26 template<typename Func, BOOST_SIGNALS2_PREFIXED_ARGS_TEMPLATE_DECL(n, BindArg)> \
|
Chris@16
|
27 BOOST_SIGNALS2_SLOT_CLASS_NAME(BOOST_SIGNALS2_NUM_ARGS)( \
|
Chris@16
|
28 const Func &func, BOOST_SIGNALS2_PREFIXED_FULL_REF_ARGS(n, const BindArg)) \
|
Chris@16
|
29 { \
|
Chris@16
|
30 init_slot_function(boost::bind(func, BOOST_SIGNALS2_SIGNATURE_ARG_NAMES(n))); \
|
Chris@16
|
31 }
|
Chris@16
|
32 #define BOOST_SIGNALS2_SLOT_N_BINDING_CONSTRUCTORS \
|
Chris@16
|
33 BOOST_PP_REPEAT_FROM_TO(1, BOOST_SIGNALS2_SLOT_MAX_BINDING_ARGS, BOOST_SIGNALS2_SLOT_N_BINDING_CONSTRUCTOR, ~)
|
Chris@16
|
34
|
Chris@16
|
35
|
Chris@16
|
36 #define BOOST_PP_ITERATION_LIMITS (0, BOOST_PP_INC(BOOST_SIGNALS2_MAX_ARGS))
|
Chris@16
|
37 #define BOOST_PP_FILENAME_1 <boost/signals2/detail/slot_template.hpp>
|
Chris@16
|
38 #include BOOST_PP_ITERATE()
|
Chris@16
|
39
|
Chris@16
|
40 #undef BOOST_SIGNALS2_SLOT_N_BINDING_CONSTRUCTOR
|
Chris@16
|
41 #undef BOOST_SIGNALS2_SLOT_N_BINDING_CONSTRUCTORS
|
Chris@16
|
42
|
Chris@16
|
43 namespace boost
|
Chris@16
|
44 {
|
Chris@16
|
45 namespace signals2
|
Chris@16
|
46 {
|
Chris@16
|
47 template<typename Signature,
|
Chris@16
|
48 typename SlotFunction = boost::function<Signature> >
|
Chris@16
|
49 class slot: public detail::slotN<function_traits<Signature>::arity,
|
Chris@16
|
50 Signature, SlotFunction>::type
|
Chris@16
|
51 {
|
Chris@16
|
52 private:
|
Chris@16
|
53 typedef typename detail::slotN<boost::function_traits<Signature>::arity,
|
Chris@16
|
54 Signature, SlotFunction>::type base_type;
|
Chris@16
|
55 public:
|
Chris@16
|
56 template<typename F>
|
Chris@16
|
57 slot(const F& f): base_type(f)
|
Chris@16
|
58 {}
|
Chris@16
|
59 // bind syntactic sugar
|
Chris@16
|
60 // template<typename F, typename BindArgT0, typename BindArgT1, ..., typename BindArgTn-1> slot(...
|
Chris@16
|
61 #define BOOST_SIGNALS2_SLOT_BINDING_CONSTRUCTOR(z, n, data) \
|
Chris@16
|
62 template<typename Func, BOOST_SIGNALS2_PREFIXED_ARGS_TEMPLATE_DECL(n, BindArg)> \
|
Chris@16
|
63 slot(const Func &func, BOOST_SIGNALS2_PREFIXED_FULL_REF_ARGS(n, const BindArg)): \
|
Chris@16
|
64 base_type(func, BOOST_SIGNALS2_SIGNATURE_ARG_NAMES(n)) \
|
Chris@16
|
65 {}
|
Chris@16
|
66 BOOST_PP_REPEAT_FROM_TO(1, BOOST_SIGNALS2_SLOT_MAX_BINDING_ARGS, BOOST_SIGNALS2_SLOT_BINDING_CONSTRUCTOR, ~)
|
Chris@16
|
67 #undef BOOST_SIGNALS2_SLOT_BINDING_CONSTRUCTOR
|
Chris@16
|
68 };
|
Chris@16
|
69 } // namespace signals2
|
Chris@16
|
70 }
|
Chris@16
|
71
|
Chris@16
|
72 #endif // BOOST_SIGNALS2_PREPROCESSED_SLOT_HPP
|