11#include <unordered_map>
96 std::vector<std::uint8_t>
data;
137 auto now = std::chrono::steady_clock::now();
138 return static_cast<std::uint64_t
>(
139 std::chrono::duration_cast<std::chrono::milliseconds>(now -
timestamp).count());
189 startTime = std::chrono::steady_clock::now();
203 std::chrono::duration_cast<std::chrono::seconds>(std::chrono::steady_clock::now() -
startTime);
204 if (elapsed.count() == 0)
Event statistics structure.
std::uint64_t totalEventsConsumed
Total events consumed.
std::unordered_map< std::uint32_t, std::uint64_t > targetCount
Count per target component.
std::uint64_t totalEventsPublished
Total events published.
std::uint64_t maxQueueSize
Maximum queue size reached.
std::uint64_t currentQueueSize
Current queue size.
std::unordered_map< EventPriority, std::uint64_t > priorityCount
Count per priority.
double getEventsPerSecond() const
Get events per second rate.
std::chrono::steady_clock::time_point startTime
Statistics start time.
std::unordered_map< EventType, std::uint64_t > eventTypeCount
Count per event type.
std::uint64_t totalEventsExpired
Total events that expired.
void reset()
Reset all statistics.
std::unordered_map< std::uint32_t, std::uint64_t > sourceCount
Count per source component.
Event structure for inter-component communication.
std::uint64_t getAge() const
Get event age in milliseconds.
bool isTargeted() const
Check if event is targeted to a specific component.
std::uint32_t sourceId
ID of the component that sent the event (0 = system)
std::vector< std::uint8_t > data
Serialized event data.
std::chrono::steady_clock::time_point timestamp
Timestamp when event was created.
EventType type
Type of the event.
std::uint32_t targetId
ID of the target component (0 = broadcast)
Event()
Default constructor with current timestamp.
Event(EventType t, std::uint32_t src, std::uint32_t tgt=0, EventPriority prio=EventPriority::NORMAL)
Constructor with all parameters.
EventPriority priority
Event priority.
Event(EventType t)
Constructor with event type.
Event(EventType t, const std::vector< std::uint8_t > &d)
Constructor with event type and data.
bool hasExpired(std::uint64_t maxAgeMs=5000) const
Check if event has expired.
bool isBroadcast() const
Check if event is a broadcast.
static constexpr std::uint32_t GAME_LOGIC
EventType
Event types for inter-component communication.
static constexpr std::uint32_t RENDERING_ENGINE
EventPriority
Event priority levels.
static constexpr std::uint32_t NETWORK_SERVER
static constexpr std::uint32_t NETWORK_CLIENT