qb  2.0.0.0
C++17 Actor Framework
qb Issue Watch Star Fork Follow @isndev
Loading...
Searching...
No Matches
qb::Actor::EventBuilder Class Reference

Helper class for building and sending events to actors. More...

#include <Actor.h>

Public Member Functions

 EventBuilder (EventBuilder const &rhs) noexcept=default
template<typename _Event, typename... _Args>
EventBuilderpush (_Args &&...args) noexcept
 Send a new event to the target actor.

Detailed Description

Helper class for building and sending events to actors.

This class simplifies the process of sending multiple events to a target actor. It provides a fluent interface for chaining event sends, ensuring that events are delivered in the order they are pushed.

Member Function Documentation

◆ push()

template<typename _Event, typename... _Args>
EventBuilder & qb::Actor::EventBuilder::push ( _Args &&... args)
noexcept

Send a new event to the target actor.

Creates and sends an event of the specified type to the target actor. The event is constructed with the provided arguments and will be delivered in the order it was pushed.

Example:

// Send multiple events to an actor
to(targetActorId)
.push<ReadyEvent>()
.push<DataEvent>(buffer, size)
.push<CompleteEvent>(status);
EventBuilder & push(_Args &&...args) noexcept
Send a new event to the target actor.
EventBuilder to(ActorId dest) const noexcept
Get an EventBuilder for sending chained events to a destination actor.
Template Parameters
_EventThe type of event to create and send
ArgsTypes of arguments to forward to the event constructor
Parameters
argsArguments to forward to the event constructor
Returns
Reference to this EventBuilder for method chaining