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

Allows a reaction to write data to a given Port. More...

#include <xronos/sdk/reaction.hh>

Public Member Functions

 PortEffect (Port< T > &port, ReactionContext context)
 Constructor.
void set (const ImmutableValuePtr< T > &value_ptr)
 Write a value to the port sending a message to connected ports.
void set (MutableValuePtr< T > &&value_ptr)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
template<class U>
requires (!std::is_same_v<U, void> && std::is_same_v<T, U>)
void set (const U &value)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
template<class U>
requires (!std::is_same_v<U, void> && std::is_same_v<T, U>)
void set (U &&value)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void set ()
 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 a previously set value.
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::PortEffect< T >

Allows a reaction to write data to a given Port.

Template Parameters
TThe value type associated with the port.

Constructor & Destructor Documentation

◆ PortEffect()

template<class T>
xronos::sdk::BaseReaction::PortEffect< T >::PortEffect ( Port< T > & port,
ReactionContext context )

Constructor.

Parameters
portThe Port for which the reaction should have write access.
contextThe context of the reaction the effect is declared for. Can be obtained using context().

Member Function Documentation

◆ set() [1/4]

template<class T>
void xronos::sdk::BaseReaction::PortEffect< T >::set ( const ImmutableValuePtr< T > & value_ptr)

Write a value to the port sending a message to connected ports.

May be called multiple times, but at most one value is sent to connected ports. When called repeatedly at a given timestamp, the previous value is overwritten.

Parameters
value_ptrA pointer to the value to be written to the referenced port.

◆ set() [2/4]

template<class T>
template<class U>
requires (!std::is_same_v<U, void> && std::is_same_v<T, U>)
void xronos::sdk::BaseReaction::PortEffect< T >::set ( const U & value)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Copy constructs the value using the given lvalue reference.

◆ set() [3/4]

template<class T>
template<class U>
requires (!std::is_same_v<U, void> && std::is_same_v<T, U>)
void xronos::sdk::BaseReaction::PortEffect< T >::set ( U && value)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Move constructs the value using the given rvalue reference.

◆ set() [4/4]

template<class T>
void xronos::sdk::BaseReaction::PortEffect< T >::set ( )

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Set the port without sending a value. This is only available if T is void.

◆ get()

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

Get a previously set value.

Returns
A pointer to the current value of the port or nullptr if no value was set at the current timestamp.

◆ is_present()

template<class T>
auto xronos::sdk::BaseReaction::PortEffect< 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: