From a1b60bcac9ac9b1b1547b576eae9a6e2d9801e24 Mon Sep 17 00:00:00 2001 From: "Timur A. Fatkhullin" Date: Thu, 6 Jun 2024 18:09:32 +0300 Subject: [PATCH] ... --- net/adc_netmsg.h | 23 +++++++++++++++++++++++ net/adc_netservice.h | 32 +++++++++++++++++++++++++++----- 2 files changed, 50 insertions(+), 5 deletions(-) diff --git a/net/adc_netmsg.h b/net/adc_netmsg.h index 9184778..eb9649f 100644 --- a/net/adc_netmsg.h +++ b/net/adc_netmsg.h @@ -68,6 +68,12 @@ public: bool empty() const { return std::ranges::distance(_bytes.begin(), _bytes.end()) == 0; } + size_t byteSize() const + { + // + return std::ranges::distance(_bytes.begin(), _bytes.end()); + } + // get a copy of message bytes template R bytes() const @@ -138,6 +144,17 @@ public: return emp; } + size_t byteSize() const + { + size_t sz = 0; + + for (const auto& el : _bytes | std::views::drop(_reservedNum)) { + sz += std::ranges::distance(el.begin(), el.end()); + } + + return sz; + } + // get a copy of message bytes template R bytes() const @@ -455,6 +472,12 @@ public: virtual ~AdcKeyTokenNetMessage() = default; + size_t byteSize() const + { + size_t sz = base_t::template byteSize(); + return sz + std::distance(this->_bytesbyte[0].begin(), this->_bytes[0].end()); + } + // get a copy of message bytes template R bytes() const diff --git a/net/adc_netservice.h b/net/adc_netservice.h index b3c2d58..fe64d20 100644 --- a/net/adc_netservice.h +++ b/net/adc_netservice.h @@ -7,26 +7,43 @@ ABSTRACT DEVICE COMPONENTS LIBRARY */ +#include namespace adc { -template -class AdcNetService : public IOImplT +template +class AdcNetServiceInterface : public IOImplT { +protected: + AdcNetServiceInterface::socket _socket; + + template + AdcNetServiceInterface(AdcNetServiceInterface::socket&& sock, IOImplCtorArgTs&&... args) + : IOImplT(std::forward(args)...), _socket(sock) + { + } + public: + using typename IOImplT::endpoint; + using typename IOImplT::socket; + + virtual ~AdcNetServiceInterface() = default; + + /* asynchronuos operations */ // open connection template - auto asyncConnect(ArgTs&&... args) + auto asyncConnect(AdcNetServiceInterface::endpoint&& end_point, ArgTs&&... args) { + return IOImplT::asyncConnect(end_point); } template - auto asyncSend(NetMessageT&& msg, ArgTs&&... args) + auto asyncSend(const NetMessageT& msg, ArgTs&&... args) { } @@ -40,7 +57,12 @@ public: /* blocking operations */ template - auto send(NetMessageT&& msg, ArgTs&&... args) + auto connect(const AdcNetServiceInterface::endpoint& end_point, ArgTs&&... args) + { + } + + template + auto send(const NetMessageT& msg, ArgTs&&... args) { }