diff options
-rw-r--r-- | default.nix | 3 | ||||
-rw-r--r-- | modules/io_codec/.nix/derivation.nix | 18 | ||||
-rw-r--r-- | modules/io_codec/c++/SConscript | 8 | ||||
-rw-r--r-- | modules/io_codec/c++/io_peer.hpp | 46 | ||||
-rw-r--r-- | modules/io_codec/examples/SConscript | 5 |
5 files changed, 46 insertions, 34 deletions
diff --git a/default.nix b/default.nix index ef36e43..2d97e9b 100644 --- a/default.nix +++ b/default.nix @@ -63,6 +63,8 @@ in rec { inherit forstio; inherit stdenv; inherit clang-tools; + + build_examples = "true"; }; remote-opencl = pkgs.callPackage modules/remote-opencl/.nix/derivation.nix { @@ -92,6 +94,7 @@ in rec { forstio.codec-netcdf forstio.io forstio.io-tls + forstio.io_codec ]; }; diff --git a/modules/io_codec/.nix/derivation.nix b/modules/io_codec/.nix/derivation.nix index aa5deb8..d810a6b 100644 --- a/modules/io_codec/.nix/derivation.nix +++ b/modules/io_codec/.nix/derivation.nix @@ -4,11 +4,10 @@ , clang-tools , version , forstio +, build_examples ? "false" }: -let - -in stdenv.mkDerivation { +stdenv.mkDerivation { pname = "forstio-io_codec"; inherit version; src = ./..; @@ -27,5 +26,16 @@ in stdenv.mkDerivation { forstio.codec ]; - outputs = ["out" "dev"]; + outputs = [ + "out" + "dev" + ]; + + buildPhase = '' + scons build_examples=${build_examples} + ''; + + installPhase = '' + scons prefix=$out build_examples=${build_examples} install + ''; } 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 diff --git a/modules/io_codec/examples/SConscript b/modules/io_codec/examples/SConscript index 5c35209..f8f6353 100644 --- a/modules/io_codec/examples/SConscript +++ b/modules/io_codec/examples/SConscript @@ -23,7 +23,10 @@ examples_env.echo_client = examples_env.Program('#bin/peer_echo_client', ['peer_ #examples_env.echo_server = examples_env.Program('#bin/peer_echo_server', ['peer_echo_server.cpp', env.library_static]); # Set Alias -env.examples = [examples_env.echo_client, examples_env.echo_server]; +env.examples = [ + examples_env.echo_client +#, examples_env.echo_server +]; env.Alias('examples', env.examples); if env["build_examples"]: |