Base Framework
Public Member Functions | Static Public Member Functions | List of all members
Pipe Class Reference

Pipe. More...

#include <base/io/Pipe.h>

Inherits Resource, InputStream, and OutputStream.

Public Member Functions

 Pipe () noexcept
 
void close ()
 
unsigned int getBufferSize () const
 
bool atEnd () const
 
unsigned int available () const
 
unsigned int skip (unsigned int count)
 
void flush ()
 
unsigned int read (uint8 *buffer, unsigned int size, bool nonblocking=false)
 
unsigned int write (const uint8 *buffer, unsigned int size, bool nonblocking=false)
 
void wait () const
 
bool wait (unsigned int timeout) const
 
 ~Pipe ()
 
- Public Member Functions inherited from Resource
String getDescription () const
 
void setDescription (const String &description)
 
unsigned int getResourceId () const
 
unsigned int getCreatedById () const
 
AnyReference getHandle () const noexcept
 
template<class TYPE >
TYPE & getInternalHandle () const
 
 operator bool () const noexcept
 
- Public Member Functions inherited from Stream
virtual ~Stream () noexcept(false)
 
- Public Member Functions inherited from ReferenceCountedObject
 ReferenceCountedObject () noexcept
 
 ReferenceCountedObject (const ReferenceCountedObject &copy) noexcept
 
 ReferenceCountedObject (ReferenceCountedObject &&move) noexcept
 
ReferenceCountedObjectoperator= (const ReferenceCountedObject &copy) noexcept
 
ReferenceCountedObjectoperator= (ReferenceCountedObject &&move) noexcept
 
MemorySize getNumberOfReferences_INTERNAL () const noexcept
 
virtual bool useGarbageCollector () const noexcept
 
- Public Member Functions inherited from DynamicObject
 DynamicObject () noexcept
 
bool isValidObject () const noexcept
 
virtual ~DynamicObject () noexcept(false)
 
 _COM_AZURE_DEV__BASE__OVERRIDE_ALLOC ()
 

Static Public Member Functions

static Pair< Pipe, Pipemake ()
 

Additional Inherited Members

- Protected Attributes inherited from Resource
AnyReference handle
 

Detailed Description

Pipe.

This class implements an anonymous pipe. MT-level is safe.

Version
1.2

Constructor & Destructor Documentation

◆ Pipe()

Pipe::Pipe ( )
noexcept

Initializes an invalidated pipe object.

◆ ~Pipe()

Pipe::~Pipe ( )

Destroys the pipe.

Member Function Documentation

◆ atEnd()

bool Pipe::atEnd ( ) const

Returns true if the end of the stream has been reached.

◆ available()

unsigned int Pipe::available ( ) const
virtual

Returns the number of bytes that can be read or skipped over without blocking.

Returns
Available number of bytes in stream.

Implements InputStream.

◆ close()

void Pipe::close ( )
virtual

Closes this pipe.

Implements Stream.

◆ flush()

void Pipe::flush ( )
virtual

Forces any buffered bytes to be written out.

Implements OutputStream.

◆ getBufferSize()

unsigned int Pipe::getBufferSize ( ) const

Returns the size of the internal buffer of the pipe. The data may be interleaved when writing to the pipe from multiple threads simultaneously. To avoid the data being interleaved the packet size must not exceed this buffer size.

◆ make()

static Pair<Pipe, Pipe> Pipe::make ( )
static

Creates a new pair of pipes.

◆ read()

unsigned int Pipe::read ( uint8 *  buffer,
unsigned int  size,
bool  nonblocking = false 
)
virtual

Fills the specified buffer with bytes from the stream. In blocking mode the method does not return until all bytes have been read. In non-blocking mode the total bytes read may be any number below or equal to the requested number of bytes. Attempting to read beyond the end of a stream in blocking mode results in an EndOfFile exception.

Parameters
bufferThe buffer to receive the bytes.
sizeThe size of the buffer.
nonblockingSpecifies that the method may not block.
Returns
The actual number of bytes read from the stream.

Implements InputStream.

◆ skip()

unsigned int Pipe::skip ( unsigned int  count)
virtual

Skips a specified number of bytes. Blocks if asked to skip more bytes than currently available.

Implements InputStream.

◆ wait() [1/2]

void Pipe::wait ( ) const
virtual

Blocking wait for input to become available.

Implements InputStream.

◆ wait() [2/2]

bool Pipe::wait ( unsigned int  timeout) const
virtual

Blocking wait for input to become available.

Parameters
timeoutThe timeout periode in microseconds.
Returns
True, if data is available. False, if the timeout periode expired.

Implements InputStream.

◆ write()

unsigned int Pipe::write ( const uint8 *  buffer,
unsigned int  size,
bool  nonblocking = false 
)
virtual

Writes the specified number of bytes in the buffer to the stream. In blocking mode the method does not return until all bytes have been written. In non-blocking mode the total number of bytes written may be any number below or equal to the requested number of bytes.

Parameters
bufferThe buffer containing the bytes to be written.
sizeThe number of bytes to be written.
nonblockingSpecifies that the method may not block.
Returns
The actual number of bytes written to the stream.

Implements OutputStream.