![]() |
Home | Libraries | People | FAQ | More |
boost::signals2::slot — Pass slots as function arguments, and associate tracked objects with a slot.
// In header: <boost/signals2/slot.hpp> template<typename Signature, typename SlotFunction = boost::function<> class slot : public boost::signals2::slot_base { public: // types typedef ; typedef ; // Exists iff arity == 1 typedef ; // Exists iff arity == 2 typedef ; // Exists iff arity == 2 typedef ; typedef ; // static constants = ; // The number of arguments taken by the slot. // member classes/structs/unions template< n> class arg { public: // types typedef ; // The type of the slot's (n+1)th argument }; // construct/copy/destruct template<typename Slot> (); template<typename OtherSignature, typename OtherSlotFunction> (); template<typename Func, typename Arg1, typename Arg2, ..., typename ArgN> (, , , ..., ); // invocation (, , ..., ); (, , ..., ) ; // tracking (); (signals2::signal_base &); (signals2::slot_base &); template<typename ForeignWeakPtr> (, = ); template<typename ForeignSharedPtr> (, = ); // slot function access (); () ; };
A slot consists of a polymorphic function wrapper (boost::function by default)
plus a container of weak_ptr
s which identify the slot's "tracked objects". If any of the
tracked objects expire, the slot will automatically disable itself. That is, the slot's function
call operator will throw an exception instead of forwarding the function call to the slot's
polymorphic function wrapper. Additionally, a slot will automatically lock all the tracked objects
as shared_ptr
during invocation, to prevent any of them from expiring while
the polymorphic function wrapper is being run.
The slot constructor will search for signals2::signal and signals2::trackable inside incoming function objects and automatically track them. It does so by applying a visitor to the incoming functors with boost::visit_each.
slot
public
construct/copy/destructtemplate<typename Slot> ( target);
Effects: |
Initializes the In this special case where the template type parameter |
template<typename OtherSignature, typename OtherSlotFunction> ( other_slot);
Effects: |
Initializes |
template<typename Func, typename Arg1, typename Arg2, ..., typename ArgN> ( f, a1, a2, ..., aN);
Effects: |
Syntactic sugar for |
slot
invocation( a1, a2, ..., aN); ( a1, a2, ..., aN) ;
Effects: |
Calls the slot's |
Returns: |
The result returned by the slot's |
Throws: |
Any exceptions thrown by the slot's |
Notes: |
If you have already used lock to insure the
tracked objects are valid, it is slightly more efficient to use the
slot_function() method
and call the slot's |
slot
tracking( tracked_object); (signals2::signal_base & tracked_signal); (signals2::slot_base & tracked_slot);
Effects: |
Adds object(s) to the slot's tracked object list. Should any of the
tracked objects expire, then subsequent attempts to call the slot's When tracking a signal, a shared_ptr
internal to the signal class is used for tracking. The signal does not
need to be owned by an external
In the case of passing another slot as the argument to |
Returns: |
|
template<typename ForeignWeakPtr> ( tracked_object, SFINAE = ); template<typename ForeignSharedPtr> ( tracked_object, SFINAE = );
Effects: |
The
In order to use a particular The second argument "SFINAE" may be ignored, it is used to resolve the overload between
either |
Returns: |
|