libqi-api
2.8.7.4
|
#include <signal.hpp>
Public Types | |
using | OnSubscribers = boost::function< Future< void >(bool)> |
Public Member Functions | |
SignalBase (const Signature &signature, OnSubscribers onSubscribers=OnSubscribers()) | |
SignalBase (const Signature &signature, ExecutionContext *execContext, OnSubscribers onSubscribers=OnSubscribers()) | |
SignalBase (OnSubscribers onSubscribers=OnSubscribers()) | |
SignalBase (ExecutionContext *execContext, OnSubscribers onSubscribers=OnSubscribers()) | |
SignalBase (const SignalBase &)=delete | |
SignalBase is not copyable, since subscriptions should not be duplicated. More... | |
SignalBase & | operator= (const SignalBase &)=delete |
virtual | ~SignalBase () |
virtual qi::Signature | signature () const |
template<typename F > | |
SignalSubscriber | connect (boost::function< F > func) |
SignalSubscriber | connect (AnyObject object, const unsigned int slot) |
SignalSubscriber | connect (AnyObject object, const std::string &slot) |
SignalSubscriber | connect (const SignalSubscriber &s) |
The following overloads are the lowest-level. More... | |
Future< SignalSubscriber > | connectAsync (const SignalSubscriber &) |
bool | disconnectAll () |
Future< bool > | disconnectAllAsync () |
bool | asyncDisconnectAll () |
bool | disconnect (const SignalLink &link) |
Future< bool > | disconnectAsync (const SignalLink &link) |
bool | asyncDisconnect (const SignalLink &link) |
virtual void | trigger (const GenericFunctionParameters ¶ms, MetaCallType callType=MetaCallType_Auto) |
void | setCallType (MetaCallType callType) |
Set the MetaCallType used by operator()(). More... | |
void | operator() (qi::AutoAnyReference p1=qi::AutoAnyReference(), qi::AutoAnyReference p2=qi::AutoAnyReference(), qi::AutoAnyReference p3=qi::AutoAnyReference(), qi::AutoAnyReference p4=qi::AutoAnyReference(), qi::AutoAnyReference p5=qi::AutoAnyReference(), qi::AutoAnyReference p6=qi::AutoAnyReference(), qi::AutoAnyReference p7=qi::AutoAnyReference(), qi::AutoAnyReference p8=qi::AutoAnyReference()) |
Trigger the signal with given arguments, and call type set by setCallType() More... | |
std::vector< SignalSubscriber > | subscribers () |
bool | hasSubscribers () |
void | setOnSubscribers (OnSubscribers onSubscribers) |
void | _setSignature (const Signature &s) |
Static Public Attributes | |
static const SignalLink | invalidSignalLink |
Protected Types | |
using | Trigger = boost::function< void(const GenericFunctionParameters ¶ms, MetaCallType callType)> |
Protected Member Functions | |
void | callSubscribers (const GenericFunctionParameters ¶ms, MetaCallType callType=MetaCallType_Auto) |
void | setTriggerOverride (Trigger trigger) |
void | callOnSubscribe (bool v) |
void | createNewTrackLink (int &id, SignalLink *&trackLink) |
void | disconnectTrackLink (int id) |
ExecutionContext * | executionContext () const |
void | clearExecutionContext () |
Protected Attributes | |
boost::shared_ptr < SignalBasePrivate > | _p |
Friends | |
class | SignalBasePrivate |
SignalBase provides a signal subscription mechanism called "connection". Derived classes can customize the subscription step by setting an "onSubscribers" callback.
Definition at line 42 of file signal.hpp.
using qi::SignalBase::OnSubscribers = boost::function<Future<void>(bool)> |
Definition at line 45 of file signal.hpp.
|
protected |
Definition at line 154 of file signal.hpp.
|
explicit |
qi::SignalBase::SignalBase | ( | const Signature & | signature, |
ExecutionContext * | execContext, | ||
OnSubscribers | onSubscribers = OnSubscribers() |
||
) |
qi::SignalBase::SignalBase | ( | OnSubscribers | onSubscribers = OnSubscribers() | ) |
qi::SignalBase::SignalBase | ( | ExecutionContext * | execContext, |
OnSubscribers | onSubscribers = OnSubscribers() |
||
) |
|
delete |
SignalBase is not copyable, since subscriptions should not be duplicated.
|
virtual |
void qi::SignalBase::_setSignature | ( | const Signature & | s | ) |
|
inline |
Definition at line 116 of file signal.hpp.
|
inline |
Definition at line 89 of file signal.hpp.
|
protected |
|
protected |
|
protected |
SignalSubscriber qi::SignalBase::connect | ( | boost::function< F > | func | ) |
Definition at line 89 of file signal.hxx.
SignalSubscriber qi::SignalBase::connect | ( | AnyObject | object, |
const unsigned int | slot | ||
) |
SignalSubscriber qi::SignalBase::connect | ( | AnyObject | object, |
const std::string & | slot | ||
) |
SignalSubscriber qi::SignalBase::connect | ( | const SignalSubscriber & | s | ) |
The following overloads are the lowest-level.
Future<SignalSubscriber> qi::SignalBase::connectAsync | ( | const SignalSubscriber & | ) |
Connect asynchronously. This is recommended since derived classes may provide asynchronous customizations for dealing with subscribers. The callbacks are guaranteed to be called only after the returned future is set.
|
protected |
bool qi::SignalBase::disconnect | ( | const SignalLink & | link | ) |
Disconnect a SignalHandler.
The associated callback will not be called anymore as soon as this function returns.
This method blocks until all the already running callbacks are finished.
bool qi::SignalBase::disconnectAll | ( | ) |
Disconnect all callbacks from signal.
This function will block until all callbacks are finished.
Future<bool> qi::SignalBase::disconnectAllAsync | ( | ) |
Disconnect all callbacks from signal without waiting for them.
This function does not block.
Future<bool> qi::SignalBase::disconnectAsync | ( | const SignalLink & | link | ) |
Disconnect a SignalHandler without waiting for it.
Same as disconnect, but this method does not block. Though this is async, you are guaranteed that once the function returns the future, your callback will not be called anymore.
|
protected |
|
protected |
bool qi::SignalBase::hasSubscribers | ( | ) |
void qi::SignalBase::operator() | ( | qi::AutoAnyReference | p1 = qi::AutoAnyReference() , |
qi::AutoAnyReference | p2 = qi::AutoAnyReference() , |
||
qi::AutoAnyReference | p3 = qi::AutoAnyReference() , |
||
qi::AutoAnyReference | p4 = qi::AutoAnyReference() , |
||
qi::AutoAnyReference | p5 = qi::AutoAnyReference() , |
||
qi::AutoAnyReference | p6 = qi::AutoAnyReference() , |
||
qi::AutoAnyReference | p7 = qi::AutoAnyReference() , |
||
qi::AutoAnyReference | p8 = qi::AutoAnyReference() |
||
) |
Trigger the signal with given arguments, and call type set by setCallType()
|
delete |
void qi::SignalBase::setCallType | ( | MetaCallType | callType | ) |
Set the MetaCallType used by operator()().
void qi::SignalBase::setOnSubscribers | ( | OnSubscribers | onSubscribers | ) |
Set a function to call when the number of subscribers go between 1 and 0. You can use this to avoid computing if no one has subscribed to the signal.
|
protected |
|
virtual |
std::vector<SignalSubscriber> qi::SignalBase::subscribers | ( | ) |
|
virtual |
Trigger the signal with given type-erased parameters.
params | the signal arguments |
callType | specify how to invoke subscribers. Used in combination with each subscriber's MetaCallType to chose between synchronous and asynchronous call. The combination rule is to honor subscriber's override, then callType , then signal's callType and default to asynchronous |
|
friend |
Definition at line 165 of file signal.hpp.
|
protected |
Definition at line 164 of file signal.hpp.
|
static |
Definition at line 151 of file signal.hpp.