7 #ifndef _QITYPE_DETAILS_SIGNAL_HXX_
8 #define _QITYPE_DETAILS_SIGNAL_HXX_
12 #include <boost/bind.hpp>
18 template <
typename ARG0>
19 inline typename boost::enable_if<
20 boost::is_base_of<Actor, typename detail::Unwrap<ARG0>::type>,
21 SignalSubscriber&>::type
22 SignalF<T>::_connectMaybeActor(
const ARG0& arg0,
23 const boost::function<T>& cb,
24 const boost::function<
void()>& fallbackCb)
29 detail::Unwrap<ARG0>::unwrap(arg0)->strand(), cb)),
37 template <
typename ARG0>
38 inline typename boost::disable_if<
39 boost::is_base_of<Actor, typename detail::Unwrap<ARG0>::type>,
40 SignalSubscriber&>::type
41 SignalF<T>::_connectMaybeActor(
const ARG0& arg0,
42 const boost::function<T>& cb,
43 const boost::function<
void()>& fallbackCb)
48 #define genConnect(n, ATYPEDECL, ATYPES, ADECL, AUSE, comma) \
49 template <typename T> \
50 template <typename F, typename P comma ATYPEDECL> \
51 SignalSubscriber& SignalF<T>::connect(const F& func, \
52 const P& p comma ADECL) \
55 SignalLink* trackLink; \
56 createNewTrackLink(curId, trackLink); \
57 SignalSubscriber& s = _connectMaybeActor<P>( \
58 p, qi::bind<T>(func, p comma AUSE), \
59 qi::track(boost::function<void()>(boost::bind( \
60 &SignalF<T>::disconnectTrackLink, this, curId)), \
61 boost::weak_ptr<SignalBasePrivate>(_p))); \
84 createNewTrackLink(curId, trackLink);
86 boost::bind(&SignalF<T>::disconnectTrackLink,
this, curId),
87 (boost::function<U>&)signal,
88 boost::weak_ptr<SignalBasePrivate>(signal._p)));
94 template<QI_SIGNAL_TEMPLATE_DECL>
97 typedef typename detail::VoidFunctionType<QI_SIGNAL_TEMPLATE>::type ftype;
100 createNewTrackLink(curId, trackLink);
102 boost::bind(&SignalF<T>::disconnectTrackLink,
this, curId),
103 (boost::function<ftype>&)signal,
104 boost::weak_ptr<SignalBasePrivate>(signal._p)));
120 template<
typename CALLABLE>
123 return connect((boost::function<T>)c);
134 return connect(SignalSubscriber(obj, slot));
143 BOOST_STATIC_ASSERT(
sizeof(T) < 0);
149 #define pushArg(z, n, _) \
150 args.push_back(AutoAnyReference(p ##n));
151 #define makeBounce(n, argstypedecl, argstype, argsdecl, argsues, comma) \
152 template<typename R comma argstypedecl> \
153 class BounceToSignalBase<R(argstype)> { \
155 BounceToSignalBase(SignalBase& signalBase) : signalBase(signalBase) {} \
156 R operator()(argsdecl) { \
157 AnyReferenceVector args; \
158 BOOST_PP_REPEAT(n, pushArg, _); \
159 signalBase.trigger(args); \
162 SignalBase& signalBase; \
182 return detail::functionArgumentsSignature<T>();
192 #endif // _QITYPE_DETAILS_SIGNAL_HXX_
SignalSubscriber & setCallType(MetaCallType ct)
static AnyFunction from(F func)
BounceToSignalBase(SignalBase &sb)
boost::function< RF > bind(const AF &fun,...)
#define genConnect(n, ATYPEDECL, ATYPES, ADECL, AUSE, comma)
void _setSignature(const Signature &s)
void post(const boost::function< void()> &callback)
post a callback to be executed as soon as possible
SignalSubscriber & connect(...)
virtual qi::Signature signature() const
Force a synchronous call.
#define makeBounce(n, argstypedecl, argstype, argsdecl, argsues, comma)
boost::function< void(bool)> OnSubscribers
MetaCallType threadingModel
boost::function< F > trackWithFallback(boost::function< void()> onFail, const boost::function< F > &f, const ARG0 &arg0)
Wrap given function f with a tracking check on arg0, which must be a weak pointer or a Trackable inst...
Object< Empty > AnyObject
SignalSubscriber & connect(const boost::function< F > &func)
SignalF(OnSubscribers onSubscribers=OnSubscribers())