diff options
| author | Dennis Brentjes <d.brentjes@gmail.com> | 2016-12-01 14:34:18 +0100 |
|---|---|---|
| committer | Dennis Brentjes <d.brentjes@gmail.com> | 2016-12-01 14:43:00 +0100 |
| commit | bc39d05453340257fff986edfdd728f2a89d13ad (patch) | |
| tree | 34fe208d1ccba0ae891dc23851352d3af6f7ee0f /libcmix-common/sender.hpp | |
| parent | 95283582a0392633974d1f3f67d5510a16eb104c (diff) | |
| download | cmix-bc39d05453340257fff986edfdd728f2a89d13ad.tar.gz cmix-bc39d05453340257fff986edfdd728f2a89d13ad.tar.bz2 cmix-bc39d05453340257fff986edfdd728f2a89d13ad.zip | |
Removed a large chunk of code duplication in the network code.
Diffstat (limited to 'libcmix-common/sender.hpp')
| -rw-r--r-- | libcmix-common/sender.hpp | 62 |
1 files changed, 22 insertions, 40 deletions
diff --git a/libcmix-common/sender.hpp b/libcmix-common/sender.hpp index c722e30..d1baabe 100644 --- a/libcmix-common/sender.hpp +++ b/libcmix-common/sender.hpp @@ -9,61 +9,43 @@ */ /*! - * \brief forward declaration for SenderReceiver to allow for the friend declaration. + * \brief BaseSender */ -struct SenderReceiver; - -/*! - * \brief The Sender struct is a shim around ProtobufClient and only exposes things needed - * for sending messages. - */ -struct Sender : private ProtobufClient<CMixProtoFunctor> +template<template <typename T> class C, typename F> +struct BaseSender : private C<CMixProtoFunctor> { /*! * The friend declaration that allows for the Sender to be upgraded to a SenderReceiver. */ - friend SenderReceiver; + friend F; - using ProtobufClient::ProtobufClient; - using ProtobufClient::operator=; + using C<CMixProtoFunctor>::C; + using C<CMixProtoFunctor>::operator=; - using ProtobufClient::async_send; + using C<CMixProtoFunctor>::async_send; - using ProtobufClient::async_connect; + using C<CMixProtoFunctor>::async_connect; - using ProtobufClient::close; + using C<CMixProtoFunctor>::close; - using ProtobufClient::on_done; + using C<CMixProtoFunctor>::on_done; - using ProtobufClient::is_open; + using C<CMixProtoFunctor>::is_open; }; /*! - * \brief forward declaration for SenderReceiver to allow for the friend declaration. + * \brief forward declaration for BaseSenderReceiver to allow for the friend declaration. */ -struct SSLSenderReceiver; +template <template <typename T> class C> +struct BaseSenderReceiver; /*! - * \brief The Sender struct is a shim around ProtobufClient and only exposes things needed - * for sending messages. + * \brief Conveniance typedef for Sender */ -struct SSLSender : private SSLProtobufClient<CMixProtoFunctor> -{ - /*! - * The friend declaration that allows for the Sender to be upgraded to a SenderReceiver. - */ - friend SSLSenderReceiver; - - using SSLProtobufClient::SSLProtobufClient; - using SSLProtobufClient::operator=; - - using SSLProtobufClient::async_send; - - using SSLProtobufClient::async_connect; - - using SSLProtobufClient::close; - - using SSLProtobufClient::on_done; - - using SSLProtobufClient::is_open; -}; +using Sender = BaseSender<ProtobufClient, BaseSenderReceiver<ProtobufClient>>; + +/*! + * \brief Conveniance typedef for SSLSender + */ + +using SSLSender = BaseSender<SSLProtobufClient, BaseSenderReceiver<SSLProtobufClient>>;
\ No newline at end of file |
