xronos-sdk 0.12.0
Xronos C++ SDK
Loading...
Searching...
No Matches
xronos::sdk::PeriodicTimer Class Referencefinal

A reactor element that emits events in regular intervals. More...

#include <xronos/sdk/periodic_timer.hh>

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

Public Member Functions

 PeriodicTimer (std::string_view name, ReactorContext context, Duration period, Duration offset=Duration::zero())
 Constructor.
auto offset () const noexcept -> const Duration &
 Get the timer's offset.
auto period () const noexcept -> const Duration &
 Get the delay in between two events emitted by the timer.
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.

Detailed Description

A reactor element that emits events in regular intervals.

Can be used as a reaction trigger.

Constructor & Destructor Documentation

◆ PeriodicTimer()

xronos::sdk::PeriodicTimer::PeriodicTimer ( std::string_view name,
ReactorContext context,
Duration period,
Duration offset = Duration::zero() )

Constructor.

Parameters
nameThe name of the periodic timer.
contextThe containing reactor's context.
periodThe delay in between two events emitted by the timer.
offsetThe delay between the startup event and the first event emitted by the timer.

Member Function Documentation

◆ offset()

auto xronos::sdk::PeriodicTimer::offset ( ) const -> const Duration &
nodiscardnoexcept

Get the timer's offset.

The offset denotes the delay between the startup event and the first event emitted by the timer.

Returns
The timer's offset.

◆ period()

auto xronos::sdk::PeriodicTimer::period ( ) const -> const Duration &
nodiscardnoexcept

Get the delay in between two events emitted by the timer.

Returns
The timer's period.

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