xronos-sdk 0.5.0
Xronos C++ SDK
Loading...
Searching...
No Matches
xronos::sdk::Element Class Reference

Base class for all reactor elements. More...

#include <xronos/sdk/element.hh>

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

Public Member Functions

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.

Detailed Description

Base class for all reactor elements.

Reactor elements are objects that can be contained by reactors and that have special meaning to the Xronos SDK.

Member Function Documentation

◆ name()

auto xronos::sdk::Element::name ( ) const -> const std::string &
nodiscardnoexcept

Get the element's name.

Returns
The element's name.

◆ fqn()

auto xronos::sdk::Element::fqn ( ) const -> const std::string &
nodiscardnoexcept

Get the element's fully qualified name.

The fully qualified name (FQN) represents the containment hierarchy. It consists of the containing reactor's FQN plus the element's name separated by a .. For top-level reactors (those owned by the Environment), the FQN is equal to the name.

Returns
The element's fully qualified name.

◆ add_attribute()

auto xronos::sdk::Element::add_attribute ( std::string_view key,
const AttributeValue & value ) -> bool
noexcept

Annotate an element with an attribute.

Adding the attribute only succeeds, if the given key has not been set before on the same element.

See Attributes for more information.

Parameters
keyThe name of the attribute to add.
valueThe value of the attribute to add.
Returns
true if the attribute was successfully added.
See also
add_attributes()

◆ add_attributes() [1/2]

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 xronos::sdk::Element::add_attributes ( const R & range) -> bool
noexcept

Annotate an element with multiple attributes.

Adding the attributes only succeeds, if the given key has not been set before on the same element.

See Attributes for more information.

Template Parameters
RType of the range.
Parameters
rangeRange of key-value-pairs to be added as attributes.
Returns
true if all attributes were successfully added.
See also
add_attribute()

◆ add_attributes() [2/2]

auto xronos::sdk::Element::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.

Accepts an initializer list of key value pairs.


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