emlabcpp
modern opinionated embedded C++ library
reactor.h
Go to the documentation of this file.
1 
24 #pragma once
25 
26 #include "../../pmr/stack_resource.h"
27 #include "../../protocol/endpoint.h"
28 #include "../../result.h"
29 #include "./executor.h"
30 #include "./protocol.h"
32 
33 namespace emlabcpp::testing
34 {
35 
36 class reactor
37 {
38  protocol::channel_type channel_;
39 
40  std::string_view suite_name_;
41  std::string_view const suite_date_ = __DATE__ " " __TIME__;
42 
43  empty_node root_node_;
45 
47 
48  std::optional< executor > opt_exec_;
49  bool boot_msg_fired_ = false;
50 
51 public:
52  explicit reactor(
53  protocol::channel_type const chann,
54  std::string_view const suite_name,
56  : channel_( chann )
57  , suite_name_( suite_name )
58  , iface_( chann, std::move( tb ) )
59  {
60  }
61 
62  reactor( reactor const& ) = delete;
63  reactor( reactor&& ) = delete;
64  reactor& operator=( reactor const& ) = delete;
65  reactor& operator=( reactor&& ) = delete;
66 
67  [[nodiscard]] constexpr protocol::channel_type get_channel() const
68  {
69  return channel_;
70  }
71 
72  outcome on_msg( std::span< std::byte const > buffer );
74 
76  {
77  root_node_.link_as_next( test );
78  }
79 
80  void tick();
81 
82 private:
85  outcome handle_message( get_property< msgid::COUNT > );
86  outcome handle_message( get_test_name_request );
87  outcome handle_message( exec_request );
88 };
89 
90 } // namespace emlabcpp::testing
Definition: linked_list.h:33
void link_as_next(linked_list_node_base< Base > &node)
Definition: linked_list.h:65
Definition: linked_list.h:138
Definition: reactor_interface_adapter.h:35
Definition: reactor.h:37
void register_test(linked_list_node_base< test_interface > &test)
Definition: reactor.h:75
reactor(protocol::channel_type const chann, std::string_view const suite_name, reactor_transmit_callback tb)
Definition: reactor.h:52
outcome on_msg(std::span< std::byte const > buffer)
reactor & operator=(reactor const &)=delete
reactor(reactor &&)=delete
constexpr protocol::channel_type get_channel() const
Definition: reactor.h:67
reactor & operator=(reactor &&)=delete
outcome on_msg(controller_reactor_variant const &var)
reactor(reactor const &)=delete
uint16_t channel_type
Definition: multiplexer.h:35
MIT License.
Definition: base.h:37
typename protocol::traits_for< controller_reactor_group >::value_type controller_reactor_variant
Definition: protocol.h:133
Definition: static_function.h:109
outcome represents tristate resut of some operation, which can succeed, fail or produce an error.
Definition: outcome.h:49
Definition: protocol.h:119
Definition: protocol.h:65