...
This commit is contained in:
@@ -28,12 +28,11 @@ concept adc_time_duration_c = requires {
|
||||
} // namespace traits
|
||||
|
||||
|
||||
template <typename ImplT>
|
||||
class AdcNetService
|
||||
{
|
||||
protected:
|
||||
ImplT _impl;
|
||||
/* The class incapsulates network operations */
|
||||
|
||||
template <typename ImplT>
|
||||
class AdcNetService : public ImplT
|
||||
{
|
||||
public:
|
||||
using impl_t = ImplT;
|
||||
|
||||
@@ -42,7 +41,7 @@ public:
|
||||
using typename ImplT::timeout_t;
|
||||
|
||||
template <typename... ImplCtorArgTs>
|
||||
AdcNetService(ImplCtorArgTs&&... ctor_args) : _impl(std::forward<ImplCtorArgTs>(ctor_args)...)
|
||||
AdcNetService(ImplCtorArgTs&&... ctor_args) : impl_t(std::forward<ImplCtorArgTs>(ctor_args)...)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -52,53 +51,60 @@ public:
|
||||
|
||||
/* asynchronuos operations */
|
||||
|
||||
// open connection
|
||||
// start accepting client connections (server side)
|
||||
template <typename... ArgTs>
|
||||
auto asyncAccept(const endpoint_t& end_point, const timeout_t& timeout, ArgTs&&... args)
|
||||
{
|
||||
return impl_t::asyncAccept(end_point, timeout, std::forward<ArgTs>(args)...);
|
||||
}
|
||||
|
||||
// open connection (client side)
|
||||
template <typename... ArgTs>
|
||||
auto asyncConnect(const endpoint_t& end_point, const timeout_t& timeout, ArgTs&&... args)
|
||||
{
|
||||
return _impl.asyncConnect(end_point, timeout, std::forward<ArgTs>(args)...);
|
||||
return impl_t::asyncConnect(end_point, timeout, std::forward<ArgTs>(args)...);
|
||||
}
|
||||
|
||||
|
||||
template <traits::adc_netmessage_c NetMessageT, typename... ArgTs>
|
||||
auto asyncSend(const NetMessageT& msg, const timeout_t& timeout, ArgTs&&... args)
|
||||
{
|
||||
return _impl.asyncSend(msg, timeout, std::forward<ArgTs>(args)...);
|
||||
return impl_t::asyncSend(msg, timeout, std::forward<ArgTs>(args)...);
|
||||
}
|
||||
|
||||
template <traits::adc_netmessage_c NetMessageT, typename... ArgTs>
|
||||
auto asyncReceive(const timeout_t& timeout, ArgTs&&... args)
|
||||
{
|
||||
return _impl.asyncReceive(timeout, std::forward<ArgTs>(args)...);
|
||||
return impl_t::asyncReceive(timeout, std::forward<ArgTs>(args)...);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* blocking operations */
|
||||
/* blocking operations (throw exceptions if there is an error) */
|
||||
|
||||
template <typename... ArgTs>
|
||||
auto connect(const endpoint_t& endpoint, const timeout_t& timeout, ArgTs&&... args)
|
||||
{
|
||||
return _impl.connect(endpoint, timeout, std::forward<ArgTs>(args)...);
|
||||
return impl_t::connect(endpoint, timeout, std::forward<ArgTs>(args)...);
|
||||
}
|
||||
|
||||
template <traits::adc_netmessage_c NetMessageT, typename... ArgTs>
|
||||
auto send(const NetMessageT& msg, const timeout_t& timeout, ArgTs&&... args)
|
||||
{
|
||||
return _impl.send(msg, timeout, std::forward<ArgTs>(args)...);
|
||||
return impl_t::send(msg, timeout, std::forward<ArgTs>(args)...);
|
||||
}
|
||||
|
||||
|
||||
template <traits::adc_netmessage_c NetMessageT, typename... ArgTs>
|
||||
NetMessageT receive(const timeout_t& timeout, ArgTs&&... args)
|
||||
{
|
||||
return _impl.receive(timeout, std::forward<ArgTs>(args)...);
|
||||
return impl_t::receive(timeout, std::forward<ArgTs>(args)...);
|
||||
}
|
||||
|
||||
template <typename... ArgTs>
|
||||
auto close(ArgTs&&... args)
|
||||
{
|
||||
return _impl.close(std::forward<ArgTs>(args)...);
|
||||
return impl_t::close(std::forward<ArgTs>(args)...);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user