...
This commit is contained in:
parent
39aefe462a
commit
fd0625a84b
@ -11,8 +11,41 @@ ABSTRACT DEVICE COMPONENTS LIBRARY
|
||||
|
||||
#include "../common/adc_traits.h"
|
||||
|
||||
/* DEFINITIONS OF NETWORK CONPONENTS INTERFACES */
|
||||
/* DEFINITIONS OF NETWORK COMPONENTS INTERFACES */
|
||||
|
||||
|
||||
/*
|
||||
struct NetService {
|
||||
typedef ImplementationDependentT netservice_ident_t;
|
||||
typedef ImplementationDependentT async_ctx_t;
|
||||
typedef ImplementationDependentT endpoint_t;
|
||||
|
||||
template<typename Rep, typename Period>
|
||||
auto asyncAccept(const endpoint_t&, const async_ctx_t&, const std::chrono::duration<Rep, Period>&)
|
||||
|
||||
template<typename Rep, typename Period>
|
||||
auto asyncConnect(const endpoint_t&, const async_ctx_t&, const std::chrono::duration<Rep, Period>&)
|
||||
|
||||
template<typename Rep, typename Period, adc::traits::adc_input_char_range R>
|
||||
auto asyncSend(const R&, const async_ctx_t&, const std::chrono::duration<Rep, Period>&)
|
||||
|
||||
template<typename Rep, typename Period>
|
||||
auto asyncReceived(const async_ctx_t&, const std::chrono::duration<Rep, Period>&)
|
||||
|
||||
template<typename Rep, typename Period>
|
||||
auto accept(const endpoint_t&, const async_ctx_t&, const std::chrono::duration<Rep, Period>&)
|
||||
|
||||
template<typename Rep, typename Period>
|
||||
auto connect(const endpoint_t&, const async_ctx_t&, const std::chrono::duration<Rep, Period>&)
|
||||
|
||||
template<typename Rep, typename Period, adc::traits::adc_input_char_range R>
|
||||
auto send(const R&, const std::chrono::duration<Rep, Period>&)
|
||||
|
||||
template<adc::traits::adc_output_char_range R, typename Rep, typename Period>
|
||||
R received(const std::chrono::duration<Rep, Period>&)
|
||||
|
||||
}
|
||||
*/
|
||||
template <typename SRVT>
|
||||
concept adc_netservice_c = requires(SRVT srv, const SRVT srv_const) {
|
||||
typename SRVT::netservice_ident_t;
|
||||
@ -49,3 +82,39 @@ concept adc_netservice_c = requires(SRVT srv, const SRVT srv_const) {
|
||||
}(srv, std::string(), typename SRVT::async_ctx_t(), std::chrono::seconds(1));
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
/* NETWORK SESSION */
|
||||
|
||||
template<typename SESST>
|
||||
concept adc_netsession_c = std::derived_from<SESST, std::enable_shared_from_this<SESST>>
|
||||
&& requires(SESST sess, const SESST sess_const) {
|
||||
typename SESST::netsession_ident_t;
|
||||
|
||||
// netsession_ident_t ident() const
|
||||
{ sess_const.ident() } -> std::same_as<typename SESST::netsession_ident_t>;
|
||||
|
||||
sess.start();
|
||||
sess.stop();
|
||||
};
|
||||
|
||||
|
||||
|
||||
/* NETWORK SESSION-LEVEL PROTOCOL */
|
||||
|
||||
template<typename SESS_PROTOT>
|
||||
concept adc_netsession_proto_c = requires(SESS_PROTOT proto, const SESS_PROTOT proto_const) {
|
||||
typename SESS_PROTOT::proto_ident_t;
|
||||
|
||||
// proto_ident_t ident() const (const method)
|
||||
{ proto_const.ident() } -> std::same_as<typename SESS_PROTOT::proto_ident_t>;
|
||||
|
||||
[]<std::input_iterator IT>(const SESS_PROTOT &proto, IT begin, IT end) -> std::tuple<IT, IT, bool> {
|
||||
return proto.parse(begin, end);
|
||||
};
|
||||
|
||||
// must return a view of R-range!
|
||||
[]<std::ranges::range R>(SESS_PROTOT obj, const R &r) -> std::ranges::view auto {
|
||||
return obj.from(r);
|
||||
}(proto, std::string());
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user