Commit 60c7e61e authored by Jakob Otto's avatar Jakob Otto

Cleanup packet_writer

parent 31434abc
...@@ -27,19 +27,22 @@ ...@@ -27,19 +27,22 @@
namespace caf { namespace caf {
namespace net { namespace net {
/// Implements an interface for packet writing in application-layers.
class packet_writer { class packet_writer {
public: public:
using buffer_type = std::vector<byte>; using buffer_type = std::vector<byte>;
// virtual ~packet_writer() = default; virtual ~packet_writer() = default;
/// Returns the next header_buffer from transport
virtual buffer_type next_header_buffer() = 0; virtual buffer_type next_header_buffer() = 0;
/// Returns the next payload_buffer from transport
virtual buffer_type next_buffer() = 0; virtual buffer_type next_buffer() = 0;
// TODO: some documentation /// Convenience function to write a packet consisting of multiple buffers.
// First buffer is header. /// @param buffers the buffers that make up the packet. first buffer should
// Following buffers are one or more payload buffers for this packet. /// contain the header.
/// @warning takes ownership of `buffers`. /// @warning takes ownership of `buffers`.
template <class... Ts> template <class... Ts>
void write_packet(Ts&... buffers) { void write_packet(Ts&... buffers) {
...@@ -48,6 +51,8 @@ public: ...@@ -48,6 +51,8 @@ public:
} }
protected: protected:
/// Actual write_packet implementation.
/// @param buffers `span` containing all buffers of a packet.
virtual void write_impl(span<buffer_type*> buffers) = 0; virtual void write_impl(span<buffer_type*> buffers) = 0;
}; };
......
...@@ -27,7 +27,7 @@ namespace caf { ...@@ -27,7 +27,7 @@ namespace caf {
namespace net { namespace net {
/// Implements the interface for transport and application policies and /// Implements the interface for transport and application policies and
/// dispatches member functions either to `decorator` or `parent`. /// dispatches member functions either to `object` or `parent`.
template <class Object, class Parent> template <class Object, class Parent>
class packet_writer_impl final : public packet_writer { class packet_writer_impl final : public packet_writer {
public: public:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment