asrt
Automated System Runtime Testing library
Loading...
Searching...
No Matches
param.hpp
1
11#pragma once
12
13#include "../asrtc/param.h"
14#include "../asrtl/asrt_assert.h"
15#include "../asrtl/log.h"
16#include "../asrtl/status_to_str.h"
17#include "../asrtlpp/callback.hpp"
18#include "../asrtlpp/flat_type_traits.hpp"
19#include "../asrtlpp/task.hpp"
20#include "../asrtlpp/util.hpp"
21
22namespace asrt
23{
24
25using status = enum asrt_status;
26
28ASRT_NODISCARD inline status init(
29 ref< asrt_param_server > srv,
30 asrt_node& prev,
31 asrt_allocator alloc )
32{
33 return asrt_param_server_init( srv, &prev, alloc );
34}
35
38inline void set_tree( ref< asrt_param_server > srv, asrt_flat_tree const& tree )
39{
40 asrt_param_server_set_tree( srv, &tree );
41}
42
45ASRT_NODISCARD inline status send_ready(
46 ref< asrt_param_server > srv,
47 flat_id root_id,
49 uint32_t timeout )
50{
51 return asrt_param_server_send_ready( srv, root_id, timeout, ack_cb.fn, ack_cb.ptr );
52}
53
55inline void deinit( ref< asrt_param_server > srv )
56{
57 asrt_param_server_deinit( srv );
58}
59
61struct _param_send_ready_ctx
62{
63 using completion_signatures =
64 ecor::completion_signatures< ecor::set_value_t(), ecor::set_error_t( status ) >;
65
67 flat_id root_id;
68 uint32_t timeout;
69
70 template < typename OP >
71 void start( OP& op )
72 {
73 auto s = asrt_param_server_send_ready(
74 srv,
75 root_id,
76 timeout,
77 +[]( void* p, enum asrt_status s ) {
78 auto& o = *static_cast< OP* >( p );
79 if ( s == ASRT_SUCCESS )
80 o.receiver.set_value();
81 else
82 o.receiver.set_error( s );
83 },
84 &op );
85 if ( s != ASRT_SUCCESS )
86 op.receiver.set_error( s );
87 }
88};
89
92using param_send_ready_sender = ecor::sender_from< _param_send_ready_ctx >;
93
96inline ecor::sender auto send_ready(
97 ref< asrt_param_server > srv,
98 flat_id root_id,
99 uint32_t timeout )
100{
101 return param_send_ready_sender{ { srv, root_id, timeout } };
102}
103
104} // namespace asrt
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee ...
Definition: callback.hpp:17
ecor::sender_from< _param_send_ready_ctx > param_send_ready_sender
Sender backing co_await send_ready(srv, root_id, timeout).
Definition: param.hpp:92
ASRT_NODISCARD enum asrt_status init(ref< asrt_cntr_assm > assm, asrt_allocator alloc)
Initialise the controller assembly — wires controller, diag, param, collect and stream channels.
Definition: cntr_assm.hpp:25
ASRT_NODISCARD status send_ready(ref< asrt_collect_server > srv, flat_id root_id, callback< asrt_collect_ready_ack_cb > ack_cb, uint32_t timeout)
Send a READY message to the reactor to start a collection session rooted at root_id.
Definition: collect.hpp:39
asrt_flat_tree const & tree(ref< asrt_collect_server > srv)
Access the flat_tree assembled from incoming APPEND messages.
Definition: collect.hpp:49
void set_tree(ref< asrt_param_server > srv, asrt_flat_tree const &tree)
Set the flat_tree to be served in response to QUERY and FIND_BY_KEY requests.
Definition: param.hpp:38
void deinit(ref< asrt_cntr_assm > assm)
Release all resources owned by the assembly.
Definition: cntr_assm.hpp:52
A type-erasing wrapper for C-style callback + void* pairs.
Definition: callback.hpp:27
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee ...
Definition: allocator.h:28
node_id maps to blocks[node_id / node_capacity][node_id % node_capacity].
Definition: flat_tree.h:121
A node in a doubly-linked channel chain.
Definition: chann.h:122
Param server module — PARAM channel, controller side.
Definition: param.h:38