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

Access to a reactor element that triggers the reaction and that it may read. More...

#include <xronos/sdk/reaction.hh>

Public Member Functions

 Trigger (const EventSource< T > &trigger, ReactionContext context)
 Construct a new Trigger object.
 
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 >

Access to a reactor element that triggers the reaction and that it may read.

Template Parameters
TThe type of value carried by the trigger.

Constructor & Destructor Documentation

◆ Trigger()

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

Construct a new Trigger object.

Constructing a Trigger object ensures that the corresponding reaction is invoked for every event on the given event source.

Parameters
triggerAn event source of the containing reactor, which can be obtained using the Reaction::self method.
contextThe current reaction's initialization context, which can be obtained using the BaseReaction::context method.

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
ImmutableValuePtr<T> A pointer to the current value of the event source, or nullptr if there is no present event.

◆ 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
bool true if an event is present, false otherwise.

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