1 // Boost.Signals library
3 // Copyright Douglas Gregor 2001-2004.
4 // Copyright Frank Mori Hess 2007. Use, modification and
5 // distribution is subject to the Boost Software License, Version
6 // 1.0. (See accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt)
9 // For more information, see http://www.boost.org
11 #ifndef BOOST_SIGNALS2_SIGNALS_COMMON_HPP
12 #define BOOST_SIGNALS2_SIGNALS_COMMON_HPP
14 #include <boost/mpl/bool.hpp>
15 #include <boost/mpl/if.hpp>
16 #include <boost/ref.hpp>
17 #include <boost/signals2/signal_base.hpp>
18 #include <boost/type_traits/is_base_of.hpp>
23 // Determine if the given type T is a signal
25 class is_signal: public mpl::bool_<is_base_of<signal_base, T>::value>
28 // A slot can be a signal, a reference to a function object, or a
31 struct reference_tag {};
34 // Classify the given slot as a signal, a reference-to-slot, or a
38 typedef typename mpl::if_<is_signal<S>,
39 signal_tag, value_tag>::type signal_or_value;
41 typedef typename mpl::if_<is_reference_wrapper<S>,
43 signal_or_value>::type type;
46 // Get the slot so that it can be copied
48 typename F::weak_signal_type
49 get_invocable_slot(const F &signal, signal_tag)
50 { return typename F::weak_signal_type(signal); }
54 get_invocable_slot(const F& f, reference_tag)
59 get_invocable_slot(const F& f, value_tag)
62 // Determines the type of the slot - is it a signal, a reference to a
63 // slot or just a normal slot.
65 typename get_slot_tag<F>::type
68 typedef typename get_slot_tag<F>::type
70 the_tag_type tag = the_tag_type();
73 } // end namespace detail
74 } // end namespace signals2
75 } // end namespace boost
77 #endif // BOOST_SIGNALS2_SIGNALS_COMMON_HPP