guillaume 2026.6.1
A C++ UI framework designed for modern desktop and extended reality (XR) applications.
Loading...
Searching...
No Matches
guillaume::EventHandler Class Referenceabstract

Interface of an event source: something that reads platform input and reports it as utility::event::Event objects through a callback. More...

#include <headers/guillaume/event_handler.hpp>

Inheritance diagram for guillaume::EventHandler:
Collaboration diagram for guillaume::EventHandler:

Public Types

using Handler
 The callback type: a function called with each event read from the platform.

Public Member Functions

 EventHandler (void)
 Create an event source with no callback.
virtual ~EventHandler (void)=default
 Virtual destructor.
void setEventCallback (const Handler &callback)
 Choose the function that receives the events.
virtual void pollEvents (void)=0
 Read the events the platform has pending and report each one through the callback.

Protected Member Functions

Handler & getEventCallback (void)
 Get the callback, for pollEvents() to call.

Detailed Description

Interface of an event source: something that reads platform input and reports it as utility::event::Event objects through a callback.

An implementation overrides pollEvents() to read what the platform has pending, convert it and call the callback once per event. The owner sets the callback, typically to forward to event::EventBus::publish.

class MyEventHandler: public guillaume::EventHandler
{
public:
void pollEvents(void) override
{
std::shared_ptr<utility::event::Event> event = readPlatform();
if (event && getEventCallback()) {
}
}
};
Interface of an event source: something that reads platform input and reports it as utility::event::E...
virtual void pollEvents(void)=0
Read the events the platform has pending and report each one through the callback.
Handler & getEventCallback(void)
Get the callback, for pollEvents() to call.
Delivery of engine events to the systems that subscribed to them.
Definition event_bus.hpp:34
Note
Application does not use this class: it receives its events from utility::Engine (setEventCallback and pollEvents), which has the same shape.
See also
event::EventBus

Definition at line 65 of file event_handler.hpp.

Member Typedef Documentation

◆ Handler

Initial value:
std::function<void(std::shared_ptr<utility::event::Event> &)>

The callback type: a function called with each event read from the platform.

It receives the shared pointer by reference and may move from it.

Definition at line 76 of file event_handler.hpp.

Member Function Documentation

◆ getEventCallback()

Handler & guillaume::EventHandler::getEventCallback ( void )
protected

Get the callback, for pollEvents() to call.

Returns
Reference to the callback. It is an empty function until setEventCallback() is called: test it before calling it.

◆ pollEvents()

virtual void guillaume::EventHandler::pollEvents ( void )
pure virtual

Read the events the platform has pending and report each one through the callback.

Implemented by each event source. It is meant to be called once per frame and to return without waiting when nothing is pending.

◆ setEventCallback()

void guillaume::EventHandler::setEventCallback ( const Handler & callback)

Choose the function that receives the events.

Parameters
callbackThe function pollEvents() calls once per event. It replaces the previous one; an empty function removes it.

The documentation for this class was generated from the following file: