Chris@16: // Boost.Signals library Chris@16: Chris@16: // Copyright Douglas Gregor 2001-2004. Chris@16: // Copyright Frank Mori Hess 2007. Use, modification and Chris@16: // distribution is subject to the Boost Software License, Version Chris@16: // 1.0. (See accompanying file LICENSE_1_0.txt or copy at Chris@16: // http://www.boost.org/LICENSE_1_0.txt) Chris@16: Chris@16: // For more information, see http://www.boost.org Chris@16: Chris@16: #ifndef BOOST_SIGNALS2_SIGNALS_COMMON_HPP Chris@16: #define BOOST_SIGNALS2_SIGNALS_COMMON_HPP Chris@16: Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: Chris@16: namespace boost { Chris@16: namespace signals2 { Chris@16: namespace detail { Chris@16: // Determine if the given type T is a signal Chris@16: template Chris@16: class is_signal: public mpl::bool_::value> Chris@16: {}; Chris@16: Chris@16: // A slot can be a signal, a reference to a function object, or a Chris@16: // function object. Chris@16: struct signal_tag {}; Chris@16: struct reference_tag {}; Chris@16: struct value_tag {}; Chris@16: Chris@16: // Classify the given slot as a signal, a reference-to-slot, or a Chris@16: // standard slot Chris@16: template Chris@16: class get_slot_tag { Chris@16: typedef typename mpl::if_, Chris@16: signal_tag, value_tag>::type signal_or_value; Chris@16: public: Chris@16: typedef typename mpl::if_, Chris@16: reference_tag, Chris@16: signal_or_value>::type type; Chris@16: }; Chris@16: Chris@16: // Get the slot so that it can be copied Chris@16: template Chris@16: typename F::weak_signal_type Chris@16: get_invocable_slot(const F &signal, signal_tag) Chris@16: { return typename F::weak_signal_type(signal); } Chris@16: Chris@16: template Chris@16: const F& Chris@16: get_invocable_slot(const F& f, reference_tag) Chris@16: { return f; } Chris@16: Chris@16: template Chris@16: const F& Chris@16: get_invocable_slot(const F& f, value_tag) Chris@16: { return f; } Chris@16: Chris@16: // Determines the type of the slot - is it a signal, a reference to a Chris@16: // slot or just a normal slot. Chris@16: template Chris@16: typename get_slot_tag::type Chris@16: tag_type(const F&) Chris@16: { Chris@16: typedef typename get_slot_tag::type Chris@16: the_tag_type; Chris@16: the_tag_type tag = the_tag_type(); Chris@16: return tag; Chris@16: } Chris@16: } // end namespace detail Chris@16: } // end namespace signals2 Chris@16: } // end namespace boost Chris@16: Chris@16: #endif // BOOST_SIGNALS2_SIGNALS_COMMON_HPP