...
This commit is contained in:
@@ -237,7 +237,7 @@ struct netproto_stopseq_t {
|
||||
};
|
||||
|
||||
|
||||
static_assert(net_connection_proto_c<netproto_stopseq_t<>>, "!!!");
|
||||
static_assert(net_repr_proto_c<netproto_stopseq_t<>>, "!!!");
|
||||
|
||||
|
||||
/* BINARY BLOB PROTOCOL */
|
||||
@@ -374,7 +374,7 @@ struct netproto_binary_blob_t {
|
||||
|
||||
|
||||
|
||||
static_assert(net_connection_proto_c<netproto_binary_blob_t<>>, "!!!");
|
||||
static_assert(net_repr_proto_c<netproto_binary_blob_t<>>, "!!!");
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -42,8 +42,28 @@ concept net_message_c = requires(const T t_const) {
|
||||
});
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
concept net_repr_proto_result_c = requires(T t) {
|
||||
typename T::result_flag_t;
|
||||
|
||||
[]() {
|
||||
[[maybe_unused]] static constexpr std::array arr{T::result_flag_t::OK,
|
||||
// needs more data
|
||||
T::result_flag_t::NOT_ENOUGH_DATA,
|
||||
// given byte sequence is invalid
|
||||
T::result_flag_t::INVALID_DATA};
|
||||
}();
|
||||
|
||||
// static_cast<bool>(T::NOT_ENOUGH_DATA) != false;
|
||||
// static_cast<bool>(T::INVALID_DATA) != false;
|
||||
|
||||
std::same_as<typename T::result_flag_t, decltype(t.flag)>;
|
||||
|
||||
char_range_or_range_of_char_ranges_c<decltype(t.result)>;
|
||||
};
|
||||
|
||||
// template <typename T>
|
||||
// concept net_connection_proto_c = requires(T t) {
|
||||
// concept net_repr_proto_c = requires(T t) {
|
||||
// requires net_message_c<typename T::message_t>;
|
||||
|
||||
// // from application-level representation to session-level one
|
||||
@@ -63,13 +83,16 @@ concept net_message_c = requires(const T t_const) {
|
||||
// };
|
||||
|
||||
|
||||
// OSI representation level protocol
|
||||
template <typename T, typename CharRangeT = std::vector<char>>
|
||||
concept net_connection_proto_c = requires(T t) {
|
||||
// from byte sequence payload representation to "network"-ready (session) one (a byte sequence to be sent over
|
||||
// transport level (TCP, UDP etc...))
|
||||
concept net_repr_proto_c = requires(T t) {
|
||||
// from payload byte sequence representation to "network"-ready (Representation Level in the OSI model) one (a byte
|
||||
// sequence to be sent over transport level (TCP, UDP etc...))
|
||||
// The method may add some "markers" (e.g. "stop symbols") to the input byte sequence to encode
|
||||
// sequence of messages
|
||||
{ t.toNetwork(std::declval<CharRangeT>()) } -> char_range_or_range_of_char_ranges_c;
|
||||
|
||||
// from session level representation to byte sequence payload representation
|
||||
// from "network"-ready level representation to byte sequence payload representation
|
||||
requires(
|
||||
requires {
|
||||
{ t.fromNetwork(std::declval<std::span<const char>>()) } -> ret_expected_c;
|
||||
|
||||
@@ -37,12 +37,12 @@ concept transport_dgram_proto_c =
|
||||
|
||||
|
||||
|
||||
template <net_message_c NETMSG_T, net_connection_proto_c NETPROTO_T>
|
||||
template <net_message_c NETMSG_T, transport_proto_c NET_TRANSP_PROTO_T, net_repr_proto_c NET_REPR_PROTO_T>
|
||||
class net_connection_t
|
||||
{
|
||||
public:
|
||||
typedef NETMSG_T message_t;
|
||||
typedef NETPROTO_T netproto_t;
|
||||
typedef NET_REPR_PROTO_T net_repr_proto_t;
|
||||
|
||||
typedef std::error_code error_t;
|
||||
typedef std::expected<message_t, error_t> recv_result_t;
|
||||
@@ -165,6 +165,7 @@ protected:
|
||||
|
||||
|
||||
|
||||
static_assert(net_connection_c<asio::net_connection_t<keyval_netmsg_t<>, netproto_stopseq_t<>>>, "!!!");
|
||||
static_assert(net_connection_c<asio::net_connection_t<keyval_netmsg_t<>, ::asio::ip::tcp, netproto_stopseq_t<>>>,
|
||||
"!!!");
|
||||
|
||||
} // namespace snplib::asio
|
||||
Reference in New Issue
Block a user