CheeseEngine
A 2D Game Engine
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
EventQueue< T > Class Template Reference

Typed event queue for a specific event type T. More...

#include <EventBus.hpp>

Inheritance diagram for EventQueue< T >:
[legend]
Collaboration diagram for EventQueue< T >:
[legend]

Public Member Functions

void Dispatch () override
 Moves events to a local buffer, clears the original queue, and notifies subscribers.
 
void RemoveHandler (HandlerId id) override
 Erases a callback from the handlers list if the ID matches.
 
- Public Member Functions inherited from IEventQueue
virtual ~IEventQueue ()=default
 

Public Attributes

std::vector< T > queue
 Accumulated events for the current frame.
 
std::vector< std::pair< HandlerId, std::function< void(const T &)> > > handlers
 Registered callbacks paired with their IDs.
 

Detailed Description

template<typename T>
class EventQueue< T >

Typed event queue for a specific event type T.

Template Parameters
T: The type of the event being handled

Member Function Documentation

◆ Dispatch()

template<typename T >
void EventQueue< T >::Dispatch ( )
inlineoverridevirtual

Moves events to a local buffer, clears the original queue, and notifies subscribers.

Note
Moving the queue prevents iterator invalidation if Publish is called recursively inside a handler
Parameters
None
Return values
None

Implements IEventQueue.

◆ RemoveHandler()

template<typename T >
void EventQueue< T >::RemoveHandler ( HandlerId  id)
inlineoverridevirtual

Erases a callback from the handlers list if the ID matches.

Parameters
id: The unique identifier of the handler to remove
Return values
None

Implements IEventQueue.

Member Data Documentation

◆ handlers

template<typename T >
std::vector<std::pair<HandlerId, std::function<void(const T&)> > > EventQueue< T >::handlers

Registered callbacks paired with their IDs.

◆ queue

template<typename T >
std::vector<T> EventQueue< T >::queue

Accumulated events for the current frame.


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