OpenSourceSimWheelESP32
Open-source wireless steering wheel/button box for ESP32 boards
Loading...
Searching...
No Matches
static_event< Args > Class Template Reference

Publish-subscribe event (forever subscribed) More...

#include <InternalTypes.hpp>

Public Types

using type = static_event<Args...>
 This type.
 
using callback_type = typename ::std::add_pointer<void(Args...)>::type
 Callback type for subscribers.
 

Public Member Functions

void subscribe (callback_type callback) noexcept
 Subscribe forever.
 
void clear () noexcept
 Clear all subscriptions.
 
void operator() (const Args &...args)
 Dispatch event to all subscribed callbacks.
 
void operator() (const Args &...args) const
 Dispatch event to all subscribed callbacks (const)
 
::std::size_t subscribed ()
 Get the number of subscribed callbacks.
 
typeoperator= (type &&source) noexcept
 Move-assignment.
 
typeoperator= (const type &source) noexcept
 Copy-assignment.
 
constexpr static_event () noexcept=default
 Default constructor.
 
 static_event (const type &source)
 Copy constructor.
 
 static_event (type &&source)
 Move constructor.
 
constexpr bool operator== (const type &other) const noexcept
 Equality operator.
 

Detailed Description

template<class... Args>
class static_event< Args >

Publish-subscribe event (forever subscribed)

Warning
Not thread safe. All subscribers must subscribe in the same thread. Subscription must not take place while the event is dispatching in another thread.
Author
Ángel Fernández Pineda. Madrid. Spain. 2026. https://github.com/afpineda/cpp-publish-subscribe-observable
Template Parameters
ArgsCallback argument types

Definition at line 518 of file InternalTypes.hpp.

Member Typedef Documentation

◆ callback_type

template<class... Args>
using static_event< Args >::callback_type = typename ::std::add_pointer<void(Args...)>::type

Callback type for subscribers.

Definition at line 524 of file InternalTypes.hpp.

◆ type

template<class... Args>
using static_event< Args >::type = static_event<Args...>

This type.

Definition at line 522 of file InternalTypes.hpp.

Constructor & Destructor Documentation

◆ static_event() [1/2]

template<class... Args>
static_event< Args >::static_event ( const type & source)
inline

Copy constructor.

Parameters
sourceInstance to be copied

Definition at line 619 of file InternalTypes.hpp.

◆ static_event() [2/2]

template<class... Args>
static_event< Args >::static_event ( type && source)
inline

Move constructor.

Parameters
sourceRvalue

Definition at line 629 of file InternalTypes.hpp.

Member Function Documentation

◆ clear()

template<class... Args>
void static_event< Args >::clear ( )
inlinenoexcept

Clear all subscriptions.

Warning
To be used exclusively in test units.

Definition at line 543 of file InternalTypes.hpp.

◆ operator()() [1/2]

template<class... Args>
void static_event< Args >::operator() ( const Args &... args)
inline

Dispatch event to all subscribed callbacks.

Parameters
argsEvent data

Definition at line 553 of file InternalTypes.hpp.

◆ operator()() [2/2]

template<class... Args>
void static_event< Args >::operator() ( const Args &... args) const
inline

Dispatch event to all subscribed callbacks (const)

Parameters
argsEvent data

Definition at line 566 of file InternalTypes.hpp.

◆ operator=() [1/2]

template<class... Args>
type & static_event< Args >::operator= ( const type & source)
inlinenoexcept

Copy-assignment.

Parameters
sourceInstance to be copied
Returns
type& Reference to this instance

Definition at line 602 of file InternalTypes.hpp.

◆ operator=() [2/2]

template<class... Args>
type & static_event< Args >::operator= ( type && source)
inlinenoexcept

Move-assignment.

Parameters
sourceRvalue
Returns
type& Reference to this instance

Definition at line 590 of file InternalTypes.hpp.

◆ operator==()

template<class... Args>
bool static_event< Args >::operator== ( const type & other) const
inlineconstexprnoexcept

Equality operator.

Note
Mostly for testing purposes.
Parameters
otherInstance to compare to
Returns
true If equal
false If not equal

Definition at line 643 of file InternalTypes.hpp.

◆ subscribe()

template<class... Args>
void static_event< Args >::subscribe ( callback_type callback)
inlinenoexcept

Subscribe forever.

Parameters
callbackCallback function to be called on event dispatch

Definition at line 531 of file InternalTypes.hpp.

◆ subscribed()

template<class... Args>
::std::size_t static_event< Args >::subscribed ( )
inline

Get the number of subscribed callbacks.

Returns
::std::size_t Count of subscribed callbacks

Definition at line 579 of file InternalTypes.hpp.


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