xronos-sdk 0.6.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>

Inheritance diagram for xronos::sdk::BaseReaction::Trigger< T >:
[legend]

Public Member Functions

 Trigger (const InputPort< T > &trigger, const ReactionContext &context)
 Constructor.
 Trigger (const OutputPort< T > &trigger, const ReactionContext &context)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 Trigger (const PhysicalEvent< T > &trigger, const ReactionContext &context)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 Trigger (const ProgrammableTimer< T > &trigger, const ReactionContext &context)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 Trigger (const PeriodicTimer &trigger, const ReactionContext &context)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 Trigger (const Startup &trigger, const ReactionContext &context)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 Trigger (const Shutdown &trigger, const ReactionContext &context)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
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 InputPort< T > & trigger,
const ReactionContext & context )

Constructor.

Constructing a Trigger automatically registers the given event source as a trigger of the reaction, causing the reaction handler to run whenever the event source emits an event.

Parameters
triggerAn event 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: