add net/adc_net_concepts.h: start declaration of network components
interfaces
This commit is contained in:
parent
db58d6a904
commit
39aefe462a
51
net/adc_net_concepts.h
Normal file
51
net/adc_net_concepts.h
Normal file
@ -0,0 +1,51 @@
|
||||
#pragma once
|
||||
|
||||
/*
|
||||
|
||||
ABSTRACT DEVICE COMPONENTS LIBRARY
|
||||
|
||||
*/
|
||||
|
||||
#include <chrono>
|
||||
#include <concepts>
|
||||
|
||||
#include "../common/adc_traits.h"
|
||||
|
||||
/* DEFINITIONS OF NETWORK CONPONENTS INTERFACES */
|
||||
|
||||
template <typename SRVT>
|
||||
concept adc_netservice_c = requires(SRVT srv, const SRVT srv_const) {
|
||||
typename SRVT::netservice_ident_t;
|
||||
|
||||
// netservice_ident_t ident() const
|
||||
{ srv_const.ident() } -> std::same_as<typename SRVT::netservice_ident_t>;
|
||||
|
||||
typename SRVT::async_ctx_t;
|
||||
typename SRVT::endpoint_t;
|
||||
|
||||
requires requires {
|
||||
[]<typename Rep, typename Period>(SRVT& srv_obj, const typename SRVT::endpoint_t& endpoint,
|
||||
const typename SRVT::async_ctx_t& ctx,
|
||||
const std::chrono::duration<Rep, Period>& timeout) {
|
||||
srv_obj.asyncAccept(endpoint, ctx, timeout);
|
||||
srv_obj.asyncConnect(endpoint, ctx, timeout);
|
||||
|
||||
srv_obj.accept(endpoint, timeout);
|
||||
srv_obj.connect(endpoint, timeout);
|
||||
}(srv, typename SRVT::endpoint_t(), typename SRVT::async_ctx_t(), std::chrono::seconds(1));
|
||||
|
||||
[]<typename Rep, typename Period, adc::traits::adc_input_char_range R>(
|
||||
SRVT& srv_obj, const R& msg, const typename SRVT::async_ctx_t& ctx,
|
||||
const std::chrono::duration<Rep, Period>& timeout) {
|
||||
srv_obj.asyncSend(msg, ctx, timeout);
|
||||
srv_obj.send(msg, timeout);
|
||||
}(srv, std::span<const char>(), typename SRVT::async_ctx_t(), std::chrono::seconds(1));
|
||||
|
||||
[]<typename Rep, typename Period, adc::traits::adc_output_char_range R>(
|
||||
SRVT& srv_obj, R& msg, const typename SRVT::async_ctx_t& ctx,
|
||||
const std::chrono::duration<Rep, Period>& timeout) {
|
||||
srv_obj.asyncReceive(ctx, timeout);
|
||||
msg = srv_obj.receive(timeout);
|
||||
}(srv, std::string(), typename SRVT::async_ctx_t(), std::chrono::seconds(1));
|
||||
};
|
||||
};
|
||||
Loading…
x
Reference in New Issue
Block a user