13#include "../asrtl/asrt_assert.h"
14#include "../asrtl/log.h"
15#include "../asrtl/status_to_str.h"
16#include "../asrtlpp/callback.hpp"
17#include "../asrtlpp/flat_type_traits.hpp"
18#include "../asrtlpp/task.hpp"
19#include "../asrtlpp/util.hpp"
20#include "../asrtr/collect.h"
28template <
typename T >
34 static constexpr auto member = &asrt_flat_scalar::u32_val;
40 static constexpr auto member = &asrt_flat_scalar::i32_val;
46 static constexpr auto member = &asrt_flat_scalar::float_val;
52 static constexpr auto member = &asrt_flat_scalar::str_val;
58 static constexpr auto member = &asrt_flat_scalar::bool_val;
72template <
typename T >
76template <
typename T >
79ASRT_NODISCARD
inline status
init( ref< asrt_collect_client > client,
asrt_node& prev )
81 return asrt_collect_client_init( client, &prev );
84ASRT_NODISCARD
inline flat_id root_id( ref< asrt_collect_client const > cc )
86 return asrt_collect_client_root_id( cc );
90template <
typename T >
91struct _collect_append_ctx;
93template < collect_scalar T >
94struct _collect_append_ctx< T >
96 using completion_signatures =
97 ecor::completion_signatures< ecor::set_value_t(), ecor::set_error_t( status ) >;
104 template <
typename OP >
107 using traits = collect_append_traits< T >;
110 v.data.s.*traits::member =
static_cast< member_type
>( val );
111 auto s = asrt_collect_client_append(
117 +[](
void* ptr,
enum asrt_status st ) {
118 auto* o =
static_cast< OP*
>( ptr );
119 if ( st == ASRT_SUCCESS )
120 o->receiver.set_value();
122 o->receiver.set_error(
static_cast< status
>( st ) );
125 if ( s != ASRT_SUCCESS )
126 op.receiver.set_error(
static_cast< status
>( s ) );
130template < collect_container T >
131struct _collect_append_ctx< T >
133 using completion_signatures = ecor::
134 completion_signatures< ecor::set_value_t( flat_id ), ecor::set_error_t( status ) >;
141 template <
typename OP >
144 using traits = collect_append_traits< T >;
146 auto s = asrt_collect_client_append(
152 +[](
void* ptr,
enum asrt_status st ) {
153 auto* o =
static_cast< OP*
>( ptr );
154 if ( st == ASRT_SUCCESS )
155 o->receiver.set_value( o->ctx.out );
157 o->receiver.set_error(
static_cast< status
>( st ) );
160 if ( s != ASRT_SUCCESS )
161 op.receiver.set_error(
static_cast< status
>( s ) );
165template <
typename T >
166 requires collect_scalar< T > || collect_container< T >
167using collect_append_sender = ecor::sender_from< _collect_append_ctx< T > >;
170template < collect_scalar T >
172 ref< asrt_collect_client > cc,
181 v.data.s.*traits::member =
static_cast< member_type
>( val );
182 return asrt_collect_client_append( cc, parent, key, &v, NULL, done_cb.fn, done_cb.ptr );
186template < collect_scalar T >
187ecor::sender
auto append( ref< asrt_collect_client > cc, flat_id parent,
char const* key, T val )
189 return collect_append_sender< T >{ { cc, parent, key, val } };
193template < collect_scalar T >
195 ref< asrt_collect_client > cc,
200 return append< T >( cc, parent,
nullptr, val, done_cb );
205template < collect_container T >
207 ref< asrt_collect_client > cc,
215 return asrt_collect_client_append( cc, parent, key, &v, &out, done_cb.fn, done_cb.ptr );
219template < collect_container T >
220ecor::sender
auto append( ref< asrt_collect_client > client, flat_id parent,
char const* key )
222 return collect_append_sender< T >{ { client, parent, key } };
226template < collect_container T >
228 ref< asrt_collect_client > cc,
233 return append< T >( cc, parent,
nullptr, out, done_cb );
237template < collect_scalar T >
238ecor::sender
auto append( ref< asrt_collect_client > cc, flat_id parent, T val )
240 return collect_append_sender< T >{ { cc, parent,
nullptr, val } };
244template < collect_container T >
245ecor::sender
auto append( ref< asrt_collect_client > client, flat_id parent )
247 return collect_append_sender< T >{ { client, parent,
nullptr } };
250inline void deinit( ref< asrt_collect_client > client )
252 asrt_collect_client_deinit( client );
Concept: T is a container tag (OBJECT or ARRAY).
Definition: collect.hpp:77
Concept: T is a scalar type with a flat_value member pointer.
Definition: collect.hpp:73
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee ...
Definition: callback.hpp:17
ASRT_NODISCARD status start(ref< asrt_controller > c, callback< asrt_init_callback > cb, uint32_t timeout)
Begin the protocol handshake; cb is invoked once the target responds or the operation times out.
Definition: controller.hpp:36
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
status append(ref< asrt_collect_client > cc, flat_id parent, char const *key, T val, callback< asrt_send_done_cb > done_cb)
Scalar append with key: append<uint32_t>(parent, "key", 42, cb).
Definition: collect.hpp:171
void deinit(ref< asrt_cntr_assm > assm)
Release all resources owned by the assembly.
Definition: cntr_assm.hpp:52
Tag type representing a flat-tree ARRAY container node.
Definition: flat_type_traits.hpp:28
A type-erasing wrapper for C-style callback + void* pairs.
Definition: callback.hpp:27
Trait mapping C++ types to flat_value scalar member pointers.
Definition: collect.hpp:29
Trait mapping a C++ type to its flat_tree metadata.
Definition: flat_type_traits.hpp:38
Tag type representing a flat-tree OBJECT container node.
Definition: flat_type_traits.hpp:24
Reactor-side collect client (ASRT_COLL channel).
Definition: collect.h:41
Definition: flat_tree.h:90
A node in a doubly-linked channel chain.
Definition: chann.h:122
Definition: flat_tree.h:75