...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
boost::signals2::slotN — Pass slots as function arguments, and associate tracked objects with a slot.
// In header: <boost/signals2/slot.hpp> template<typename R, typename T1, typename T2, ..., typename TN, typename SlotFunction = functionN<R, T1, T2, ..., TN> > class slotN : public slot_base { public: // types typedef R result_type; typedef T1 argument_type; // If N == 1 typedef T1 first_argument_type; // If N == 2 typedef T2 second_argument_type; // If N == 2 typedef T1 arg1_type; typedef T2 arg2_type; . . . typedef TN argN_type; typedef SlotFunction slot_function_type; // static constants static const int arity = N; // construct/copy/destruct template<typename Slot> slotN(const Slot &); template<typename OtherR, typename OtherT1, typename OtherT2, ..., typename OtherTN, typename OtherSlotFunction> slotN(const slotN<OtherR, OtherT1, OtherT2, ..., OtherTN, OtherSlotFunction> &); template<typename OtherSignature, typename OtherSlotFunction> slotN(const slot<OtherSignature, OtherSlotFunction> &); template<typename Func, typename Arg1, typename Arg2, ..., typename ArgN> slotN(const Func &, const Arg1 &, const Arg2 &, ..., const ArgN &); // invocation result_type operator()(arg1_type, arg2_type, ..., argN_type); result_type operator()(arg1_type, arg2_type, ..., argN_type) const; // tracking slotN & track(const weak_ptr<void> &); slotN & track(const signal_base &); slotN & track(const slot_base &); // slot function access slot_function_type & slot_function(); const slot_function_type & slot_function() const; };
The class template slotN covers several related classes slot0, slot1, slot2, etc., where the number suffix describes the number of function parameters the slot will take. Instead of enumerating all classes, a single pattern slotN will be described, where N represents the number of function parameters.
slotN
public
construct/copy/destructtemplate<typename Slot> slotN(const Slot & target);
Effects: |
Initializes the In this special case where the template type parameter |
template<typename OtherR, typename OtherT1, typename OtherT2, ..., typename OtherTN, typename OtherSlotFunction> slotN(const slotN<OtherR, OtherT1, OtherT2, ..., OtherTN, OtherSlotFunction> & other_slot);
Effects: |
Initializes |
template<typename OtherSignature, typename OtherSlotFunction> slotN(const slot<OtherSignature, OtherSlotFunction> & other_slot);
Effects: |
Initializes |
template<typename Func, typename Arg1, typename Arg2, ..., typename ArgN> slotN(const Func & f, const Arg1 & a1, const Arg2 & a2, ..., const ArgN & aN);
Effects: |
Syntactic sugar for |
slotN
invocationresult_type operator()(arg1_type a1, arg2_type a2, ..., argN_type aN); result_type operator()(arg1_type a1, arg2_type a2, ..., argN_type aN) const;
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 |
slotN
trackingslotN & track(const weak_ptr<void> & tracked_object); slotN & track(const signal_base & tracked_signal); slotN & track(const 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: |
|