xronos-sdk 0.12.0
Xronos C++ SDK
Loading...
Searching...
No Matches
xronos::sdk::Reaction< R > Class Template Reference

Reaction base class with reactor access. More...

#include <xronos/sdk/reaction.hh>

Inheritance diagram for xronos::sdk::Reaction< R >:
[legend]

Public Member Functions

 Reaction (const ReactionProperties &properties)
 Constructor.
Public Member Functions inherited from xronos::sdk::BaseReaction
 BaseReaction (const ReactionProperties &properties)
 Constructor.
Public Member Functions inherited from xronos::sdk::Element
 Element (Element &&)=default
 Move constructor.
virtual ~Element ()=default
 Virtual destructor.
auto add_attribute (std::string_view key, const AttributeValue &value) noexcept -> bool
 Annotate an element with an attribute.
template<std::ranges::input_range R>
requires requires(std::ranges::range_value_t<R> pair) { { pair.first } -> std::convertible_to<std::string_view>; { pair.second } ->
std::convertible_to<AttributeValue>; }
auto add_attributes (const R &range) noexcept -> bool
 Annotate an element with multiple attributes.
auto add_attributes (std::initializer_list< std::pair< std::string_view, AttributeValue > > attributes) -> bool
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
auto fqn () const noexcept -> const std::string &
 Get the element's fully qualified name.
auto name () const noexcept -> const std::string &
 Get the element's name.
auto operator= (Element &&) -> Element &=default
 Move assignment operator.
auto uid () const noexcept -> std::uint64_t
 Get the element's unique ID.

Protected Member Functions

auto self () noexcept -> R &
 Get a reference to the owning reactor.
Protected Member Functions inherited from xronos::sdk::BaseReaction
auto context () noexcept -> auto
 Get a context object for constructing reaction triggers and effects Reaction effect classes..
auto current_time () const noexcept -> TimePoint
 Get the current time.
auto deadline () const noexcept -> std::optional< TimePoint >
 Get the deadline associated with the current handler invocation.
auto elapsed_time () const noexcept -> Duration
 Get how far the internal clock has advanced since the startup event.
auto is_before_deadline () const noexcept -> bool
 Check whether the currently executing handler is still within its deadline.
auto lag () const noexcept -> Duration
 Get the current lag.
auto remaining_slack () const noexcept -> Duration
auto slack () const noexcept -> Duration
 Get the remaining slack before the deadline.

Detailed Description

template<class R>
class xronos::sdk::Reaction< R >

Reaction base class with reactor access.

In addition to BaseReaction, this class provides fully-typed access to the owning reactor and all its state and elements.

Template Parameters
RType of the owning reactor. This must be a subclass of Reactor.

Constructor & Destructor Documentation

◆ Reaction()

template<class R>
xronos::sdk::Reaction< R >::Reaction ( const ReactionProperties & properties)

Constructor.

Since ReactionProperties has no public constructor, this constructor cannot be invoked directly. Use the Reactor::add_reaction() factory method instead.

Member Function Documentation

◆ self()

template<class R>
auto xronos::sdk::Reaction< R >::self ( ) -> R &
nodiscardprotectednoexcept

Get a reference to the owning reactor.

The reactor reference can be used for referencing other elements of the reactor when declaring triggers and effects Reaction effect classes.. It can also be used in the reaction handler for accessing the reactor's state.

Returns
A reference to the owning reactor.

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