xronos-sdk 0.5.0
Xronos C++ SDK
Loading...
Searching...
No Matches

Base class for implementing reactions. More...

#include <xronos/sdk/reaction.hh>

Inheritance diagram for xronos::sdk::BaseReaction:
[legend]

Classes

class  MetricEffect
 Allows a reaction to record telemetry data using a given Metric. More...
class  PortEffect
 Allows a reaction to write data to a given Port. More...
class  ProgrammableTimerEffect
 Allows a reaction to schedule future events using a ProgrammableTimer. More...
class  Trigger
 Declares a reaction trigger and provides read access to the triggering EventSource. More...

Public Member Functions

 BaseReaction (ReactionProperties properties)
 Constructor.
Public Member Functions inherited from xronos::sdk::Element
auto name () const noexcept -> const std::string &
 Get the element's name.
auto fqn () const noexcept -> const std::string &
 Get the element's fully qualified name.
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.
virtual ~Element ()=default
 Virtual destructor.

Protected Member Functions

auto context () noexcept -> ReactionContext
 Get a context object for constructing reaction triggers and effects Reaction effect classes..

Private Member Functions

virtual void handler ()=0
 The reaction handler.

Detailed Description

Base class for implementing reactions.

In the Xronos SDK, reactions define the behavior of a reactor. Reactions have one or more triggers and may have effects Reaction effect classes.. The reaction's behavior is defined by overriding the handler() method, which is invoked automatically for any event received on the triggers.

Typically, user reactions should not inherit from BaseReaction directly and use Reaction instead as it provides additional tools for accessing other reactor elements and reactor state.

Note that reaction classes may not be instantiated directly. Use the Reactor::add_reaction() factory method instead.

See also
Reaction
Reactor::add_reaction()

Constructor & Destructor Documentation

◆ BaseReaction()

xronos::sdk::BaseReaction::BaseReaction ( 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

◆ context()

auto xronos::sdk::BaseReaction::context ( ) -> ReactionContext
nodiscardprotectednoexcept

Get a context object for constructing reaction triggers and effects Reaction effect classes..

Returns
This reaction's context.

◆ handler()

virtual void xronos::sdk::BaseReaction::handler ( )
privatepure virtual

The reaction handler.

This method is invoked automatically in response to triggering events. User code must override this method to define a reaction's behavior.


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