libGimbal 0.1.0
C17-Based Extended Standard Library and Cross-Language Runtime Framework
Loading...
Searching...
No Matches
gimbal_signal_closure.h
Go to the documentation of this file.
1/*! \file
2 * \ingroup signals
3 * \brief GblSignalClosure, signal-emitting closurure, and API
4 *
5 * This file contains the GblSignalClosure type and its
6 * associated methods. It is used to forward a generic function
7 * invocation to a signal emission, which can then be received
8 * again by any GblClosure instances connected to the signal.
9 *
10 * \author 2023 Falco Girgis
11 * \copyright MIT License
12 */
13#ifndef GIMBAL_SIGNAL_CLOSURE_H
14#define GIMBAL_SIGNAL_CLOSURE_H
15
16#include "gimbal_closure.h"
17
18#define GBL_SIGNAL_CLOSURE_TYPE (GBL_TYPEID(GblSignalClosure))
19
20#define GBL_SIGNAL_CLOSURE(self) (GBL_CAST(GblSignalClosure, self))
21#define GBL_SIGNAL_CLOSURE_CLASS(klass) (GBL_CLASS_CAST(GblSignalClosure, klass))
22#define GBL_SIGNAL_CLOSURE_GET_CLASS(self) (GBL_CLASSOF(GblSignalClosure, self))
23
24#define GBL_SELF_TYPE GblSignalClosure
25
27
28/*! \struct GblSignalClosureClass
29 * \extends GblClosureClass
30 * \brief GblClass type for GblSignalClosure
31 *
32 * No public members.
33 *
34 * \sa GblSignalClosure
35 */
36GBL_CLASS_DERIVE_EMPTY(GblSignalClosure, GblClosure)
37
38/*! \struct GblSignalClosure
39 * \extends GblClosure
40 * \ingroup signals
41 * \brief Closure type for invoking signals
42 *
43 * GblSignalClosure is a closure type which marshals its
44 * arguments into a signal invocation. The first argument
45 * of the invoke function is expected to be the instance
46 * which emits the signal.
47 */
50 GblQuark signalName; //!< PRIVATE: Name of the signal to forward arguments to
53
54//! Returns the GblType UUID associated with GblSignalClosure
56
57//! Creates a new GblSignalClosure, with the given \p pSignalName, capturing the given \p pUserdata
58GBL_EXPORT GblSignalClosure* GblSignalClosure_create (const char* pSignalName,
59 void* pUserdata) GBL_NOEXCEPT;
60
61/*! \name Accessor Method(s)
62 * \brief Setter methods for GblSignalClosure
63 * \relatesalso GblSignalClosure
64 * @{
65 */
66//! Sets the signal for the closure to invoke to the given \p pSignalName
67GBL_EXPORT GBL_RESULT GblSignalClosure_setSignal (GBL_SELF, const char* pSignalName) GBL_NOEXCEPT;
68//! @}
69
71
72#undef GBL_SELF_TYPE
73
74#endif // GIMBAL_SIGNAL_CLOSURE_H
#define GBL_CLASS_CAST(cType, klass)
#define GBL_NOEXCEPT
#define GBL_DECLS_BEGIN
#define GBL_TYPEID(instanceStruct)
#define GBL_INSTANCE_DERIVE(derivedInstance, baseInstance)
#define GBL_PRIVATE_BEGIN
#define GBL_INSTANCE_END
#define GBL_CLASS_DERIVE_EMPTY(...)
#define GBL_EXPORT
#define GBL_PRIVATE_END
Private data structure.
#define GBL_CLASSOF(cType, self)
#define GBL_CAST(cType, self)
GblType GblSignalClosure_type(void)
Returns the GblType UUID associated with GblSignalClosure.
GblSignalClosure * GblSignalClosure_create(const char *pSignalName, void *pUserdata)
Creates a new GblSignalClosure, with the given pSignalName, capturing the given pUserdata.
uintptr_t GblType
Meta Type UUID.
Definition gimbal_type.h:51
uintptr_t GblQuark
Uniquely identifiable interned string type.
Closure type for invoking signals.
GBL_RESULT GblSignalClosure_setSignal(GblSignalClosure *pSelf, const char *pSignalName)
Sets the signal for the closure to invoke to the given pSignalName.
GblQuark signalName
PRIVATE: Name of the signal to forward arguments to.