libsigc++  3.6.0
Public Member Functions | List of all members
sigc::trackable_signal< T_return(T_arg...)>::accumulated< T_accumulator > Class Template Reference

Like sigc::trackable_signal but the additional template parameter T_accumulator defines the accumulator type that should be used. More...

#include <sigc++/signal.h>

Inheritance diagram for sigc::trackable_signal< T_return(T_arg...)>::accumulated< T_accumulator >:
Inheritance graph
[legend]

Public Member Functions

 accumulated ()=default
 
 accumulated (const accumulated & src)
 
- Public Member Functions inherited from sigc::trackable_signal_with_accumulator< T_return, T_accumulator, T_arg... >
 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. More...
 
connection connect (slot_type && slot_)
 Add a slot at the end of the list of slots. More...
 
connection connect_first (const slot_type & slot_)
 Add a slot at the beginning of the list of slots. More...
 
connection connect_first (slot_type && slot_)
 Add a slot at the beginning of the list of slots. More...
 
decltype(auto) emit (type_trait_take_t< T_arg >... a) const
 Triggers the emission of the signal. More...
 
decltype(auto) make_slot () const
 Creates a functor that calls emit() on this signal. More...
 
decltype(auto) operator() (type_trait_take_t< T_arg >... a) const
 Triggers the emission of the signal (see emit()). More...
 
trackable_signal_with_accumulatoroperator= (const trackable_signal_with_accumulator & src)
 
trackable_signal_with_accumulatoroperator= (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. More...
 
bool blocked () const noexcept
 Returns whether all slots in the list are blocked. More...
 
void clear ()
 Empties the list of slots. More...
 
bool empty () const noexcept
 Returns whether the list of slots is empty. More...
 
signal_baseoperator= (const signal_base & src)
 
signal_baseoperator= (signal_base && src)
 
size_type size () const noexcept
 Returns the number of slots in the list. More...
 
void unblock () noexcept
 Unsets the blocking state of all slots in the list. More...
 
- 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. More...
 
void notify_callbacks ()
 Execute and remove all previously installed callbacks. More...
 
trackableoperator= (const trackable & src)
 
trackableoperator= (trackable && src) noexcept
 
void remove_destroy_notify_callback (notifiable *data) const
 Remove a callback previously installed with add_destroy_notify_callback(). More...
 

Additional Inherited Members

- Public Types inherited from sigc::trackable_signal_with_accumulator< T_return, T_accumulator, T_arg... >
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
 
- 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. More...
 
iterator_type connect (slot_base && slot_)
 Adds a slot at the end of the list of slots. More...
 
iterator_type connect_first (const slot_base & slot_)
 Adds a slot at the beginning of the list of slots. More...
 
iterator_type connect_first (slot_base && slot_)
 Adds a slot at the beginning of the list of slots. More...
 
std::shared_ptr< internal::signal_impl > impl () const
 Returns the signal_impl object encapsulating the list of slots. More...
 
iterator_type insert (iterator_type i, const slot_base & slot_)
 Adds a slot at the given position into the list of slots. More...
 
iterator_type insert (iterator_type i, slot_base && slot_)
 Adds a slot at the given position into the list of slots. More...
 
- Protected Attributes inherited from sigc::signal_base
std::shared_ptr< internal::signal_impl > impl_
 The signal_impl object encapsulating the slot list. More...
 

Detailed Description

template<typename T_return, typename... T_arg>
template <typename T_accumulator>
class sigc::trackable_signal< T_return(T_arg...)>::accumulated< T_accumulator >

Like sigc::trackable_signal but the additional template parameter T_accumulator defines the accumulator type that should be used.

An accumulator is a functor that uses a pair of special iterators to step through a list of slots and calculate a return value from the results of the slot invocations. The iterators' operator*() executes the slot. The return value is buffered, so that in an expression like

a = (*i) * (*i);

the slot is executed only once.

Example 1:
This accumulator calculates the arithmetic mean value:
struct arithmetic_mean_accumulator
{
template<typename T_iterator>
double operator()(T_iterator first, T_iterator last) const
{
double value_ = 0;
int n_ = 0;
for (; first != last; ++first, ++n_)
value_ += *first;
return value_ / n_;
}
};
decltype(auto) operator()(type_trait_take_t< T_arg >... a) const
Triggers the emission of the signal (see emit()).
Definition: signal.h:800
Example 2:
This accumulator stops signal emission when a slot returns zero:
struct interruptable_accumulator
{
template<typename T_iterator>
bool operator()(T_iterator first, T_iterator last) const
{
for (; first != last; ++first, ++n_)
if (!*first) return false;
return true;
}
};
Since libsigc++ 3.4:

Constructor & Destructor Documentation

◆ accumulated() [1/2]

template <typename T_return , typename... T_arg>
template <typename T_accumulator >
sigc::trackable_signal< T_return(T_arg...)>::accumulated< T_accumulator >::accumulated ( )
default

◆ accumulated() [2/2]

template <typename T_return , typename... T_arg>
template <typename T_accumulator >
sigc::trackable_signal< T_return(T_arg...)>::accumulated< T_accumulator >::accumulated ( const accumulated &  src)
inline