summaryrefslogtreecommitdiff
path: root/modules/io_codec/c++
diff options
context:
space:
mode:
authorClaudius "keldu" Holeksa <mail@keldu.de>2024-04-15 20:43:48 +0200
committerClaudius "keldu" Holeksa <mail@keldu.de>2024-04-15 20:43:48 +0200
commit1a2299a70280867b93fde4050833d4bd2b419884 (patch)
tree773299de044b5c4bac1097759f127a53ff99bf8f /modules/io_codec/c++
parent3432c661572c8e0b6c8b4b34536e6e9ce2f87039 (diff)
nix,io_codec: Fixing old streaming peer code
Diffstat (limited to 'modules/io_codec/c++')
-rw-r--r--modules/io_codec/c++/SConscript8
-rw-r--r--modules/io_codec/c++/io_peer.hpp46
2 files changed, 25 insertions, 29 deletions
diff --git a/modules/io_codec/c++/SConscript b/modules/io_codec/c++/SConscript
index 2a277cb..7dc7ada 100644
--- a/modules/io_codec/c++/SConscript
+++ b/modules/io_codec/c++/SConscript
@@ -21,18 +21,18 @@ env.headers += io_env.headers;
## Shared lib
objects_shared = []
io_env.add_source_files(objects_shared, io_env.sources, shared=True);
-io_env.library_shared = io_env.SharedLibrary('#build/forstio-io_codec', [objects_shared]);
+env.library_shared = io_env.SharedLibrary('#build/forstio-io_codec', [objects_shared]);
## Static lib
objects_static = []
io_env.add_source_files(objects_static, io_env.sources, shared=False);
-io_env.library_static = io_env.StaticLibrary('#build/forstio-io_codec', [objects_static]);
+env.library_static = io_env.StaticLibrary('#build/forstio-io_codec', [objects_static]);
# Set Alias
-env.Alias('library_io_codec', [io_env.library_shared, io_env.library_static]);
+env.Alias('library_io_codec', [env.library_shared, env.library_static]);
env.targets += ['library_io_codec'];
# Install
-env.Install('$prefix/lib/', [io_env.library_shared, io_env.library_static]);
+env.Install('$prefix/lib/', [env.library_shared, env.library_static]);
env.Install('$prefix/include/forstio/io_codec/', [io_env.headers]);
diff --git a/modules/io_codec/c++/io_peer.hpp b/modules/io_codec/c++/io_peer.hpp
index a92e236..8ba6ee1 100644
--- a/modules/io_codec/c++/io_peer.hpp
+++ b/modules/io_codec/c++/io_peer.hpp
@@ -2,14 +2,13 @@
#include <forstio/async/async.hpp>
#include <forstio/buffer.hpp>
-#include <forsto/io/io.hpp>
-#include <forstio/schema/message.hpp>
+#include <forstio/io/io.hpp>
+#include <forstio/codec/data.hpp>
namespace saw {
-template <typename Codec, typename Incoming, typename Outgoing,
- typename InContainer = message_container<Incoming>,
- typename OutContainer = message_container<Outgoing>,
+template <typename Incoming, typename Outgoing,
+ typename Encoding,
typename BufferT = ring_buffer>
class streaming_io_peer {
public:
@@ -17,14 +16,14 @@ public:
* Constructor with the option to provide a custom codec, in and out buffer
*/
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<Encoding> codec, BufferT in, BufferT out);
/**
* Constructor
*/
streaming_io_peer(
- own<conveyor_feeder<heap_message_root<Incoming, InContainer>>> feed,
+ own<conveyor_feeder<data<Incoming, Encoding>>> feed,
own<async_io_stream> stream);
/**
@@ -36,47 +35,46 @@ public:
/**
* Send a message to the remote peer
*/
- error_or<void> send(heap_message_root<Outgoing, OutContainer> builder);
+ error_or<void> send(data<Outgoing, Encoding> builder);
/**
* A phantom conveyor feeder. Meant for interfacing with other components
*/
- conveyor_feeder<heap_message_root<Outgoing, OutContainer>> &feeder();
+ conveyor_feeder<data<Outgoing, Encoding>> &feeder();
conveyor<void> on_read_disconnected();
private:
/// @unimplemented
class peer_conveyor_feeder final
- : public conveyor_feeder<heap_message_root<Outgoing, OutContainer>> {
+ : public conveyor_feeder<data<Outgoing, Encoding>> {
public:
peer_conveyor_feeder(
- streaming_io_peer<Codec, Incoming, Outgoing, InContainer,
- OutContainer, BufferT> &peer_)
+ streaming_io_peer<Incoming, Outgoing, Encoding, BufferT> &peer_)
: peer_{peer_} {}
- void feed(heap_message_root<Outgoing, OutContainer> &&data) override {
- (void)data;
+ void feed(data<Outgoing, Encoding> &&data_) override {
+ (void)data_;
}
- void fail(error &&error) override { (void)error; }
+ void fail(error &&err) override { (void)err; }
size_t space() const override { return 0; }
size_t queued() const override { return 0; }
private:
- streaming_io_peer<Codec, Incoming, Outgoing, InContainer, OutContainer,
+ streaming_io_peer<Incoming, Outgoing, Encoding,
BufferT> &peer_;
};
private:
- own<conveyor_feeder<heap_message_root<Incoming, InContainer>>>
+ own<conveyor_feeder<data<Incoming, Encoding>>>
incoming_feeder_ = nullptr;
own<async_io_stream> io_stream_;
- Codec codec_;
+ codec<Encoding> codec_;
BufferT in_buffer_;
BufferT out_buffer_;
@@ -91,13 +89,11 @@ private:
* Setup new streaming io peer with the provided network protocols.
* This is a convenience wrapper intended for a faster setup of this class
*/
-template <typename Codec, typename Incoming, typename Outgoing,
- typename InContainer = message_container<Incoming>,
- typename OutContainer = message_container<Outgoing>,
+template <typename Incoming, typename Outgoing,
+ typename Encoding,
typename BufferT = ring_buffer>
-std::pair<own<streaming_io_peer<Codec, Incoming, Outgoing, InContainer,
- OutContainer, BufferT>>,
- conveyor<heap_message_root<Incoming, InContainer>>>
+std::pair<own<streaming_io_peer<Incoming, Outgoing, Encoding, BufferT>>,
+ conveyor<data<Incoming, Encoding>>>
new_streaming_io_peer(own<async_io_stream> stream);
} // namespace saw