Gooey GUI Library
Loading...
Searching...
No Matches
gooey_signals.h File Reference

Go to the source code of this file.

Classes

struct  GooeySignal_Slot
 A slot representing a linked callback in the signal system. More...
 
struct  GooeySignal
 A signal that can emit events to all linked slots. More...
 

Typedefs

typedef void(* GooeySignal_CallbackFunction) (void *context, void *data)
 Callback function type for signal events.
 
typedef struct GooeySignal_Slot GooeySignal_Slot
 A slot representing a linked callback in the signal system.
 

Functions

GooeySignal GooeySignal_Create (void)
 Creates a new signal object.
 
void GooeySignal_Link (GooeySignal *signal, GooeySignal_CallbackFunction callback, void *context)
 Links a callback function to a signal.
 
void GooeySignal_Emit (GooeySignal *signal, void *data)
 Emits a signal.
 
void GooeySignal_UnLinkAll (GooeySignal *signal)
 Unlinks all callbacks from a signal.
 

Typedef Documentation

◆ GooeySignal_CallbackFunction

typedef void(* GooeySignal_CallbackFunction) (void *context, void *data)

Callback function type for signal events.

This function type is used for the callback that is executed when a signal is emitted. The callback receives a context and data passed from the emitter.

Parameters
contextThe user-defined context passed when linking the callback.
dataThe data passed when emitting the signal.

◆ GooeySignal_Slot

A slot representing a linked callback in the signal system.

A slot contains a callback function, its associated context, and a link to the next slot in a potentially linked list of callbacks.

Function Documentation

◆ GooeySignal_Create()

GooeySignal GooeySignal_Create ( void  )

Creates a new signal object.

Signals are used to manage event handling and callbacks. This function initializes a new signal object with no slots.

Returns
GooeySignal The created signal object with no linked callbacks.

◆ GooeySignal_Emit()

void GooeySignal_Emit ( GooeySignal signal,
void *  data 
)

Emits a signal.

This function triggers the signal, invoking all linked callbacks in the order they were added. Each callback receives the specified data.

Parameters
signalA pointer to the signal to emit.
dataA void pointer to the data passed to all linked callbacks.

◆ GooeySignal_Link()

void GooeySignal_Link ( GooeySignal signal,
GooeySignal_CallbackFunction  callback,
void *  context 
)

Links a callback function to a signal.

This function connects a signal to a specific callback function. When the signal is emitted, the callback function will be executed. The callback is linked to the signal and can be triggered when the signal is emitted.

Parameters
signalA pointer to the signal to which the callback is linked.
callbackThe callback function to execute when the signal is emitted.
contextA user-defined context pointer passed to the callback.

◆ GooeySignal_UnLinkAll()

void GooeySignal_UnLinkAll ( GooeySignal signal)

Unlinks all callbacks from a signal.

Removes all callback functions linked to the specified signal, effectively clearing its event listeners.

Parameters
signalA pointer to the signal from which callbacks should be unlinked.