1 | /* |
2 | A meta function which supports using named template type parameters |
3 | via Boost.Parameter to specify the template type parameters for |
4 | the boost::signals2::signal class. |
5 | |
6 | Author: Frank Mori Hess <fmhess@users.sourceforge.net> |
7 | Begin: 2009-01-22 |
8 | */ |
9 | // Copyright Frank Mori Hess 2009 |
10 | // Use, modification and |
11 | // distribution is subject to the Boost Software License, Version |
12 | // 1.0. (See accompanying file LICENSE_1_0.txt or copy at |
13 | // http://www.boost.org/LICENSE_1_0.txt) |
14 | |
15 | // For more information, see http://www.boost.org |
16 | |
17 | #ifndef BOOST_SIGNALS2_SIGNAL_TYPE_HPP |
18 | #define BOOST_SIGNALS2_SIGNAL_TYPE_HPP |
19 | |
20 | #include <boost/parameter/config.hpp> |
21 | |
22 | #if BOOST_PARAMETER_MAX_ARITY < 7 |
23 | #error Define BOOST_PARAMETER_MAX_ARITY as 7 or greater. |
24 | #endif |
25 | |
26 | #include <boost/parameter/template_keyword.hpp> |
27 | #include <boost/parameter/parameters.hpp> |
28 | #include <boost/parameter/required.hpp> |
29 | #include <boost/parameter/optional.hpp> |
30 | #include <boost/parameter/value_type.hpp> |
31 | #include <boost/type_traits/is_function.hpp> |
32 | #include <boost/type_traits/function_traits.hpp> |
33 | #include <boost/signals2/signal.hpp> |
34 | #include <functional> |
35 | |
36 | namespace boost |
37 | { |
38 | namespace signals2 |
39 | { |
40 | namespace keywords |
41 | { |
42 | BOOST_PARAMETER_TEMPLATE_KEYWORD(signature_type) |
43 | BOOST_PARAMETER_TEMPLATE_KEYWORD(combiner_type) |
44 | BOOST_PARAMETER_TEMPLATE_KEYWORD(group_type) |
45 | BOOST_PARAMETER_TEMPLATE_KEYWORD(group_compare_type) |
46 | BOOST_PARAMETER_TEMPLATE_KEYWORD(slot_function_type) |
47 | BOOST_PARAMETER_TEMPLATE_KEYWORD(extended_slot_function_type) |
48 | BOOST_PARAMETER_TEMPLATE_KEYWORD(mutex_type) |
49 | } // namespace keywords |
50 | |
51 | template < |
52 | typename A0, |
53 | typename A1 = parameter::void_, |
54 | typename A2 = parameter::void_, |
55 | typename A3 = parameter::void_, |
56 | typename A4 = parameter::void_, |
57 | typename A5 = parameter::void_, |
58 | typename A6 = parameter::void_ |
59 | > |
60 | class signal_type |
61 | { |
62 | typedef parameter::parameters< |
63 | parameter::required<keywords::tag::signature_type, is_function<boost::mpl::_> >, |
64 | parameter::optional<keywords::tag::combiner_type>, |
65 | parameter::optional<keywords::tag::group_type>, |
66 | parameter::optional<keywords::tag::group_compare_type>, |
67 | parameter::optional<keywords::tag::slot_function_type>, |
68 | parameter::optional<keywords::tag::extended_slot_function_type>, |
69 | parameter::optional<keywords::tag::mutex_type> |
70 | > parameter_spec; |
71 | |
72 | public: |
73 | // ArgumentPack |
74 | typedef typename parameter_spec::bind<A0, A1, A2, A3, A4, A5, A6>::type |
75 | args; |
76 | |
77 | typedef typename parameter::value_type<args, keywords::tag::signature_type>::type |
78 | signature_type; |
79 | |
80 | typedef typename parameter::value_type |
81 | < |
82 | args, |
83 | keywords::tag::combiner_type, |
84 | optional_last_value |
85 | < |
86 | typename boost::function_traits<signature_type>::result_type |
87 | > |
88 | >::type combiner_type; |
89 | |
90 | typedef typename |
91 | parameter::value_type<args, keywords::tag::group_type, int>::type group_type; |
92 | |
93 | typedef typename |
94 | parameter::value_type<args, keywords::tag::group_compare_type, std::less<group_type> >::type |
95 | group_compare_type; |
96 | |
97 | typedef typename |
98 | parameter::value_type<args, keywords::tag::slot_function_type, function<signature_type> >::type |
99 | slot_function_type; |
100 | |
101 | typedef typename |
102 | parameter::value_type |
103 | < |
104 | args, |
105 | keywords::tag::extended_slot_function_type, |
106 | typename detail::extended_signature<function_traits<signature_type>::arity, signature_type>::function_type |
107 | >::type |
108 | extended_slot_function_type; |
109 | |
110 | typedef typename |
111 | parameter::value_type<args, keywords::tag::mutex_type, mutex>::type mutex_type; |
112 | |
113 | typedef signal |
114 | < |
115 | signature_type, |
116 | combiner_type, |
117 | group_type, |
118 | group_compare_type, |
119 | slot_function_type, |
120 | extended_slot_function_type, |
121 | mutex_type |
122 | > type; |
123 | }; |
124 | } // namespace signals2 |
125 | } // namespace boost |
126 | |
127 | #endif // BOOST_SIGNALS2_SIGNAL_TYPE_HPP |
128 | |