Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:51:41

0001 // Boost.Signals library
0002 
0003 // Copyright Douglas Gregor 2001-2004.
0004 // Copyright Frank Mori Hess 2007. Use, modification and
0005 // distribution is subject to the Boost Software License, Version
0006 // 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0007 // http://www.boost.org/LICENSE_1_0.txt)
0008 
0009 // For more information, see http://www.boost.org
0010 
0011 #ifndef BOOST_SIGNALS2_SIGNALS_COMMON_HPP
0012 #define BOOST_SIGNALS2_SIGNALS_COMMON_HPP
0013 
0014 #include <boost/core/ref.hpp>
0015 #include <boost/mpl/bool.hpp>
0016 #include <boost/mpl/if.hpp>
0017 #include <boost/signals2/signal_base.hpp>
0018 #include <boost/type_traits/is_base_of.hpp>
0019 
0020 namespace boost {
0021   namespace signals2 {
0022     namespace detail {
0023       // Determine if the given type T is a signal
0024       template<typename T>
0025       class is_signal: public mpl::bool_<is_base_of<signal_base, T>::value>
0026       {};
0027 
0028       // A slot can be a signal, a reference to a function object, or a
0029       // function object.
0030       struct signal_tag {};
0031       struct reference_tag {};
0032       struct value_tag {};
0033 
0034       // Classify the given slot as a signal, a reference-to-slot, or a
0035       // standard slot
0036       template<typename S>
0037       class get_slot_tag {
0038         typedef typename mpl::if_<is_signal<S>,
0039           signal_tag, value_tag>::type signal_or_value;
0040       public:
0041         typedef typename mpl::if_<is_reference_wrapper<S>,
0042                             reference_tag,
0043                             signal_or_value>::type type;
0044       };
0045 
0046       // Get the slot so that it can be copied
0047       template<typename F>
0048       typename F::weak_signal_type
0049       get_invocable_slot(const F &signal, signal_tag)
0050       { return typename F::weak_signal_type(signal); }
0051 
0052       template<typename F>
0053       const F&
0054       get_invocable_slot(const F& f, reference_tag)
0055       { return f; }
0056 
0057       template<typename F>
0058       const F&
0059       get_invocable_slot(const F& f, value_tag)
0060       { return f; }
0061 
0062       // Determines the type of the slot - is it a signal, a reference to a
0063       // slot or just a normal slot.
0064       template<typename F>
0065       typename get_slot_tag<F>::type
0066       tag_type(const F&)
0067       {
0068         typedef typename get_slot_tag<F>::type
0069           the_tag_type;
0070         the_tag_type tag = the_tag_type();
0071         return tag;
0072       }
0073     } // end namespace detail
0074   } // end namespace signals2
0075 } // end namespace boost
0076 
0077 #endif // BOOST_SIGNALS2_SIGNALS_COMMON_HPP