template<typename T_return, typename T_accumulator, typename... T_arg>
class sigc::signal_with_accumulator< T_return, T_accumulator, T_arg >
Signal declaration.
signal_with_accumulator can be used to connect() slots that are invoked during subsequent calls to emit(). Any functor or slot can be passed into connect() or connect_first(). It is converted into a slot implicitly.
If you want to connect one signal to another, use make_slot() to retrieve a functor that emits the signal when invoked.
Be careful if you directly pass one signal into the connect() or connect_first() method of another: a shallow copy of the signal is made and the signal's slots are not disconnected until both the signal and its clone are destroyed, which is probably not what you want!
The following template arguments are used:
- T_return The desired return type for the emit() function (may be overridden by the accumulator).
- T_arg Argument types used in the definition of emit().
- T_accumulator The accumulator type used for emission. The default
void
means that no accumulator should be used, for example if signal emission returns the return value of the last slot invoked.
template <typename T_return , typename T_accumulator , typename... T_arg>
Add a slot at the end of the list of slots.
Any functor or slot may be passed into connect(). It will be converted into a slot implicitly. The returned connection may be stored for disconnection of the slot at some later point. It stays valid until the slot is disconnected from the signal. std::function<> and C++11 lambda expressions are functors. These are examples of functors that can be connected to a signal.
std::bind() creates a functor, but this functor typically has an operator()() which is a variadic template. Our functor_trait can't deduce the result type of such a functor. If you first assign the return value of std::bind() to a std::function, you can connect the std::function to a signal.
- Parameters
-
slot_ | The slot to add to the list of slots. |
- Returns
- A connection.
template <typename T_return , typename T_accumulator , typename... T_arg>
Add a slot at the beginning of the list of slots.
Any functor or slot may be passed into connect_first(). It will be converted into a slot implicitly. The returned connection may be stored for disconnection of the slot at some later point. It stays valid until the slot is disconnected from the signal. std::function<> and C++11 lambda expressions are functors. These are examples of functors that can be connected to a signal.
std::bind() creates a functor, but this functor typically has an operator()() which is a variadic template. Our functor_trait can't deduce the result type of such a functor. If you first assign the return value of std::bind() to a std::function, you can connect the std::function to a signal.
- Parameters
-
slot_ | The slot to add to the list of slots. |
- Returns
- A connection.
- Since libsigc++ 3.6:
template <typename T_return , typename T_accumulator , typename... T_arg>
Triggers the emission of the signal.
During signal emission all slots that have been connected to the signal are invoked unless they are manually set into a blocking state. The parameters are passed on to the slots. If T_accumulated is not void
, an accumulator of this type is used to process the return values of the slot invocations. Otherwise, the return value of the last slot invoked is returned.
- Parameters
-
a | Arguments to be passed on to the slots. |
- Returns
- The accumulated return values of the slot invocations.