SignalBase is an implementation of the observer pattern, through the use of an emitting object and slots that are connected to the signal and called with supplied arguments when a signal is emitted. More...
#include <wpi/Signal.h>
Public Types | |
using | arg_list = trait::typelist<T...> |
using | ext_arg_list = trait::typelist<Connection&, T...> |
Public Member Functions | |
SignalBase () noexcept | |
~SignalBase () | |
SignalBase (const SignalBase &)=delete | |
SignalBase & | operator= (const SignalBase &)=delete |
SignalBase (SignalBase &&o) | |
SignalBase & | operator= (SignalBase &&o) |
template<typename... A> | |
void | operator() (A &&... a) const |
Emit a signal. | |
template<typename Callable > | |
void | connect (Callable &&c) |
Connect a callable of compatible arguments. | |
template<typename Callable > | |
std::enable_if_t< trait::is_callable_v< arg_list, Callable >, Connection > | connect_connection (Callable &&c) |
Connect a callable of compatible arguments, returning a Connection. | |
template<typename Callable > | |
std::enable_if_t< trait::is_callable_v< ext_arg_list, Callable >, Connection > | connect_extended (Callable &&c) |
Connect a callable with an additional Connection argument. | |
template<typename Pmf , typename Ptr > | |
std::enable_if_t< trait::is_callable_v< arg_list, Pmf, Ptr > &&!trait::is_weak_ptr_compatible_v< Ptr >, Connection > | connect (Pmf &&pmf, Ptr &&ptr) |
Overload of connect for pointers over member functions. | |
template<typename Pmf , typename Ptr > | |
std::enable_if_t< trait::is_callable_v< ext_arg_list, Pmf, Ptr > &&!trait::is_weak_ptr_compatible_v< Ptr >, Connection > | connect_extended (Pmf &&pmf, Ptr &&ptr) |
Overload of connect for pointer over member functions and. | |
template<typename Pmf , typename Ptr > | |
std::enable_if_t<!trait::is_callable_v< arg_list, Pmf > &&trait::is_weak_ptr_compatible_v< Ptr >, Connection > | connect (Pmf &&pmf, Ptr &&ptr) |
Overload of connect for lifetime object tracking and automatic disconnection. | |
template<typename Callable , typename Trackable > | |
std::enable_if_t< trait::is_callable_v< arg_list, Callable > &&trait::is_weak_ptr_compatible_v< Trackable >, Connection > | connect (Callable &&c, Trackable &&ptr) |
Overload of connect for lifetime object tracking and automatic disconnection. | |
template<typename... CallArgs> | |
ScopedConnection | connect_scoped (CallArgs &&...args) |
Creates a connection whose duration is tied to the return object Use the same semantics as connect. | |
void | disconnect_all () |
Disconnects all the slots Safety: Thread safety depends on locking policy. | |
void | block () noexcept |
Blocks signal emission Safety: thread safe. | |
void | unblock () noexcept |
Unblocks signal emission Safety: thread safe. | |
bool | blocked () const noexcept |
Tests blocking state of signal emission. | |
SignalBase is an implementation of the observer pattern, through the use of an emitting object and slots that are connected to the signal and called with supplied arguments when a signal is emitted.
wpi::SignalBase is the general implementation, whose locking policy must be set in order to decide thread safety guarantees. wpi::Signal and wpi::Signal_st are partial specializations for multi-threaded and single-threaded use.
It does not allow slots to return a value.
Lockable | a lock type to decide the lock policy |
T... | the argument types of the emitting and slots functions. |
using wpi::sig::SignalBase< Lockable, T >::arg_list = trait::typelist<T...> |
using wpi::sig::SignalBase< Lockable, T >::ext_arg_list = trait::typelist<Connection&, T...> |
|
inlinenoexcept |
|
inline |
|
delete |
|
inline |
|
inlinenoexcept |
Blocks signal emission Safety: thread safe.
|
inlinenoexcept |
Tests blocking state of signal emission.
|
inline |
Connect a callable of compatible arguments.
Effect: Creates and stores a new slot responsible for executing the supplied callable for every subsequent signal emission. Safety: Thread-safety depends on locking policy.
c | a callable |
|
inline |
Overload of connect for lifetime object tracking and automatic disconnection.
Trackable must be convertible to an object following a loose form of weak pointer concept, by implementing the ADL-detected conversion function to_weak().
This overload covers the case of a standalone callable and unrelated trackable object.
Note: only weak references are stored, a slot does not extend the lifetime of a suppied object.
c | a callable |
ptr | a trackable object pointer |
|
inline |
Overload of connect for pointers over member functions.
pmf | a pointer over member function |
ptr | an object pointer |
|
inline |
Overload of connect for lifetime object tracking and automatic disconnection.
Ptr must be convertible to an object following a loose form of weak pointer concept, by implementing the ADL-detected conversion function to_weak().
This overload covers the case of a pointer over member function and a trackable pointer of that class.
Note: only weak references are stored, a slot does not extend the lifetime of a suppied object.
pmf | a pointer over member function |
ptr | a trackable object pointer |
|
inline |
Connect a callable of compatible arguments, returning a Connection.
Effect: Creates and stores a new slot responsible for executing the supplied callable for every subsequent signal emission. Safety: Thread-safety depends on locking policy.
c | a callable |
|
inline |
Connect a callable with an additional Connection argument.
The callable's first argument must be of type Connection. This overload the callable to manage it's own connection through this argument.
c | a callable |
|
inline |
Overload of connect for pointer over member functions and.
pmf | a pointer over member function |
ptr | an object pointer |
|
inline |
Creates a connection whose duration is tied to the return object Use the same semantics as connect.
|
inline |
Disconnects all the slots Safety: Thread safety depends on locking policy.
|
inline |
Emit a signal.
Effect: All non blocked and connected slot functions will be called with supplied arguments. Safety: With proper locking (see wpi::Signal), emission can happen from multiple threads simultaneously. The guarantees only apply to the signal object, it does not cover thread safety of potentially shared state used in slot functions.
a | arguments to emit |
|
delete |
|
inline |
|
inlinenoexcept |
Unblocks signal emission Safety: thread safe.