r-type  0.0.0
R-Type main
Loading...
Searching...
No Matches
utl::Event Class Reference

Event structure for inter-component communication. More...

#include <Event.hpp>

+ Collaboration diagram for utl::Event:

Public Member Functions

 Event ()
 Default constructor with current timestamp.
 
 Event (EventType t)
 Constructor with event type.
 
 Event (EventType t, const std::vector< std::uint8_t > &d)
 Constructor with event type and data.
 
 Event (EventType t, std::uint32_t src, std::uint32_t tgt=0, EventPriority prio=EventPriority::NORMAL)
 Constructor with all parameters.
 
std::uint64_t getAge () const
 Get event age in milliseconds.
 
bool hasExpired (std::uint64_t maxAgeMs=5000) const
 Check if event has expired.
 
bool isTargeted () const
 Check if event is targeted to a specific component.
 
bool isBroadcast () const
 Check if event is a broadcast.
 

Public Attributes

EventType type
 Type of the event.
 
std::uint32_t sourceId = 0
 ID of the component that sent the event (0 = system)
 
std::uint32_t targetId = 0
 ID of the target component (0 = broadcast)
 
EventPriority priority = EventPriority::NORMAL
 Event priority.
 
std::chrono::steady_clock::time_point timestamp
 Timestamp when event was created.
 
std::vector< std::uint8_t > data
 Serialized event data.
 

Detailed Description

Event structure for inter-component communication.

Definition at line 88 of file Event.hpp.

Constructor & Destructor Documentation

◆ Event() [1/4]

utl::Event::Event ( )
inline

Default constructor with current timestamp.

Definition at line 101 of file Event.hpp.

◆ Event() [2/4]

utl::Event::Event ( EventType t)
inlineexplicit

Constructor with event type.

Parameters
tEvent type

Definition at line 107 of file Event.hpp.

◆ Event() [3/4]

utl::Event::Event ( EventType t,
const std::vector< std::uint8_t > & d )
inline

Constructor with event type and data.

Parameters
tEvent type
dEvent data

Definition at line 114 of file Event.hpp.

◆ Event() [4/4]

utl::Event::Event ( EventType t,
std::uint32_t src,
std::uint32_t tgt = 0,
EventPriority prio = EventPriority::NORMAL )
inline

Constructor with all parameters.

Parameters
tEvent type
srcSource component ID
tgtTarget component ID (0 for broadcast)
prioEvent priority

Definition at line 126 of file Event.hpp.

Member Function Documentation

◆ getAge()

std::uint64_t utl::Event::getAge ( ) const
inline

Get event age in milliseconds.

Returns
Age in milliseconds

Definition at line 135 of file Event.hpp.

References timestamp.

Referenced by hasExpired().

+ Here is the caller graph for this function:

◆ hasExpired()

bool utl::Event::hasExpired ( std::uint64_t maxAgeMs = 5000) const
inline

Check if event has expired.

Parameters
maxAgeMsMaximum age in milliseconds
Returns
True if event has expired

Definition at line 147 of file Event.hpp.

References getAge().

+ Here is the call graph for this function:

◆ isBroadcast()

bool utl::Event::isBroadcast ( ) const
inline

Check if event is a broadcast.

Returns
True if event is broadcast to all components

Definition at line 159 of file Event.hpp.

References targetId.

◆ isTargeted()

bool utl::Event::isTargeted ( ) const
inline

Check if event is targeted to a specific component.

Returns
True if event has a specific target

Definition at line 153 of file Event.hpp.

References targetId.

Member Data Documentation

◆ data

◆ priority

EventPriority utl::Event::priority = EventPriority::NORMAL

Event priority.

Definition at line 94 of file Event.hpp.

◆ sourceId

std::uint32_t utl::Event::sourceId = 0

ID of the component that sent the event (0 = system)

Definition at line 92 of file Event.hpp.

Referenced by utl::EventBus::publish().

◆ targetId

std::uint32_t utl::Event::targetId = 0

ID of the target component (0 = broadcast)

Definition at line 93 of file Event.hpp.

Referenced by isBroadcast(), isTargeted(), and utl::EventBus::updateStats().

◆ timestamp

std::chrono::steady_clock::time_point utl::Event::timestamp

Timestamp when event was created.

Definition at line 95 of file Event.hpp.

Referenced by getAge().

◆ type

EventType utl::Event::type

Type of the event.

Definition at line 91 of file Event.hpp.

Referenced by utl::EventBus::publish().


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