Chris@16: // Boost.Signals library Chris@16: Chris@16: // Copyright Douglas Gregor 2001-2004. 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_SIGNALS_COMMON_HEADER Chris@16: #define BOOST_SIGNALS_COMMON_HEADER Chris@16: Chris@16: #ifndef BOOST_SIGNALS_NAMESPACE Chris@16: # define BOOST_SIGNALS_NAMESPACE signals Chris@16: #endif Chris@16: Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: Chris@16: #ifdef BOOST_HAS_ABI_HEADERS Chris@16: # include BOOST_ABI_PREFIX Chris@16: #endif Chris@16: Chris@16: namespace boost { Chris@16: namespace BOOST_SIGNALS_NAMESPACE { Chris@16: namespace detail { Chris@16: // The unusable class is a placeholder for unused function arguments Chris@16: // It is also completely unusable except that it constructable from Chris@16: // anything. This helps compilers without partial specialization Chris@16: // handle slots returning void. Chris@16: struct unusable { Chris@16: unusable() {} Chris@16: }; Chris@16: Chris@16: // Determine the result type of a slot call Chris@16: template Chris@16: struct slot_result_type { Chris@16: typedef R type; Chris@16: }; Chris@16: Chris@16: template<> Chris@16: struct slot_result_type { Chris@16: typedef unusable type; Chris@16: }; Chris@16: Chris@16: // Determine if the given type T is a signal Chris@16: class signal_base; Chris@16: Chris@16: template Chris@16: struct is_signal { Chris@16: BOOST_STATIC_CONSTANT(bool, Chris@16: value = (is_convertible::value)); Chris@16: }; Chris@16: Chris@16: /* Chris@16: * The IF implementation is temporary code. When a Boost metaprogramming Chris@16: * library is introduced, Boost.Signals will use it instead. Chris@16: */ Chris@16: namespace intimate { Chris@16: struct SelectThen Chris@16: { Chris@16: template Chris@16: struct Result Chris@16: { Chris@16: typedef Then type; Chris@16: }; Chris@16: }; Chris@16: Chris@16: struct SelectElse Chris@16: { Chris@16: template Chris@16: struct Result Chris@16: { Chris@16: typedef Else type; Chris@16: }; Chris@16: }; Chris@16: Chris@16: template Chris@16: struct Selector Chris@16: { Chris@16: typedef SelectThen type; Chris@16: }; Chris@16: Chris@16: template<> Chris@16: struct Selector Chris@16: { Chris@16: typedef SelectElse type; Chris@16: }; Chris@16: } // end namespace intimate Chris@16: Chris@16: template Chris@16: struct IF Chris@16: { Chris@16: typedef typename intimate::Selector::type select; Chris@16: typedef typename select::template Result::type type; Chris@16: }; Chris@16: Chris@16: // Determine if the incoming argument is a reference_wrapper Chris@16: template Chris@16: struct is_ref Chris@16: { Chris@16: BOOST_STATIC_CONSTANT(bool, value = false); Chris@16: }; Chris@16: Chris@16: template Chris@16: struct is_ref > Chris@16: { Chris@16: BOOST_STATIC_CONSTANT(bool, value = true); 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 IF<(is_signal::value), Chris@16: signal_tag, Chris@16: value_tag>::type signal_or_value; Chris@16: Chris@16: public: Chris@16: typedef typename IF<(is_ref::value), Chris@16: reference_tag, Chris@16: signal_or_value>::type type; Chris@16: }; Chris@16: Chris@16: // Forward declaration needed in lots of places Chris@16: class signal_base_impl; Chris@16: class bound_objects_visitor; Chris@16: class slot_base; Chris@16: } // end namespace detail Chris@16: } // end namespace BOOST_SIGNALS_NAMESPACE Chris@16: } // end namespace boost Chris@16: Chris@16: #ifdef BOOST_HAS_ABI_HEADERS Chris@16: # include BOOST_ABI_SUFFIX Chris@16: #endif Chris@16: Chris@16: #endif // BOOST_SIGNALS_COMMON_HEADER