gwenhywfar  4.3.1
Modules | Typedefs
Module for Signals and Slots
Basic Stuff

Basic signal handling. More...

Modules

 Signals
 

Signals.


Typedefs

typedef struct GWEN_SIGNAL GWEN_SIGNAL
typedef struct GWEN_SIGNALOBJECT GWEN_SIGNALOBJECT
typedef struct GWEN_SLOT GWEN_SLOT
typedef int(* GWEN_SLOT_FUNCTION )(GWEN_SLOT *slot, void *userData, void *pArg1, void *pArg2, int iArg3, int iArg4)

SignalObject

GWENHYWFAR_API GWEN_SIGNALOBJECTGWEN_SignalObject_new (void)
GWENHYWFAR_API void GWEN_SignalObject_free (GWEN_SIGNALOBJECT *so)
GWENHYWFAR_API GWEN_SIGNALGWEN_SignalObject_FindSignal (const GWEN_SIGNALOBJECT *so, const char *name, const char *typeOfArg1, const char *typeOfArg2)
GWENHYWFAR_API GWEN_SLOTGWEN_SignalObject_FindSlot (const GWEN_SIGNALOBJECT *so, const char *name, const char *typeOfArg1, const char *typeOfArg2)
GWENHYWFAR_API void GWEN_SignalObject_RemoveForDerivedType (GWEN_SIGNALOBJECT *so, const char *derivedType)
GWENHYWFAR_API GWEN_SIGNALGWEN_Signal_new (GWEN_SIGNALOBJECT *so, const char *derivedType, const char *name, const char *typeOfArg1, const char *typeOfArg2)
GWENHYWFAR_API void GWEN_Signal_free (GWEN_SIGNAL *sig)
GWENHYWFAR_API GWEN_SIGNALOBJECTGWEN_Signal_GetSignalObject (const GWEN_SIGNAL *sig)
GWENHYWFAR_API int GWEN_Signal_Connect (GWEN_SIGNAL *sig, GWEN_SLOT *slot)
GWENHYWFAR_API int GWEN_Signal_Disconnect (GWEN_SIGNAL *sig, GWEN_SLOT *slot)
GWENHYWFAR_API int GWEN_Signal_Emit (GWEN_SIGNAL *sig, void *pArg1, void *pArg2, int iArg3, int iArg4)

Detailed Description

Basic signal handling.

This module introduces a simple signal-slot framework. Signals have a fixed list of arguments:

The actual type of the void pointer is defined by the signal and corresponding slot(s): Gwen checks the type at runtime and refuses to connect signals with slots which define this pointer to be of a different type. Any signal can be connected to any number of matching slots.

The central object in this framework is GWEN_SIGNALOBJECT. It holds a list of signals and slots for a given object.


Typedef Documentation

typedef struct GWEN_SIGNAL GWEN_SIGNAL

Definition at line 67 of file gwensignal.h.

Definition at line 65 of file gwensignal.h.

typedef struct GWEN_SLOT GWEN_SLOT

Definition at line 69 of file gwensignal.h.

typedef int(* GWEN_SLOT_FUNCTION)(GWEN_SLOT *slot, void *userData, void *pArg1, void *pArg2, int iArg3, int iArg4)

This is the prototype for the slot function. If there is a problem in the function it should return 1, otherwise 0.

Definition at line 76 of file gwensignal.h.


Function Documentation

GWENHYWFAR_API int GWEN_Signal_Emit ( GWEN_SIGNAL sig,
void *  pArg1,
void *  pArg2,
int  iArg3,
int  iArg4 
)

This function calls the slot function of all connected slots. If any of the slot functions called returns with code 1 then this function will return 1, too. Otherwise 0 is returned. This means that this function will only return 0 if every called slot function returns 0.

Definition at line 454 of file gwensignal.c.

References DBG_DEBUG, and GWEN_LOGDOMAIN.

Definition at line 383 of file gwensignal.c.

GWENHYWFAR_API GWEN_SIGNAL* GWEN_Signal_new ( GWEN_SIGNALOBJECT so,
const char *  derivedType,
const char *  name,
const char *  typeOfArg1,
const char *  typeOfArg2 
)
GWENHYWFAR_API GWEN_SIGNAL* GWEN_SignalObject_FindSignal ( const GWEN_SIGNALOBJECT so,
const char *  name,
const char *  typeOfArg1,
const char *  typeOfArg2 
)

Definition at line 110 of file gwensignal.c.

References GWEN_SignalObject__findSignal(), and GWEN_SignalObject_MkTypeId().

GWENHYWFAR_API GWEN_SLOT* GWEN_SignalObject_FindSlot ( const GWEN_SIGNALOBJECT so,
const char *  name,
const char *  typeOfArg1,
const char *  typeOfArg2 
)

Definition at line 162 of file gwensignal.c.

References GWEN_SignalObject__findSlot(), and GWEN_SignalObject_MkTypeId().

Definition at line 46 of file gwensignal.c.

References GWEN_NEW_OBJECT.

GWENHYWFAR_API void GWEN_SignalObject_RemoveForDerivedType ( GWEN_SIGNALOBJECT so,
const char *  derivedType 
)

This function removes all signals and slots for the given derived type. This function can be used from within the FREEDATA function of the GWEN_INHERIT framework.

Definition at line 213 of file gwensignal.c.

References GWEN_Signal_free(), GWEN_SignalObject_MkTypeId(), and GWEN_Slot_free().