contur2
Loading...
Searching...
No Matches
contur::Pipe Class Referencefinal

Unidirectional byte-stream IPC channel with bounded capacity. More...

#include <pipe.h>

Inheritance diagram for contur::Pipe:
Collaboration diagram for contur::Pipe:

Public Member Functions

 Pipe (std::string name, std::size_t capacity=1024)
 Creates a pipe with a logical name and capacity.
 ~Pipe () override
 Pipe (const Pipe &)=delete
Pipeoperator= (const Pipe &)=delete
 Pipe (Pipe &&) noexcept
Pipeoperator= (Pipe &&) noexcept
Result< std::size_t > write (std::span< const std::byte > data) override
 Writes bytes into the pipe buffer.
Result< std::size_t > read (std::span< std::byte > buffer) override
 Reads bytes from the pipe buffer in FIFO order.
void close () override
 Closes the pipe and clears buffered data.
bool isOpen () const noexcept override
 Returns whether the pipe is open.
std::string_view name () const noexcept override
 Pipe name.
std::size_t capacity () const noexcept
 Maximum number of bytes that can be buffered.
std::size_t size () const noexcept
 Current number of buffered bytes.
Public Member Functions inherited from contur::IIpcChannel
virtual ~IIpcChannel ()=default

Private Attributes

std::unique_ptr< Impl > impl_

Detailed Description

Unidirectional byte-stream IPC channel with bounded capacity.

Pipe stores bytes in FIFO order. Reads consume bytes from the front.

Definition at line 16 of file pipe.h.

Constructor & Destructor Documentation

◆ Pipe() [1/3]

contur::Pipe::Pipe ( std::string name,
std::size_t capacity = 1024 )
explicit

Creates a pipe with a logical name and capacity.

Parameters
nameChannel name used by registries and diagnostics.
capacityMaximum number of buffered bytes.

◆ ~Pipe()

contur::Pipe::~Pipe ( )
override

◆ Pipe() [2/3]

contur::Pipe::Pipe ( const Pipe & )
delete

◆ Pipe() [3/3]

contur::Pipe::Pipe ( Pipe && )
noexcept

Member Function Documentation

◆ capacity()

std::size_t contur::Pipe::capacity ( ) const
nodiscardnoexcept

Maximum number of bytes that can be buffered.

◆ close()

void contur::Pipe::close ( )
overridevirtual

Closes the pipe and clears buffered data.

Implements contur::IIpcChannel.

◆ isOpen()

bool contur::Pipe::isOpen ( ) const
nodiscardoverridevirtualnoexcept

Returns whether the pipe is open.

Implements contur::IIpcChannel.

◆ name()

std::string_view contur::Pipe::name ( ) const
nodiscardoverridevirtualnoexcept

Pipe name.

Implements contur::IIpcChannel.

◆ operator=() [1/2]

Pipe & contur::Pipe::operator= ( const Pipe & )
delete

◆ operator=() [2/2]

Pipe & contur::Pipe::operator= ( Pipe && )
noexcept

◆ read()

Result< std::size_t > contur::Pipe::read ( std::span< std::byte > buffer)
nodiscardoverridevirtual

Reads bytes from the pipe buffer in FIFO order.

Returns
Read byte count, BufferEmpty if no data, InvalidState if the pipe is closed.

Implements contur::IIpcChannel.

◆ size()

std::size_t contur::Pipe::size ( ) const
nodiscardnoexcept

Current number of buffered bytes.

◆ write()

Result< std::size_t > contur::Pipe::write ( std::span< const std::byte > data)
nodiscardoverridevirtual

Writes bytes into the pipe buffer.

Returns
Written byte count, BufferFull if no free space, InvalidState if the pipe is closed.

Implements contur::IIpcChannel.

Member Data Documentation

◆ impl_

std::unique_ptr<Impl> contur::Pipe::impl_
private

Definition at line 57 of file pipe.h.


The documentation for this class was generated from the following file: