libsigc++: sigc::trackable_signal_with_accumulator< T_return, T_accumulator, T_arg > Class Template Reference

libsigc++ 3.8.1

Public Types | Public Member Functions | List of all members
sigc::trackable_signal_with_accumulator< T_return, T_accumulator, T_arg > Class Template Reference
Signals

Signal declaration. More...

`#include <sigc++/signal.h>`

Inheritance diagram for sigc::trackable_signal_with_accumulator< T_return, T_accumulator, T_arg >:
[legend]

## Public Types
using | slot_type = slot<T_return(T_arg...)>
Public Types inherited from sigc::signal_base
using | size_type = std::size_t
Public Types inherited from sigc::trackable
using | func_destroy_notify = internal::func_destroy_notify
Public Types inherited from sigc::notifiable
using | func_destroy_notify = internal::func_destroy_notify

## Public Member Functions
| trackable_signal_with_accumulator ()=default
| trackable_signal_with_accumulator (const trackable_signal_with_accumulator & src)
| trackable_signal_with_accumulator (trackable_signal_with_accumulator && src)
connection | connect (const slot_type & slot_)
| Add a slot at the end of the list of slots.
connection | connect (slot_type && slot_)
| Add a slot at the end of the list of slots.
connection | connect_first (const slot_type & slot_)
| Add a slot at the beginning of the list of slots.
connection | connect_first (slot_type && slot_)
| Add a slot at the beginning of the list of slots.
decltype(auto) | emit (type_trait_take_t< T_arg >... a) const
| Triggers the emission of the signal.
decltype(auto) | make_slot () const
| Creates a functor that calls emit() on this signal.
decltype(auto) | operator() (type_trait_take_t< T_arg >... a) const
| Triggers the emission of the signal (see emit()).
trackable_signal_with_accumulator & | operator= (const trackable_signal_with_accumulator & src)
trackable_signal_with_accumulator & | operator= (trackable_signal_with_accumulator && src)
Public Member Functions inherited from sigc::signal_base
| signal_base () noexcept
| signal_base (const signal_base & src) noexcept
| signal_base (signal_base && src)
| ~signal_base ()
void | block (bool should_block=true) noexcept
| Sets the blocking state of all slots in the list.
bool | blocked () const noexcept
| Returns whether all slots in the list are blocked.
void | clear ()
| Empties the list of slots.
bool | empty () const noexcept
| Returns whether the list of slots is empty.
signal_base & | operator= (const signal_base & src)
signal_base & | operator= (signal_base && src)
size_type | size () const noexcept
| Returns the number of slots in the list.
void | unblock () noexcept
| Unsets the blocking state of all slots in the list.
Public Member Functions inherited from sigc::trackable
| trackable () noexcept
| trackable (const trackable & src) noexcept
| trackable (trackable && src) noexcept
| ~trackable ()
void | add_destroy_notify_callback (notifiable * data, func_destroy_notify func) const
| Add a callback that is executed (notified) when the trackable object is detroyed.
void | notify_callbacks ()
| Execute and remove all previously installed callbacks.
trackable & | operator= (const trackable & src)
trackable & | operator= (trackable && src) noexcept
void | remove_destroy_notify_callback (notifiable * data) const
| Remove a callback previously installed with add_destroy_notify_callback().

## Additional Inherited Members
Protected Types inherited from sigc::signal_base
using | iterator_type = internal::signal_impl::iterator_type
Protected Member Functions inherited from sigc::signal_base
iterator_type | connect (const slot_base & slot_)
| Adds a slot at the end of the list of slots.
iterator_type | connect (slot_base && slot_)
| Adds a slot at the end of the list of slots.
iterator_type | connect_first (const slot_base & slot_)
| Adds a slot at the beginning of the list of slots.
iterator_type | connect_first (slot_base && slot_)
| Adds a slot at the beginning of the list of slots.
std::shared_ptr< internal::signal_impl > | impl () const
| Returns the signal_impl object encapsulating the list of slots.
iterator_type | insert (iterator_type i, const slot_base & slot_)
| Adds a slot at the given position into the list of slots.
iterator_type | insert (iterator_type i, slot_base && slot_)
| Adds a slot at the given position into the list of slots.
Protected Attributes inherited from sigc::signal_base
std::shared_ptr< internal::signal_impl > | impl_
| The signal_impl object encapsulating the slot list.

## Detailed Description

template <typename T_return, typename T_accumulator, typename... T_arg>
class sigc::trackable_signal_with_accumulator< T_return, T_accumulator, T_arg >

Signal declaration.

trackable_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.

  Since libsigc++ 3.4

## Member Typedef Documentation

## ◆ slot_type

template <typename T_return, typename T_accumulator, typename... T_arg>

using sigc::trackable_signal_with_accumulator< T_return, T_accumulator, T_arg >::slot_type = slot<T_return(T_arg...)>

## Constructor & Destructor Documentation

## ◆ trackable_signal_with_accumulator() [1/3]

template <typename T_return, typename T_accumulator, typename... T_arg>

sigc::trackable_signal_with_accumulator< T_return, T_accumulator, T_arg >::trackable_signal_with_accumulator | ( |  | ) |
| default

## ◆ trackable_signal_with_accumulator() [2/3]

template <typename T_return, typename T_accumulator, typename... T_arg>

sigc::trackable_signal_with_accumulator< T_return, T_accumulator, T_arg >::trackable_signal_with_accumulator | ( | const trackable_signal_with_accumulator< T_return, T_accumulator, T_arg > & | src | ) |
| inline

## ◆ trackable_signal_with_accumulator() [3/3]

template <typename T_return, typename T_accumulator, typename... T_arg>

sigc::trackable_signal_with_accumulator< T_return, T_accumulator, T_arg >::trackable_signal_with_accumulator | ( | trackable_signal_with_accumulator< T_return, T_accumulator, T_arg > && | src | ) |
| inline

## Member Function Documentation

## ◆ connect() [1/2]

template <typename T_return, typename T_accumulator, typename... T_arg>

connection sigc::trackable_signal_with_accumulator< T_return, T_accumulator, T_arg >::connect | ( | const slot_type & | slot_ | ) |
| inline

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.

## ◆ connect() [2/2]

template <typename T_return, typename T_accumulator, typename... T_arg>

connection sigc::trackable_signal_with_accumulator< T_return, T_accumulator, T_arg >::connect | ( | slot_type && | slot_ | ) |
| inline

Add a slot at the end of the list of slots.

See also
  connect(const slot_type& slot_).

## ◆ connect_first() [1/2]

template <typename T_return, typename T_accumulator, typename... T_arg>

connection sigc::trackable_signal_with_accumulator< T_return, T_accumulator, T_arg >::connect_first | ( | const slot_type & | slot_ | ) |
| inline

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

## ◆ connect_first() [2/2]

template <typename T_return, typename T_accumulator, typename... T_arg>

connection sigc::trackable_signal_with_accumulator< T_return, T_accumulator, T_arg >::connect_first | ( | slot_type && | slot_ | ) |
| inline

Add a slot at the beginning of the list of slots.

See also
  connect_first(const slot_type& slot_).

Since libsigc++ 3.6

## ◆ emit()

template <typename T_return, typename T_accumulator, typename... T_arg>

decltype(auto) sigc::trackable_signal_with_accumulator< T_return, T_accumulator, T_arg >::emit | ( | type_trait_take_t< T_arg >... | a | ) | const
| inline

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.

## ◆ make_slot()

template <typename T_return, typename T_accumulator, typename... T_arg>

decltype(auto) sigc::trackable_signal_with_accumulator< T_return, T_accumulator, T_arg >::make_slot | ( |  | ) | const
| inline

Creates a functor that calls emit() on this signal.

sigc::mem_fun(mysignal, &sigc::trackable_signal_with_accumulator::emit)
sigc::trackable_signal_with_accumulator::emit
decltype(auto) emit(type_trait_take_t< T_arg >... a) const
Triggers the emission of the signal.
Definition signal.h:790
sigc::mem_fun
decltype(auto) mem_fun(T_return(T_obj::*func)(T_arg...))
Creates a functor of type sigc::mem_functor which wraps a method.
Definition mem_fun.h:186

yields the same result.

Returns
  A functor that calls emit() on this signal.

## ◆ operator()()

template <typename T_return, typename T_accumulator, typename... T_arg>

decltype(auto) sigc::trackable_signal_with_accumulator< T_return, T_accumulator, T_arg >::operator() | ( | type_trait_take_t< T_arg >... | a | ) | const
| inline

Triggers the emission of the signal (see emit()).

## ◆ operator=() [1/2]

template <typename T_return, typename T_accumulator, typename... T_arg>

trackable_signal_with_accumulator & sigc::trackable_signal_with_accumulator< T_return, T_accumulator, T_arg >::operator= | ( | const trackable_signal_with_accumulator< T_return, T_accumulator, T_arg > & | src | ) |
| inline

## ◆ operator=() [2/2]

template <typename T_return, typename T_accumulator, typename... T_arg>

trackable_signal_with_accumulator & sigc::trackable_signal_with_accumulator< T_return, T_accumulator, T_arg >::operator= | ( | trackable_signal_with_accumulator< T_return, T_accumulator, T_arg > && | src | ) |
| inline