From ba6da37569dde1ed7616c14d591134575e6a6879 Mon Sep 17 00:00:00 2001 From: Dennis Brentjes Date: Sun, 16 Oct 2016 21:39:18 +0200 Subject: Updates all the documentation. Mainly covers the network rewrites. --- libcmix-network/client.hpp | 7 +++++-- libcmix-network/protobufclient.hpp | 24 +++++++++++++++++++++++- 2 files changed, 28 insertions(+), 3 deletions(-) (limited to 'libcmix-network') diff --git a/libcmix-network/client.hpp b/libcmix-network/client.hpp index 4990667..bd66b98 100644 --- a/libcmix-network/client.hpp +++ b/libcmix-network/client.hpp @@ -75,11 +75,10 @@ public: */ void async_connect(std::string next_host, std::string next_port, std::function on_connect); - inline static void foo() {} - /*! * \brief send sends the string prefixed with it's length over the socket. * \param message The string to be sent. + * \param on_sent The callback to call when the message has been sent. */ template void async_send(std::string message, F on_sent) { @@ -125,6 +124,10 @@ public: */ void on_done(OnDoneFT f); + /*! + * \brief is_open + * \return returns true if the underlying socket is opened. + */ bool is_open() const; diff --git a/libcmix-network/protobufclient.hpp b/libcmix-network/protobufclient.hpp index c28c347..247b71f 100644 --- a/libcmix-network/protobufclient.hpp +++ b/libcmix-network/protobufclient.hpp @@ -6,6 +6,15 @@ #include +/*! + * \file + */ + +/*! + * \brief A wrapper around Client that accepts a Functor that can turn specific protobuf messages. + * in to a desired wireformat to serialize and send or receive via the Client. + * \tparam T The Protobuf functor to use when transforming messages. + */ template class ProtobufClient : private Client { @@ -14,18 +23,31 @@ public: using Client::operator=; using Client::async_connect; - + /*! + * \brief an async_send wrapper that transforms a specific message to the container message an sends it + * \param value The specific message to send. + * \param on_sent The function to call after succesfully sending the message. + */ template void async_send(V value, F on_sent) { typename T::proto_type m = T()(value); Client::async_send(m.SerializeAsString(), on_sent); } + /*! + * \brief an async_send wrapper, like the above but without the on_sent callback. + * \param value The specific message to send. + */ template void async_send(V value) { async_send(value, []{}); } + /*! + * \brief An async_receive wrapper that transforms the wireformat to the protobuf + * container message type. + * \param message_handler The callback to call after receiving a message. + */ template void async_receive(F message_handler) { auto f = [message_handler](std::vector const& buffer) { -- cgit v1.2.3-70-g09d2