summaryrefslogtreecommitdiff
path: root/modules/io_codec
diff options
context:
space:
mode:
authorClaudius "keldu" Holeksa <mail@keldu.de>2024-05-06 10:07:42 +0200
committerClaudius "keldu" Holeksa <mail@keldu.de>2024-05-06 10:07:42 +0200
commit93b05dd8aa20f8db0d6b0eb9d1a8d5b1593f3269 (patch)
tree03db05177c1443a3b099e33759a1b5b0f25632c5 /modules/io_codec
parentd9ad6a70fa70025fdb2dbc0ee27a1f56ff3458e4 (diff)
io_codec: Moving io_peer code to newest code changes
Diffstat (limited to 'modules/io_codec')
-rw-r--r--modules/io_codec/c++/io_peer.hpp7
-rw-r--r--modules/io_codec/c++/io_peer.tmpl.hpp35
2 files changed, 23 insertions, 19 deletions
diff --git a/modules/io_codec/c++/io_peer.hpp b/modules/io_codec/c++/io_peer.hpp
index 8ba6ee1..3efb4c0 100644
--- a/modules/io_codec/c++/io_peer.hpp
+++ b/modules/io_codec/c++/io_peer.hpp
@@ -17,10 +17,10 @@ public:
*/
streaming_io_peer(
own<conveyor_feeder<data<Incoming, Encoding>>> feed,
- own<async_io_stream> stream, codec<Encoding> codec, BufferT in, BufferT out);
+ own<async_io_stream> stream, codec<Incoming, Encoding> in_codec, codec<Outgoing, Encoding> out_codec, BufferT in, BufferT out);
/**
- * Constructor
+ * Constructor with mostly default assignements
*/
streaming_io_peer(
own<conveyor_feeder<data<Incoming, Encoding>>> feed,
@@ -74,7 +74,8 @@ private:
own<async_io_stream> io_stream_;
- codec<Encoding> codec_;
+ codec<Incoming, Encoding> in_codec_;
+ codec<Outgoing, Encoding> out_codec_;
BufferT in_buffer_;
BufferT out_buffer_;
diff --git a/modules/io_codec/c++/io_peer.tmpl.hpp b/modules/io_codec/c++/io_peer.tmpl.hpp
index 342ca42..28bbbfb 100644
--- a/modules/io_codec/c++/io_peer.tmpl.hpp
+++ b/modules/io_codec/c++/io_peer.tmpl.hpp
@@ -1,23 +1,25 @@
namespace saw {
-template <typename Codec, typename Incoming, typename Outgoing,
- typename InContainer, typename OutContainer, typename BufferT>
-streaming_io_peer<Codec, Incoming, Outgoing, InContainer, OutContainer,
+template <typename Incoming, typename Outgoing, typename Encoding,
+ typename BufferT>
+streaming_io_peer<Incoming, Outgoing, Encoding,
BufferT>::
streaming_io_peer(
- own<conveyor_feeder<heap_message_root<Incoming, InContainer>>> feed,
+ own<conveyor_feeder<data<Incoming, Encoding>>> feed,
own<async_io_stream> str)
: streaming_io_peer{std::move(feed), std::move(str), {}, {}, {}} {}
template <typename Codec, typename Incoming, typename Outgoing,
typename InContainer, typename OutContainer, typename BufferT>
-streaming_io_peer<Codec, Incoming, Outgoing, InContainer, OutContainer,
+streaming_io_peer<Codec, Incoming, Outgoing, Encoding,
BufferT>::
streaming_io_peer(
- own<conveyor_feeder<heap_message_root<Incoming, InContainer>>> feed,
- own<async_io_stream> stream, Codec codec, BufferT in, BufferT out)
+ own<conveyor_feeder<data<Incoming, Encoding>>> feed,
+ own<async_io_stream> stream, codec<Incoming, Encoding> in_codec, codec<Outgoing, Encoding> out_codec, BufferT in, BufferT out)
: incoming_feeder_{std::move(feed)},
- io_stream_{std::move(stream)}, codec_{std::move(codec)},
+ io_stream_{std::move(stream)},
+ in_codec_{std::move(in_codec)},
+ out_codec_{std::move(out_codec)},
in_buffer_{std::move(in)}, out_buffer_{std::move(out)},
sink_read_{
io_stream_->read_done()
@@ -32,17 +34,18 @@ streaming_io_peer<Codec, Incoming, Outgoing, InContainer, OutContainer,
in_buffer_.write_segment_length());
while (true) {
- auto root = heap_message_root<Incoming, InContainer>();
- auto builder = root.build();
+ buffer_view in_view{in_buffer_};
+ auto in_data = data<Incoming, Encoding>(in_view);
+ auto nat_data = data<Incoming>{};
- error err = codec_.template decode<Incoming, InContainer>(
- builder, in_buffer_);
+ error err = in_codec_.template decode<Incoming, Encoding>(
+ in_data, nat_data);
if (err.is_critical()) {
return err;
}
if (!err.failed()) {
- incoming_feeder_->feed(std::move(root));
+ incoming_feeder_->feed(std::move(nat_data));
} else {
break;
}
@@ -58,7 +61,7 @@ streaming_io_peer<Codec, Incoming, Outgoing, InContainer, OutContainer,
sink_write_{io_stream_->write_done()
.then([this](size_t bytes) -> error_or<void> {
out_buffer_.read_advance(bytes);
- if (out_buffer_.readCompositeLength() > 0) {
+ if (out_buffer_.read_composite_length() > 0) {
io_stream_->write(
&out_buffer_.read(),
out_buffer_.read_segment_length());
@@ -70,9 +73,9 @@ streaming_io_peer<Codec, Incoming, Outgoing, InContainer, OutContainer,
io_stream_->read(&in_buffer_.write(), 1, in_buffer_.write_segment_length());
}
-template <typename Codec, typename Incoming, typename Outgoing,
+template <typename Incoming, typename Outgoing,
typename InContainer, typename OutContainer, typename BufferT>
-error_or<void> streaming_io_peer<Codec, Incoming, Outgoing, InContainer, OutContainer,
+error_or<void> streaming_io_peer<Codec, Incoming, Outgoing,
BufferT>::send(heap_message_root<Outgoing, OutContainer>
msg) {
bool restart_write = out_buffer_.read_segment_length() == 0;