xronos-sdk 0.5.0
Xronos C++ SDK
Loading...
Searching...
No Matches
xronos::sdk::BaseReaction::Trigger< T > Class Template Reference

Declares a reaction trigger and provides read access to the triggering EventSource. More...

#include <xronos/sdk/reaction.hh>

Public Member Functions

 Trigger (const EventSource< T > &trigger, ReactionContext context)
 Constructor.
auto get () const noexcept -> ImmutableValuePtr< T > requires(!std::is_same_v< T, void >)
 Get the value of a currently present event.
auto is_present () const noexcept -> bool
 Check if an event is present at the current timestamp.

Detailed Description

template<class T>
class xronos::sdk::BaseReaction::Trigger< T >

Declares a reaction trigger and provides read access to the triggering EventSource.

Template Parameters
TThe value type associated with events received on the triggering event source.

Constructor & Destructor Documentation

◆ Trigger()

template<class T>
xronos::sdk::BaseReaction::Trigger< T >::Trigger ( const EventSource< T > & trigger,
ReactionContext context )

Constructor.

Constructing a Trigger automatically registers the specified event source with the reaction, causing the reaction handler to run whenever the event source emits an event.

Parameters
triggerAn EventSource source that should trigger the reaction.
contextContext of the reaction the trigger is declared for. Can be obtained using context().

Member Function Documentation

◆ get()

template<class T>
auto xronos::sdk::BaseReaction::Trigger< T >::get ( ) const -> ImmutableValuePtr<T> requires(!std::is_same_v<T, void>)
nodiscardnoexcept

Get the value of a currently present event.

Returns
A pointer to the value of the current event, or nullptr if there is no current event (is_present() is false).

◆ is_present()

template<class T>
auto xronos::sdk::BaseReaction::Trigger< T >::is_present ( ) const -> bool
nodiscardnoexcept

Check if an event is present at the current timestamp.

Returns
true if an event is present, false otherwise.

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