Estella 0.113.0
A fast 2D and 3D game engine powered by WebAssembly and ECS
Loading...
Searching...
No Matches
esengine::Signal< void(Args...)> Class Template Reference

Type-safe signal for event publishing. More...

#include <Signal.hpp>

Public Types

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

Public Member Functions

 Signal ()=default
 ~Signal ()=default
 Signal (Signal &&) noexcept=default
Signal & operator= (Signal &&) noexcept=default
 Signal (const Signal &)=delete
Signal & operator= (const Signal &)=delete
void publish (Args... args)
 Publish an event to all subscribers.
usize size () const
 Get the number of active subscribers.
bool empty () const
 Check if there are any subscribers.

Friends

class Sink< Signal< void(Args...)> >

Detailed Description

template<typename... Args>
class esengine::Signal< void(Args...)>

Type-safe signal for event publishing.

Signal<void(Args...)> allows publishing events to multiple subscribers. Connections are managed through the Sink interface which returns RAII Connection handles.

Template Parameters
ArgsThe argument types for the callback
Signal<void(int, float)> signal;
auto conn = Sink(signal).connect([](int a, float b) {
// Handle event
});
signal.publish(42, 3.14f);

Definition at line 62 of file Signal.hpp.

Member Typedef Documentation

◆ Callback

template<typename... Args>
using esengine::Signal< void(Args...)>::Callback = std::function<void(Args...)>

Definition at line 64 of file Signal.hpp.

Constructor & Destructor Documentation

◆ Signal() [1/3]

template<typename... Args>
esengine::Signal< void(Args...)>::Signal ( )
default

Referenced by Signal(), Signal(), operator=(), and operator=().

◆ ~Signal()

template<typename... Args>
esengine::Signal< void(Args...)>::~Signal ( )
default

◆ Signal() [2/3]

template<typename... Args>
esengine::Signal< void(Args...)>::Signal ( Signal< void(Args...)> && )
defaultnoexcept

References Signal().

◆ Signal() [3/3]

template<typename... Args>
esengine::Signal< void(Args...)>::Signal ( const Signal< void(Args...)> & )
delete

References Signal().

Member Function Documentation

◆ empty()

template<typename... Args>
bool esengine::Signal< void(Args...)>::empty ( ) const
inlinenodiscard

Check if there are any subscribers.

Returns
true if no subscribers

Definition at line 110 of file Signal.hpp.

◆ operator=() [1/2]

template<typename... Args>
Signal & esengine::Signal< void(Args...)>::operator= ( const Signal< void(Args...)> & )
delete

References Signal().

◆ operator=() [2/2]

template<typename... Args>
Signal & esengine::Signal< void(Args...)>::operator= ( Signal< void(Args...)> && )
defaultnoexcept

References Signal().

◆ publish()

template<typename... Args>
void esengine::Signal< void(Args...)>::publish ( Args... args)
inline

Publish an event to all subscribers.

Parameters
argsArguments to pass to callbacks

Definition at line 79 of file Signal.hpp.

References publish().

Referenced by publish().

◆ size()

template<typename... Args>
usize esengine::Signal< void(Args...)>::size ( ) const
inlinenodiscard

Get the number of active subscribers.

Returns
Number of subscribers

Definition at line 102 of file Signal.hpp.

◆ Sink< Signal< void(Args...)> >

template<typename... Args>
friend class Sink< Signal< void(Args...)> >
friend

Definition at line 110 of file Signal.hpp.


The documentation for this class was generated from the following file:
  • /home/runner/work/estella/estella/src/esengine/events/Signal.hpp