Class template slotN
boost::slotN — Pass slots as function arguments, and associate tracked objects with a slot.
Synopsis
template<typename R, typename T1, typename T2, ..., typename TN, typename SlotFunction = functionN<R, T1, T2, ..., TN> > class slotN : public boost::signalslib::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(Func, Arg1, Arg2, ..., 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 signalslib::signal_base &); slotN & track(const signalslib::slot_base &); // slot function access slot_function_type & slot_function(); const slot_function_type & slot_function() const; };
Description
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/destruct
-
template<typename Slot> slotN(const Slot & target);
Effects: Initializes the
SlotFunctionobject inthiswithtarget, which may be any function object with which aSlotFunctioncan be constructed. The slot's tracked object list is initially empty. -
template<typename OtherR, typename OtherT1, typename OtherT2, ..., typename OtherTN, typename OtherSlotFunction> slotN(const slotN<OtherR, OtherT1, OtherT2, ..., OtherTN, OtherSlotFunction> & other_slot);
Effects: Initializes
thiswith a copy ofother_slot'sSlotFunctionobject and tracked object list. -
template<typename OtherSignature, typename OtherSlotFunction> slotN(const slot<OtherSignature, OtherSlotFunction> & other_slot);
Effects: Initializes
thiswith a copy ofother_slot'sOtherSlotFunctionobject and tracked object list. -
template<typename Func, typename Arg1, typename Arg2, ..., typename ArgN> slotN(Func f, Arg1 a1, Arg2 a2, ..., ArgN aN);
Effects: Syntactic sugar for
bind()when the constructor is passed more than one argument. As if:slotN(boost::bind(f, a1, a2, ..., aN))
slotN invocation
-
result_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
SlotFunctionobject.Returns: The result returned by the slot's
SlotFunctionobject.Throws: Any exceptions thrown by the slot's
SlotFunctionobject. boost::expired_slot if any object in the tracked object list has expired.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
SlotFunctiondirectly.
slotN tracking
-
slotN & track(const weak_ptr<void> & tracked_object); slotN & track(const signalslib::signal_base & tracked_signal); slotN & track(const signalslib::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
operator()orlock()methods will throw an expired_slot exception.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
shared_ptr.In the case of passing another slot as the argument to
track(), only the objects currently in the other slot's tracked object list are added to the tracked object list ofthis. The other slot object itself is not tracked.Returns: *this