7 #ifndef _QI_SIGNAL_HPP_
8 #define _QI_SIGNAL_HPP_
15 #include <boost/thread/thread.hpp>
16 #include <boost/thread/mutex.hpp>
17 #include <boost/thread/condition.hpp>
18 #include <boost/enable_shared_from_this.hpp>
21 # pragma warning( push )
22 # pragma warning( disable: 4251 )
30 class ManageablePrivate;
31 class SignalSubscriber;
33 class SignalBasePrivate;
61 bool asyncDisconnectAll();
101 std::vector<SignalSubscriber> subscribers();
102 bool hasSubscribers();
105 typedef boost::function<void(const GenericFunctionParameters& params, MetaCallType callType)>
Trigger;
107 void setTriggerOverride(
Trigger trigger);
109 void callOnSubscribe(
bool v);
110 void createNewTrackLink(
int&
id,
SignalLink*& trackLink);
111 void disconnectTrackLink(
int id);
115 boost::shared_ptr<SignalBasePrivate>
_p;
116 friend class SignalBasePrivate;
119 #define QI_SIGNAL_TEMPLATE_DECL typename P0, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7
120 #define QI_SIGNAL_TEMPLATE P0,P1,P2,P3,P4,P5,P6,P7
122 template<QI_SIGNAL_TEMPLATE_DECL>
class Signal;
136 using boost::function<T>::operator();
159 template <
typename CALLABLE>
164 template <
typename U>
166 template <QI_SIGNAL_TEMPLATE_DECL>
169 #define genConnect(n, ATYPEDECL, ATYPES, ADECL, AUSE, comma) \
170 template <typename F, typename P comma ATYPEDECL> \
171 SignalSubscriber& connect(const F& func, const P& p comma ADECL);
180 template <
typename ARG0>
181 inline typename boost::enable_if<
182 boost::is_base_of<Actor, typename detail::Unwrap<ARG0>::type>,
184 _connectMaybeActor(
const ARG0& arg0,
const boost::function<T>& cb,
185 const boost::function<
void()>& fallbackCb);
186 template <
typename ARG0>
187 inline typename boost::disable_if<
188 boost::is_base_of<Actor, typename detail::Unwrap<ARG0>::type>,
190 _connectMaybeActor(
const ARG0& arg0,
const boost::function<T>& cb,
191 const boost::function<
void()>& fallbackCb);
196 template<
typename P0,
typename P1,
typename P2,
typename P3,
typename P4,
typename P5,
typename P6,
typename P7>
struct VoidFunctionType {
typedef void(type)(P0, P1, P2, P3, P4, P5, P6, P7); };
197 template<
typename P0,
typename P1,
typename P2,
typename P3,
typename P4,
typename P5,
typename P6>
struct VoidFunctionType<P0, P1, P2, P3, P4, P5, P6, void> {
typedef void(type)(P0, P1, P2, P3, P4, P5, P6); };
198 template<
typename P0,
typename P1,
typename P2,
typename P3,
typename P4,
typename P5 >
struct VoidFunctionType<P0, P1, P2, P3, P4, P5, void, void> {
typedef void(type)(P0, P1, P2, P3, P4, P5); };
199 template<
typename P0,
typename P1,
typename P2,
typename P3,
typename P4 >
struct VoidFunctionType<P0, P1, P2, P3, P4, void, void, void> {
typedef void(type)(P0, P1, P2, P3, P4); };
200 template<
typename P0,
typename P1,
typename P2,
typename P3 >
struct VoidFunctionType<P0, P1, P2, P3, void, void, void, void> {
typedef void(type)(P0, P1, P2, P3); };
201 template<
typename P0,
typename P1,
typename P2 >
struct VoidFunctionType<P0, P1, P2, void, void, void, void, void> {
typedef void(type)(P0, P1, P2); };
202 template<
typename P0,
typename P1 >
struct VoidFunctionType<P0, P1, void, void, void, void, void, void> {
typedef void(type)(P0, P1); };
203 template<
typename P0 >
struct VoidFunctionType<P0, void, void, void, void, void, void, void> {
typedef void(type)(P0); };
204 template< >
struct VoidFunctionType<void, void, void, void, void, void, void, void> {
typedef void(type)(); };
222 class Signal:
public SignalF<typename detail::VoidFunctionType<P0, P1, P2, P3, P4, P5, P6, P7>::type>
225 typedef typename detail::VoidFunctionType<P0, P1, P2, P3, P4, P5, P6, P7>::type
FunctionType;
230 using boost::function<FunctionType>::operator();
241 :
public boost::enable_shared_from_this<SignalSubscriber>
274 void waitForInactive();
276 void addActive(
bool acquireLock, boost::thread::id tid = boost::this_thread::get_id());
277 void removeActive(
bool acquireLock, boost::thread::id tid = boost::this_thread::get_id());
320 # pragma warning( pop )
327 #endif // _QITYPE_SIGNAL_HPP_
Signal(OnSubscribers onSubscribers=OnSubscribers())
boost::condition inactiveThread
#define genConnect(n, ATYPEDECL, ATYPES, ADECL, AUSE, comma)
static const SignalLink invalidSignalLink
boost::shared_ptr< SignalBasePrivate > _p
Honor the default behavior.
ExecutionContext * executionContext
SignalSubscriber & connect(...)
virtual qi::Signature signature() const
boost::function< void(const GenericFunctionParameters ¶ms, MetaCallType callType)> Trigger
boost::function< void(bool)> OnSubscribers
MetaCallType threadingModel
QI_NO_TYPE(qi::AnyReference)
boost::shared_ptr< SignalSubscriber > SignalSubscriberPtr
uint64_t uint64_t
Cross-platform unsigned integer of length 64 bits (8 bytes).
std::vector< boost::thread::id > activeThreads
SignalLink linkId
Uid that can be passed to GenericObject::disconnect()
detail::VoidFunctionType< P0, P1, P2, P3, P4, P5, P6, P7 >::type FunctionType
ParentType::OnSubscribers OnSubscribers
SignalF(OnSubscribers onSubscribers=OnSubscribers())
SignalF< FunctionType > ParentType