libGimbal 0.1.0
C17-Based Extended Standard Library and Cross-Language Runtime Framework
Loading...
Searching...
No Matches
gimbal_ievent_receiver.h
Go to the documentation of this file.
1/*! \file
2 * \brief GblIEventReciever abstract event listener interface
3 * \ingroup interfaces
4 *
5 * This file provides the interface type definition and API for
6 * listening to and receiving GblEvents.
7 *
8 * \author 2025 Falco Girgis
9 * \copyright MIT License
10 */
11#ifndef GIMBAL_IEVENT_RECEIVER_H
12#define GIMBAL_IEVENT_RECEIVER_H
13
15#include "../instances/gimbal_instance.h"
16
17/*! \name Type System
18 * \brief Type UUID and cast operators.
19 * @{
20 */
21#define GBL_IEVENT_RECEIVER_TYPE GBL_TYPEID(GblIEventReceiver) //!< Type UUID for GblIEventReceiver.
22#define GBL_IEVENT_RECEIVER(self) GBL_CAST(GblIEventReceiver, self) //!< Casts a GblInstance to a GblIEventReceiver.
23#define GBL_IEVENT_RECEIVER_CLASS(klass) GBL_CLASS_CAST(GblIEventReceiver, klass) //!< Casts a GblClass to a GblIEventReceiverClass.
24#define GBL_IEVENT_RECEIVER_CLASSOF(self) GBL_CLASSOF(GblIEventReceiver, self) //!< Extracts a GblIEventReceiverClass from a GblInstance.
25//! @}
26
27#define GBL_SELF_TYPE GblIEventReceiver
28
30
32
33/*! \struct GblIEventReceiverClass
34 * \extends GblInterface
35 * \brief GblClass structure for GblIEventReceiver
36 *
37 * A GblIEventReceiver is a type implementing the basic interface required
38 * for event processing. There are typically two different types of receivers:
39 * - Handlers: intended recipients of a GblEvent
40 * - Filters: observers which can intercept events not directly sent to them.
41 *
42 * The same interface can be used to implement both types of receivers, depending
43 * on whether the self parameter is the same instance which is the destination
44 * receiver of GblIEventReceiverClass::pFnReceiveEvent().
45 *
46 * Once received, a GblEvent may either be ignored, allowing to potentially
47 * propagate onward through other chained receivers, or it may be "accepted,"
48 * which terminates its propagation and marks it as handled.
49 *
50 * \sa GblEvent, GblObject
51 */
52GBL_INTERFACE_DERIVE(GblIEventReceiver)
53 //! Invoked any time an event is received or intercepted by the given instance.
54 GBL_RESULT (*pFnReceiveEvent)(GBL_SELF, GblIEventReceiver* pDest, GblEvent* pEvent);
56
57//! Returns the GblType UUID associated with the GBL_IEVENT_RECEIVER_TYPE.
59
60//! Forwards the given event, sent to the given destination, to the current receiver.
62 GblIEventReceiver* pDest,
63 GblEvent* pEvent) GBL_NOEXCEPT;
64
66
67#undef GBL_SELF_TYPE
68
69#endif // GIMBAL_IEVENT_HANDLER_H
#define GBL_NOEXCEPT
#define GBL_DECLS_BEGIN
#define GBL_FORWARD_DECLARE_STRUCT(S)
#define GBL_TYPEID(instanceStruct)
#define GBL_INTERFACE_END
#define GBL_INTERFACE_DERIVE(...)
#define GBL_EXPORT
GblType GblIEventReceiver_type(void)
Returns the GblType UUID associated with the GBL_IEVENT_RECEIVER_TYPE.
GBL_RESULT GblIEventReceiver_receiveEvent(GblIEventReceiver *pSelf, GblIEventReceiver *pDest, GblEvent *pEvent)
Forwards the given event, sent to the given destination, to the current receiver.
uintptr_t GblType
Meta Type UUID.
Definition gimbal_type.h:52