libpromeki main
PROfessional MEdia toolKIt
 
Loading...
Searching...
No Matches
Event Class Reference

Base class for the event system. More...

#include <event.h>

Inheritance diagram for Event:

Public Types

using Type = uint32_t
 Integer type used to identify event kinds.
 

Public Member Functions

 Event (Type type)
 Constructs an Event with the given type.
 
virtual ~Event ()=default
 Virtual destructor.
 
Type type () const
 Returns the type identifier for this event.
 
bool isAccepted () const
 Returns whether this event has been accepted.
 
void accept ()
 Marks the event as accepted.
 
void ignore ()
 Marks the event as ignored (not accepted).
 

Static Public Member Functions

static Type registerType ()
 Allocates and returns a unique event type ID.
 

Static Public Attributes

static constexpr Type InvalidType = 0
 Sentinel value representing an invalid or unset event type.
 
static const Type Timer
 Event type for TimerEvent.
 
static const Type DeferredCall
 Event type for deferred callable delivery.
 
static const Type SignalEvent
 Event type for cross-thread signal dispatch.
 
static const Type Quit
 Event type requesting an EventLoop to quit.
 

Detailed Description

Base class for the event system.

Events carry a type identifier and an accepted/ignored state. Type IDs are allocated at runtime by registerType(), which uses a lock-free atomic counter so that registration is thread-safe and zero-overhead at dispatch time (integer comparison).

Built-in event types (Timer, DeferredCall, Signal, Quit) are registered as file-scope statics in event.cpp. User-defined types should be registered with Event::registerType().

Constructor & Destructor Documentation

◆ Event()

Event::Event ( Type  type)
inline

Constructs an Event with the given type.

Parameters
typeThe event type identifier.

Member Function Documentation

◆ accept()

void Event::accept ( )
inline

Marks the event as accepted.

An accepted event will not be propagated further by the event delivery machinery.

◆ ignore()

void Event::ignore ( )
inline

Marks the event as ignored (not accepted).

An ignored event may be propagated to a parent handler.

◆ isAccepted()

bool Event::isAccepted ( ) const
inline

Returns whether this event has been accepted.

Returns
true if accepted, false if ignored.

◆ registerType()

static Type Event::registerType ( )
static

Allocates and returns a unique event type ID.

Each call returns a new, never-before-used ID. Thread-safe.

Returns
A unique Type value.

◆ type()

Type Event::type ( ) const
inline

Returns the type identifier for this event.

Returns
The event type.

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