Lysa  0.0
Lysa 3D Engine
Signal Class Reference

Detailed Description

Signal helper used by Object and engine nodes.

  • Store a list of handlers and invoke them when a signal is emitted.
  • Preserve the order of connections: handlers are called in the order they were connected.

Notes:

  • Thread-safety: Signal is not thread-safe. If accessed from multiple threads, external synchronization is required around connect() and emit().
  • Lifetime: Handlers are stored by value (std::function). Ensure any captured objects outlive the signal emission or capture them safely by std::weak_ptr.
  • Disconnection: There is no explicit disconnect method at this time.

Public Typedefs

using signal = std::string
 
using Handler = std::function< void (void *)>
 

Public Member Functions

void connect (const Handler &handler)
 
void emit (void *params) const
 

Member Typedef Documentation

using Handler = std::function<void(void*)>

Slot/handler signature invoked on emit(). Parameter is an optional opaque pointer forwarded by the emitter.

using signal = std::string

Type alias for a signal name used as a key by Object and others.

Member Function Documentation

void connect ( const Handler handler)
inline

Connects a handler to this signal.

Handlers are appended and will be invoked in connection order when emit() is called. The callable is copied into internal storage.

void emit ( void *  params) const

Emits the signal by invoking all connected handlers in connection order.

Complexity is O(N) where N is the number of connected handlers. Any exception thrown by a handler will propagate to the caller.

Parameters
paramsOptional opaque pointer forwarded to handlers (may be nullptr).