Rose
Public Types | Public Member Functions | Protected Attributes | List of all members
rose::Signal< Args > Class Template Reference

The transmitter portion of a Signal-Slot transmitter receiver pair. More...

#include <Signals.h>

Public Types

using signal_function = std::function< void(Args...)>
 

Public Member Functions

 operator bool ()
 
void clean ()
 Groom the Slot list.
 
void connect (std::shared_ptr< Slot< Args... >> &slot)
 Connect a Slot to the Signal only if it has not already been connected. More...
 
void disconnect (std::shared_ptr< Slot< Args... >> &slot)
 Disconnect a Slot from the Signal, if it is connected. More...
 
void transmit (Args ... args)
 Transmit the Signal data to all connected and non-expired Slots. More...
 

Protected Attributes

std::vector< std::weak_ptr< Slot< Args... > > > callList {}
 

Detailed Description

template<typename ... Args>
class rose::Signal< Args >

The transmitter portion of a Signal-Slot transmitter receiver pair.

Template Parameters
ArgsThe signature of the Signal.

The signature of the Signal also sets the signature of the transmit() function. Signals and Slots must share the same signature to be connected. The Signal maintains a list of std::weak_ptr to the Slots with which is is connected. This list is groomed to remove expired Slots on each call to transmit, connect and disconnect.

Member Function Documentation

◆ connect()

template<typename ... Args>
void rose::Signal< Args >::connect ( std::shared_ptr< Slot< Args... >> &  slot)
inline

Connect a Slot to the Signal only if it has not already been connected.

Parameters
slot

◆ disconnect()

template<typename ... Args>
void rose::Signal< Args >::disconnect ( std::shared_ptr< Slot< Args... >> &  slot)
inline

Disconnect a Slot from the Signal, if it is connected.

Parameters
slotThe Slot to disconnect.

◆ transmit()

template<typename ... Args>
void rose::Signal< Args >::transmit ( Args ...  args)
inline

Transmit the Signal data to all connected and non-expired Slots.

Parameters
argsThe signature of the Signal data.

The documentation for this class was generated from the following file: