PageRenderTime 43ms CodeModel.GetById 18ms app.highlight 21ms RepoModel.GetById 1ms app.codeStats 0ms

/Src/Dependencies/Boost/boost/signals2/signal_type.hpp

http://hadesmem.googlecode.com/
C++ Header | 144 lines | 109 code | 18 blank | 17 comment | 0 complexity | f89bbc178b11d431b01a69373a4bcc94 MD5 | raw file
  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// support for function types is currently broken in Boost.Parameter
 21// #define BOOST_SIGNALS2_NAMED_SIGNATURE_PARAMETER
 22
 23#include <boost/signals2/signal.hpp>
 24
 25#if !defined(BOOST_PARAMETER_MAX_ARITY)
 26#define BOOST_PARAMETER_MAX_ARITY 7
 27#else
 28#if BOOST_PARAMETER_MAX_ARITY < 7
 29#error This header requires BOOST_PARAMETER_MAX_ARITY to be defined as 7 or greater prior to including Boost.Parameter headers
 30#endif // BOOST_PARAMETER_MAX_ARITY < 7
 31#endif // !defined(BOOST_PARAMETER_MAX_ARITY)
 32#include <boost/parameter.hpp>
 33
 34#include <boost/type_traits/is_function.hpp>
 35
 36namespace boost
 37{
 38  namespace signals2
 39  {
 40    namespace keywords
 41    {
 42#ifdef BOOST_SIGNALS2_NAMED_SIGNATURE_PARAMETER
 43      BOOST_PARAMETER_TEMPLATE_KEYWORD(signature_type)
 44#endif
 45      BOOST_PARAMETER_TEMPLATE_KEYWORD(combiner_type)
 46      BOOST_PARAMETER_TEMPLATE_KEYWORD(group_type)
 47      BOOST_PARAMETER_TEMPLATE_KEYWORD(group_compare_type)
 48      BOOST_PARAMETER_TEMPLATE_KEYWORD(slot_function_type)
 49      BOOST_PARAMETER_TEMPLATE_KEYWORD(extended_slot_function_type)
 50      BOOST_PARAMETER_TEMPLATE_KEYWORD(mutex_type)
 51    } // namespace keywords
 52
 53    template <
 54#ifdef BOOST_SIGNALS2_NAMED_SIGNATURE_PARAMETER
 55        typename A0,
 56#else
 57        typename Signature,
 58#endif
 59        typename A1 = parameter::void_,
 60        typename A2 = parameter::void_,
 61        typename A3 = parameter::void_,
 62        typename A4 = parameter::void_,
 63        typename A5 = parameter::void_,
 64        typename A6 = parameter::void_
 65      >
 66    class signal_type
 67    {
 68      typedef parameter::parameters<
 69#ifdef BOOST_SIGNALS2_NAMED_SIGNATURE_PARAMETER
 70          parameter::required<keywords::tag::signature_type, is_function<boost::mpl::_> >,
 71#endif
 72          parameter::optional<keywords::tag::combiner_type>,
 73          parameter::optional<keywords::tag::group_type>,
 74          parameter::optional<keywords::tag::group_compare_type>,
 75          parameter::optional<keywords::tag::slot_function_type>,
 76          parameter::optional<keywords::tag::extended_slot_function_type>,
 77          parameter::optional<keywords::tag::mutex_type>
 78        > parameter_spec;
 79
 80    public:
 81      // ArgumentPack
 82      typedef typename
 83        parameter_spec::bind<
 84#ifdef BOOST_SIGNALS2_NAMED_SIGNATURE_PARAMETER
 85        A0,
 86#endif
 87        A1, A2, A3, A4, A5, A6>::type
 88        args;
 89
 90#ifdef BOOST_SIGNALS2_NAMED_SIGNATURE_PARAMETER
 91      typedef typename parameter::value_type<args, keywords::tag::signature_type>::type
 92        signature_type;
 93#else
 94      typedef Signature signature_type;
 95#endif
 96
 97      typedef typename parameter::value_type
 98        <
 99          args,
100          keywords::tag::combiner_type,
101          optional_last_value
102            <
103              typename boost::function_traits<signature_type>::result_type
104            >
105        >::type combiner_type;
106
107      typedef typename
108        parameter::value_type<args, keywords::tag::group_type, int>::type group_type;
109
110      typedef typename
111        parameter::value_type<args, keywords::tag::group_compare_type, std::less<group_type> >::type
112        group_compare_type;
113
114      typedef typename
115        parameter::value_type<args, keywords::tag::slot_function_type, function<signature_type> >::type
116        slot_function_type;
117
118      typedef typename
119        parameter::value_type
120          <
121            args,
122            keywords::tag::extended_slot_function_type,
123            typename detail::extended_signature<function_traits<signature_type>::arity, signature_type>::function_type
124          >::type
125          extended_slot_function_type;
126
127      typedef typename
128        parameter::value_type<args, keywords::tag::mutex_type, mutex>::type mutex_type;
129
130      typedef signal
131        <
132          signature_type,
133          combiner_type,
134          group_type,
135          group_compare_type,
136          slot_function_type,
137          extended_slot_function_type,
138          mutex_type
139        > type;
140    };
141  } // namespace signals2
142} // namespace boost
143
144#endif // BOOST_SIGNALS2_SIGNAL_TYPE_HPP