contur2
Loading...
Searching...
No Matches
pipe.h
Go to the documentation of this file.
1
3
4#pragma once
5
6#include <memory>
7#include <string>
8
10
11namespace contur {
12
16 class Pipe final : public IIpcChannel
17 {
18 public:
22 explicit Pipe(std::string name, std::size_t capacity = 1024);
23 ~Pipe() override;
24
25 Pipe(const Pipe &) = delete;
26 Pipe &operator=(const Pipe &) = delete;
27 Pipe(Pipe &&) noexcept;
28 Pipe &operator=(Pipe &&) noexcept;
29
33 [[nodiscard]] Result<std::size_t> write(std::span<const std::byte> data) override;
34
38 [[nodiscard]] Result<std::size_t> read(std::span<std::byte> buffer) override;
39
41 void close() override;
42
44 [[nodiscard]] bool isOpen() const noexcept override;
45
47 [[nodiscard]] std::string_view name() const noexcept override;
48
50 [[nodiscard]] std::size_t capacity() const noexcept;
51
53 [[nodiscard]] std::size_t size() const noexcept;
54
55 private:
56 struct Impl;
57 std::unique_ptr<Impl> impl_;
58 };
59
60} // namespace contur
Common interface for IPC channels.
Pipe & operator=(const Pipe &)=delete
std::string_view name() const noexcept override
Pipe name.
bool isOpen() const noexcept override
Returns whether the pipe is open.
Pipe(std::string name, std::size_t capacity=1024)
Creates a pipe with a logical name and capacity.
Result< std::size_t > write(std::span< const std::byte > data) override
Writes bytes into the pipe buffer.
void close() override
Closes the pipe and clears buffered data.
Result< std::size_t > read(std::span< std::byte > buffer) override
Reads bytes from the pipe buffer in FIFO order.
~Pipe() override
std::unique_ptr< Impl > impl_
Definition pipe.h:57
std::size_t size() const noexcept
Current number of buffered bytes.
Pipe(const Pipe &)=delete
Pipe(Pipe &&) noexcept
std::size_t capacity() const noexcept
Maximum number of bytes that can be buffered.
A result type that holds either a success value of type T or an ErrorCode.
Definition error.h:104
IIpcChannel interface for inter-process communication channels.
Definition block.h:15