|
guillaume 2026.6.1
A C++ UI framework designed for modern desktop and extended reality (XR) applications.
|
Hands each engine event to the listeners subscribed to its type. More...
#include <headers/guillaume/event/event_bus.hpp>
Public Types | |
| using | Listener |
| using | ListenerList |
Public Member Functions | |
| EventBus (void)=default | |
| Create a bus with no listener. | |
| ~EventBus (void)=default | |
| Destroy the bus and its listeners. | |
| void | publish (std::shared_ptr< utility::event::Event > event) |
| Call, before returning, every listener subscribed to the exact type of an event. | |
| template<utility::event::InheritFromEvent EventType> | |
| void | subscribe (Listener listener) |
| Add a listener for one event type. | |
Hands each engine event to the listeners subscribed to its type.
Application owns one bus and passes to publish() every input event the engine polls at the start of a frame; the listeners are called at once, in subscription order. The systems do not subscribe directly: they use EventManager (or EventSubscriber), whose listener only queues the event so the system can process it later in the frame, during its phase.
Things to watch out for:
Definition at line 66 of file event_bus.hpp.
Function called with each event of the subscribed type
Definition at line 69 of file event_bus.hpp.
Listeners of one event type, in subscription order
Definition at line 74 of file event_bus.hpp.
| void guillaume::event::EventBus::publish | ( | std::shared_ptr< utility::event::Event > | event | ) |
Call, before returning, every listener subscribed to the exact type of an event.
Nothing happens when the event is null or when its type has no listener. An exception thrown by a listener propagates and the remaining listeners are not called.
| event | The event to deliver. It is shared with the listeners, which may keep it. |
Definition at line 39 of file event_bus.cpp.
| void guillaume::event::EventBus::subscribe | ( | Listener | listener | ) |
Add a listener for one event type.
| EventType | The exact event type to listen to. |
| listener | The function to call with each published event of that type. It receives the event as a base Event pointer and casts it itself. |