An abstract reactor that can be subclassed to define new reactors.  
 More...
#include <xronos/sdk/reactor.hh>
 | 
|   | Reactor (std::string_view name, const Context &parent_context) | 
|   | Constructor.  
  | 
| 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  | uid () const noexcept -> std::uint64_t | 
|   | Get the element's unique ID.  
  | 
| 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. 
  | 
| 
  | Element (Element &&)=default | 
|   | Move constructor. 
  | 
| 
auto  | operator= (Element &&) -> Element &=default | 
|   | Move assignment operator. 
  | 
 | 
| auto  | context (std::source_location source_location=std::source_location::current()) noexcept -> ReactorContext | 
|   | Get a context object for constructing reactor elements and contained reactors.  
  | 
| auto  | get_time () const noexcept -> TimePoint | 
|   | Get the current timestamp.  
  | 
| auto  | get_lag () const noexcept -> Duration | 
|   | Get the current lag.  
  | 
| auto  | get_time_since_startup () const noexcept -> Duration | 
|   | Get the time that passed since the startup event.  
  | 
| auto  | startup () const noexcept -> const Startup & | 
|   | Get the startup event source.  
  | 
| auto  | shutdown () noexcept -> Shutdown & | 
|   | Get the shutdown event source.  
  | 
| template<class T>  | 
| void  | connect (const InputPort< T > &from, const InputPort< T > &to) | 
|   | Connect two ports.     
  | 
| 
template<class T>  | 
| void  | connect (const OutputPort< T > &from, const OutputPort< T > &to) | 
|   | This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. 
  | 
| 
template<class T>  | 
| void  | connect (const OutputPort< T > &from, const InputPort< T > &to) | 
|   | This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. 
  | 
| template<class T>  | 
| void  | connect (const InputPort< T > &from, const InputPort< T > &to, Duration delay) | 
|   | Connect two ports with a delay.     
  | 
| 
template<class T>  | 
| void  | connect (const OutputPort< T > &from, const OutputPort< T > &to, Duration delay) | 
|   | This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. 
  | 
| 
template<class T>  | 
| void  | connect (const OutputPort< T > &from, const InputPort< T > &to, Duration delay) | 
|   | This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. 
  | 
template<class ReactionClass>  
requires (std::is_base_of_v<BaseReaction, ReactionClass>) | 
| void  | add_reaction (std::string_view name, std::source_location source_location=std::source_location::current()) | 
|   | Instantiate and add a new reaction to the reactor.  
  | 
 | 
| virtual void  | assemble ()=0 | 
|   | Method that sets up the internal topology of the reactor.  
  | 
An abstract reactor that can be subclassed to define new reactors. 
 
◆ Reactor()
      
        
          | xronos::sdk::Reactor::Reactor  | 
          ( | 
          std::string_view |           name,  | 
        
        
           | 
           | 
          const Context & |           parent_context ) | 
        
      
 
Constructor. 
- Parameters
 - 
  
    | name | The name of the reactor instance.  | 
    | parent_context | Either the environment's or the containing reactor's context.  | 
  
   
 
 
◆ context()
  
  
      
        
          | auto xronos::sdk::Reactor::context  | 
          ( | 
          std::source_location |           source_location = std::source_location::current() | ) | 
           ->  ReactorContext | 
         
       
   | 
  
nodiscardprotectednoexcept   | 
  
 
Get a context object for constructing reactor elements and contained reactors. 
- Parameters
 - 
  
    | source_location | Source location of the call site. Normally this should be omitted to use the default argument.  | 
  
   
- Returns
 - This reactors's context. 
 
 
 
◆ get_time()
  
  
      
        
          | auto xronos::sdk::Reactor::get_time  | 
          ( | 
           | ) | 
           const ->  TimePoint | 
         
       
   | 
  
nodiscardprotectednoexcept   | 
  
 
Get the current timestamp. 
This does not read wall-clock time. The Xronos runtime uses an internal clock to control how a program advances.
- Returns
 - The current timestamp as provided by the internal clock. 
 
 
 
◆ get_lag()
  
  
      
        
          | auto xronos::sdk::Reactor::get_lag  | 
          ( | 
           | ) | 
           const ->  Duration | 
         
       
   | 
  
nodiscardprotectednoexcept   | 
  
 
Get the current lag. 
Since in the Xronos SDK time does not advance while reactions execute, the internal clock may advance slower than a wall clock would. The lag denotes the difference between the wall clock and the internal clock. It is a measure of how far the execution of reactions lags behind events in the physical world.
- Returns
 - The current lag. 
 
 
 
◆ get_time_since_startup()
  
  
      
        
          | auto xronos::sdk::Reactor::get_time_since_startup  | 
          ( | 
           | ) | 
           const ->  Duration | 
         
       
   | 
  
nodiscardprotectednoexcept   | 
  
 
Get the time that passed since the startup event. 
- Returns
 - The difference between the current timestamp given by get_time() and the timestamp at which the program started. 
 
 
 
◆ startup()
  
  
      
        
          | auto xronos::sdk::Reactor::startup  | 
          ( | 
           | ) | 
           const -> const Startup&  | 
         
       
   | 
  
nodiscardprotectednoexcept   | 
  
 
Get the startup event source. 
- Returns
 - An event source that triggers once when the program execution starts. 
 
 
 
◆ shutdown()
  
  
      
        
          | auto xronos::sdk::Reactor::shutdown  | 
          ( | 
           | ) | 
           -> Shutdown&  | 
         
       
   | 
  
nodiscardprotectednoexcept   | 
  
 
Get the shutdown event source. 
- Returns
 - An event source that triggers once right before the program execution ends. 
 
 
 
◆ connect() [1/2]
template<class T> 
  
  
      
        
          | void xronos::sdk::Reactor::connect  | 
          ( | 
          const InputPort< T > & |           from,  | 
         
        
           | 
           | 
          const InputPort< T > & |           to ) | 
         
       
   | 
  
protected   | 
  
 
Connect two ports.    
Creates a new connection from the port given in from to the port given in to. Messages are delivered without a delay. This means that the timestamp at which the message is received is the same as the timestamp at which it was sent.
- Template Parameters
 - 
  
    | T | Value type associated with events relayed by the connection.  | 
  
   
- Parameters
 - 
  
    | from | The port to draw the connection from  | 
    | to | The port to draw the connection to.    | 
  
   
- See also
 - assemble() 
 
 
 
◆ connect() [2/2]
Connect two ports with a delay.    
Creates a new connection from the port given in from to the port given in to. Messages are delivered with a delay. This means that the timestamp at which the message is received is the timestamp at which it was sent plus delay.
- Template Parameters
 - 
  
    | T | Value type associated with events relayed by the connection.  | 
  
   
- Parameters
 - 
  
    | from | The port to draw the connection from  | 
    | to | The port to draw the connection to.  | 
    | delay | The delay to apply to all messages.    | 
  
   
- See also
 - assemble() 
 
 
 
◆ add_reaction()
template<class ReactionClass> 
requires (std::is_base_of_v<
BaseReaction, ReactionClass>)
 
  
  
      
        
          | void xronos::sdk::Reactor::add_reaction  | 
          ( | 
          std::string_view |           name,  | 
         
        
           | 
           | 
          std::source_location |           source_location = std::source_location::current() ) | 
         
       
   | 
  
protected   | 
  
 
Instantiate and add a new reaction to the reactor. 
This is intended to be invoked when overloading assemble() in a subclass. This factor method presents the only mechanism for correctly registering a reaction for execution by the runtime.
- Template Parameters
 - 
  
    | ReactionClass | The reaction class to instantiate. This is typically a subclass of Reaction. | 
  
   
- Parameters
 - 
  
    | name | The name of the reaction  | 
    | source_location | Source location of the call site. Normally this should be omitted to use the default argument. | 
  
   
- See also
 - assemble() 
 
 
 
◆ assemble()
  
  
      
        
          | virtual void xronos::sdk::Reactor::assemble  | 
          ( | 
           | ) | 
           | 
         
       
   | 
  
privatepure virtual   | 
  
 
Method that sets up the internal topology of the reactor. 
This method needs to be overridden by concrete subclasses. The method is called by the runtime before the execution starts. An implementation of assemble() should call add_reaction() to instantiate the reactor's reactions. If the reactor contains other reactors, their ports may be connected using connect(). 
 
 
The documentation for this class was generated from the following file: