aboutsummaryrefslogtreecommitdiff
path: root/libcmix-common/receiver.hpp
diff options
context:
space:
mode:
authorDennis Brentjes <d.brentjes@gmail.com>2016-12-01 14:34:18 +0100
committerDennis Brentjes <d.brentjes@gmail.com>2016-12-01 14:43:00 +0100
commitbc39d05453340257fff986edfdd728f2a89d13ad (patch)
tree34fe208d1ccba0ae891dc23851352d3af6f7ee0f /libcmix-common/receiver.hpp
parent95283582a0392633974d1f3f67d5510a16eb104c (diff)
downloadcmix-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/receiver.hpp')
-rw-r--r--libcmix-common/receiver.hpp58
1 files changed, 23 insertions, 35 deletions
diff --git a/libcmix-common/receiver.hpp b/libcmix-common/receiver.hpp
index efd3753..ddb2826 100644
--- a/libcmix-common/receiver.hpp
+++ b/libcmix-common/receiver.hpp
@@ -7,56 +7,44 @@
/*!
* \file
*/
-struct SenderReceiver;
/*!
- * \brief The Receiver struct is a shim around ProtobufClient and only exposes things needed
- * for receiving messages.
+ * \brief BaseReceiver
*/
-struct Receiver : private ProtobufClient<CMixProtoFunctor>
+template<template <typename T> class C, typename F>
+struct BaseReceiver : private C<CMixProtoFunctor>
{
/*!
* \brief friend decleration allowing Receivers to be upgraded to SenderReceivers.
*/
- friend SenderReceiver;
+ friend F;
- using ProtobufClient::ProtobufClient;
- using ProtobufClient::operator=;
+ using C<CMixProtoFunctor>::C;
+ using C<CMixProtoFunctor>::operator=;
- using ProtobufClient::async_receive;
+ using C<CMixProtoFunctor>::async_receive;
- 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;
};
-struct SSLSenderReceiver;
+/*!
+ * \brief Forward decleration the ability to convert Receivers to SenderReceivers.
+ */
+template <template <typename T> class C>
+struct BaseSenderReceiver;
/*!
- * \brief The Receiver struct is a shim around ProtobufClient and only exposes things needed
- * for receiving messages.
+ * \brief Conveniance typedef for Receiver.
*/
-struct SSLReceiver : private SSLProtobufClient<CMixProtoFunctor>
-{
- /*!
- * \brief friend decleration allowing Receivers to be upgraded to SenderReceivers.
- */
- friend SSLSenderReceiver;
-
- using SSLProtobufClient::SSLProtobufClient;
- using SSLProtobufClient::operator=;
-
- using SSLProtobufClient::async_receive;
-
- using SSLProtobufClient::async_connect;
-
- using SSLProtobufClient::close;
-
- using SSLProtobufClient::on_done;
-
- using SSLProtobufClient::is_open;
-};
+using Receiver = BaseReceiver<ProtobufClient, BaseSenderReceiver<ProtobufClient>>;
+
+/*!
+ * \brief Conveniance typedef for SSLReceiver.
+ */
+using SSLReceiver = BaseReceiver<SSLProtobufClient, BaseSenderReceiver<SSLProtobufClient>>; \ No newline at end of file