...
This commit is contained in:
@@ -8,23 +8,19 @@ ABSTRACT DEVICE COMPONENTS LIBRARY
|
||||
|
||||
|
||||
#include <chrono>
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
|
||||
|
||||
namespace adc
|
||||
{
|
||||
|
||||
|
||||
template <typename NetMessageT>
|
||||
class AdcNetServiceAbstractImplementation;
|
||||
|
||||
|
||||
template <typename NetMessageT, typename ImplT>
|
||||
class AdcNetService
|
||||
{
|
||||
protected:
|
||||
std::unique_ptr<ImplT> _implUptr;
|
||||
ImplT _impl;
|
||||
|
||||
public:
|
||||
using typename ImplT::endpoint_t;
|
||||
@@ -36,9 +32,11 @@ public:
|
||||
static constexpr timeout_drtn_t defaultSendTimeout = std::chrono::seconds(5);
|
||||
static constexpr timeout_drtn_t defaultRecvTimeout = std::chrono::seconds(5);
|
||||
|
||||
AdcNetService(ImplT* impl) : _implUptr(impl) {}
|
||||
template <typename... ImplCtorArgTs>
|
||||
AdcNetService(ImplCtorArgTs&&... ctor_args) : _impl(std::forward<ImplCtorArgTs>(ctor_args)...)
|
||||
{
|
||||
}
|
||||
|
||||
AdcNetService(std::unique_ptr<ImplT> impl) : _implUptr(std::move(impl)) {}
|
||||
|
||||
virtual ~AdcNetService() = default;
|
||||
|
||||
@@ -46,25 +44,22 @@ public:
|
||||
/* asynchronuos operations */
|
||||
|
||||
// open connection
|
||||
template <typename... ArgTs>
|
||||
auto asyncConnect(const endpoint_t& end_point,
|
||||
const timeout_drtn_t& timeout = defaultConnectTimeout,
|
||||
ArgTs&&... args)
|
||||
auto asyncConnect(const endpoint_t& end_point, const timeout_drtn_t& timeout = defaultConnectTimeout)
|
||||
{
|
||||
return _implUptr->asyncConnect(end_point, timeout, std::forward<ArgTs>(args)...);
|
||||
return _impl.asyncConnect(end_point, timeout);
|
||||
}
|
||||
|
||||
|
||||
template <typename... ArgTs>
|
||||
auto asyncSend(const NetMessageT& msg, const timeout_drtn_t& timeout = defaultSendTimeout, ArgTs&&... args)
|
||||
{
|
||||
return _implUptr->asyncSend(msg, timeout, std::forward<ArgTs>(args)...);
|
||||
return _impl.asyncSend(msg, timeout, std::forward<ArgTs>(args)...);
|
||||
}
|
||||
|
||||
template <typename... ArgTs>
|
||||
auto asyncReceive(const timeout_drtn_t& timeout = defaultRecvTimeout, ArgTs&&... args)
|
||||
{
|
||||
return _implUptr->asyncReceive(timeout, std::forward<ArgTs>(args)...);
|
||||
return _impl.asyncReceive(timeout, std::forward<ArgTs>(args)...);
|
||||
}
|
||||
|
||||
|
||||
@@ -74,26 +69,26 @@ public:
|
||||
template <typename... ArgTs>
|
||||
auto connect(const endpoint_t& endpoint, const timeout_drtn_t& timeout = defaultConnectTimeout, ArgTs&&... args)
|
||||
{
|
||||
return _implUptr->connect(endpoint, timeout, std::forward<ArgTs>(args)...);
|
||||
return _impl.connect(endpoint, timeout, std::forward<ArgTs>(args)...);
|
||||
}
|
||||
|
||||
template <typename... ArgTs>
|
||||
auto send(const NetMessageT& msg, const timeout_drtn_t& timeout = defaultSendTimeout, ArgTs&&... args)
|
||||
{
|
||||
return _implUptr->send(msg, timeout, std::forward<ArgTs>(args)...);
|
||||
return _impl.send(msg, timeout, std::forward<ArgTs>(args)...);
|
||||
}
|
||||
|
||||
|
||||
template <typename... ArgTs>
|
||||
NetMessageT receive(const timeout_drtn_t& timeout = defaultRecvTimeout, ArgTs&&... args)
|
||||
{
|
||||
return _implUptr->receive(timeout, std::forward<ArgTs>(args)...);
|
||||
return _impl.receive(timeout, std::forward<ArgTs>(args)...);
|
||||
}
|
||||
|
||||
template <typename... ArgTs>
|
||||
auto close(ArgTs&&... args)
|
||||
{
|
||||
return _implUptr->close(std::forward<ArgTs>(args)...);
|
||||
return _impl.close(std::forward<ArgTs>(args)...);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user