mc_rtc  2.14.0
mc_rtc::Signal< ArgsT > Struct Template Reference

#include <mc_rtc/SignalSlot.h>

Classes

struct  Proxy
 

Public Types

using SignalT = Signal< ArgsT... >
 
using SlotT = Slot< ArgsT... >
 
using CallbackT = std::function< void(ArgsT...)>
 

Public Member Functions

 Signal ()=default
 
template<typename Callable >
SlotT connect (Callable &&callback)
 
void signal (ArgsT... args)
 

Public Attributes

friend SlotT
 

Protected Member Functions

void disconnect (size_t idx)
 

Protected Attributes

std::vector< CallbackTcallbacks_
 
size_t next_slot_ = 0
 

Detailed Description

template<typename... ArgsT>
struct mc_rtc::Signal< ArgsT >

A signal class

Provides a way to connect to the signal, i.e. register a callback that will be called whenever the signal is raised via the signal method.

You can use this mechanism in your own code (controller, state, interface, observer...) however you must be aware of the following assumptions that are true to all usage within mc_rtc:

  • the signal emitter outlives all subscribers
  • the signal is only emitted on the main execution thread
  • the signal is handled as soon as it is emitted
Template Parameters
ArgsTArguments of the signal callback

Member Typedef Documentation

◆ CallbackT

template<typename... ArgsT>
using mc_rtc::Signal< ArgsT >::CallbackT = std::function<void(ArgsT...)>

◆ SignalT

template<typename... ArgsT>
using mc_rtc::Signal< ArgsT >::SignalT = Signal<ArgsT...>

◆ SlotT

template<typename... ArgsT>
using mc_rtc::Signal< ArgsT >::SlotT = Slot<ArgsT...>

Constructor & Destructor Documentation

◆ Signal()

template<typename... ArgsT>
mc_rtc::Signal< ArgsT >::Signal ( )
default

Member Function Documentation

◆ connect()

template<typename... ArgsT>
template<typename Callable >
SlotT mc_rtc::Signal< ArgsT >::connect ( Callable &&  callback)
inline

Connect a callback to the signal and returns a connected slot

Parameters
callbackAny callback that will match
Template Parameters
ArgsT

◆ disconnect()

template<typename... ArgsT>
void mc_rtc::Signal< ArgsT >::disconnect ( size_t  idx)
inlineprotected

◆ signal()

template<typename... ArgsT>
void mc_rtc::Signal< ArgsT >::signal ( ArgsT...  args)
inline

Trigger a signal with the provided arguments

\params args Arguments passed to subscribers

Member Data Documentation

◆ callbacks_

template<typename... ArgsT>
std::vector<CallbackT> mc_rtc::Signal< ArgsT >::callbacks_
protected

◆ next_slot_

template<typename... ArgsT>
size_t mc_rtc::Signal< ArgsT >::next_slot_ = 0
protected

◆ SlotT

template<typename... ArgsT>
friend mc_rtc::Signal< ArgsT >::SlotT

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