00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #if GG_SIGNALS_NUM_ARGS == 0
00030 #define GG_SIGNALS_COMMA_IF_NONZERO_ARGS
00031 #else
00032 #define GG_SIGNALS_COMMA_IF_NONZERO_ARGS ,
00033 #endif
00034
00035 #define GG_SIGNALS_FORWARDER_NAME BOOST_PP_CAT(GG_SIGNALS_FORWARDER_BASE_NAME, GG_SIGNALS_NUM_ARGS)
00036
00037 namespace GG {
00038
00039 namespace detail {
00040 template <class C, class R GG_SIGNALS_COMMA_IF_NONZERO_ARGS
00041 GG_SIGNALS_SIGNAL_TEMPLATE_PARMS>
00042 struct GG_SIGNALS_FORWARDER_NAME
00043 {
00044 GG_SIGNALS_FORWARDER_NAME(boost::signal<R (GG_SIGNALS_SIGNAL_TEMPLATE_ARGS), C>& sig_) : sig(sig_) {}
00045 R operator()(GG_SIGNALS_SIGNAL_PARMS) {sig(GG_SIGNALS_SIGNAL_ARGS);}
00046 boost::signal<R (GG_SIGNALS_SIGNAL_TEMPLATE_ARGS), C>& sig;
00047 };
00048 }
00049
00054 template <class C, class R, class T1, class T2 GG_SIGNALS_COMMA_IF_NONZERO_ARGS
00055 GG_SIGNALS_SIGNAL_TEMPLATE_PARMS> inline
00056 boost::signals::connection
00057 Connect(boost::signal<R (GG_SIGNALS_SIGNAL_TEMPLATE_ARGS), C>& sig,
00058 R (T1::* fn) (GG_SIGNALS_SIGNAL_TEMPLATE_ARGS),
00059 T2 obj,
00060 boost::signals::connect_position at = boost::signals::at_back)
00061 {
00062 return sig.connect(boost::bind(fn, obj GG_SIGNALS_COMMA_IF_NONZERO_ARGS GG_SIGNALS_BIND_ARGS), at);
00063 }
00064
00069 template <class C, class R, class T1, class T2 GG_SIGNALS_COMMA_IF_NONZERO_ARGS
00070 GG_SIGNALS_SIGNAL_TEMPLATE_PARMS> inline
00071 boost::signals::connection
00072 Connect(boost::signal<R (GG_SIGNALS_SIGNAL_TEMPLATE_ARGS), C>& sig,
00073 R (T1::* fn) (GG_SIGNALS_SIGNAL_TEMPLATE_ARGS) const,
00074 T2 obj,
00075 boost::signals::connect_position at = boost::signals::at_back)
00076 {
00077 return sig.connect(boost::bind(fn, obj GG_SIGNALS_COMMA_IF_NONZERO_ARGS GG_SIGNALS_BIND_ARGS), at);
00078 }
00079
00084 template <class C, class R, class T1, class T2 GG_SIGNALS_COMMA_IF_NONZERO_ARGS
00085 GG_SIGNALS_SIGNAL_TEMPLATE_PARMS> inline
00086 boost::signals::connection
00087 Connect(boost::signal<R (GG_SIGNALS_SIGNAL_TEMPLATE_ARGS), C>& sig,
00088 R (T1::* fn) (GG_SIGNALS_SIGNAL_TEMPLATE_ARGS),
00089 T2 obj,
00090 int grp,
00091 boost::signals::connect_position at = boost::signals::at_back)
00092 {
00093 return sig.connect(grp, boost::bind(fn, obj GG_SIGNALS_COMMA_IF_NONZERO_ARGS GG_SIGNALS_BIND_ARGS), at);
00094 }
00095
00100 template <class C, class R, class T1, class T2 GG_SIGNALS_COMMA_IF_NONZERO_ARGS
00101 GG_SIGNALS_SIGNAL_TEMPLATE_PARMS> inline
00102 boost::signals::connection
00103 Connect(boost::signal<R (GG_SIGNALS_SIGNAL_TEMPLATE_ARGS), C>& sig,
00104 R (T1::* fn) (GG_SIGNALS_SIGNAL_TEMPLATE_ARGS) const,
00105 T2 obj,
00106 int grp,
00107 boost::signals::connect_position at = boost::signals::at_back)
00108 {
00109 return sig.connect(grp, boost::bind(fn, obj GG_SIGNALS_COMMA_IF_NONZERO_ARGS GG_SIGNALS_BIND_ARGS), at);
00110 }
00111
00114 template <class C, class R GG_SIGNALS_COMMA_IF_NONZERO_ARGS
00115 GG_SIGNALS_SIGNAL_TEMPLATE_PARMS> inline
00116 boost::signals::connection
00117 Connect(boost::signal<R (GG_SIGNALS_SIGNAL_TEMPLATE_ARGS), C>& sig1,
00118 boost::signal<R (GG_SIGNALS_SIGNAL_TEMPLATE_ARGS), C>& sig2,
00119 boost::signals::connect_position at = boost::signals::at_back)
00120 {
00121 typedef typename detail::GG_SIGNALS_FORWARDER_NAME<C, R GG_SIGNALS_COMMA_IF_NONZERO_ARGS GG_SIGNALS_SIGNAL_TEMPLATE_ARGS> Forwarder;
00122 return sig1.connect(Forwarder(sig2), at);
00123 }
00124
00127 template <class C, class R GG_SIGNALS_COMMA_IF_NONZERO_ARGS
00128 GG_SIGNALS_SIGNAL_TEMPLATE_PARMS> inline
00129 boost::signals::connection
00130 Connect(boost::signal<R (GG_SIGNALS_SIGNAL_TEMPLATE_ARGS), C>& sig1,
00131 boost::signal<R (GG_SIGNALS_SIGNAL_TEMPLATE_ARGS), C>& sig2,
00132 int grp,
00133 boost::signals::connect_position at = boost::signals::at_back)
00134 {
00135 typedef typename detail::GG_SIGNALS_FORWARDER_NAME<C, R GG_SIGNALS_COMMA_IF_NONZERO_ARGS GG_SIGNALS_SIGNAL_TEMPLATE_ARGS> Forwarder;
00136 return sig1.connect(grp, Forwarder(sig2), at);
00137 }
00138
00139 }
00140
00141 #undef GG_SIGNALS_COMMA_IF_NONZERO_ARGS
00142 #undef GG_SIGNALS_FORWARDER_NAME