forb
Public Types | Public Member Functions | List of all members
forb::streams::stream Class Referenceabstract

Virtual class that represents a stream. More...

#include <stream.hpp>

Inheritance diagram for forb::streams::stream:
forb::streams::shared_memory forb::streams::socket

Public Types

enum  type : call_id_t { SOCKET = 0, SHMEM = 1 << (std::numeric_limits<call_id_t>::digits - 1) }
 The type of the stream. More...
 
using size_t = std::size_t
 An unsigned size type.
 

Public Member Functions

virtual ~stream () noexcept=default
 This class is virtual, so it requires a virtual destructor. More...
 
virtual void send (const void *buffer, size_t sise)=0
 Blocking send operation. More...
 
virtual void recv (void *buffer, size_t sise)=0
 Blocking receive operation. More...
 
virtual void close ()=0
 Closes the stream.
 
virtual type get_type () const =0
 Returns the type of the stream, either type::SOCKET or type::SHMEM.
 
virtual bool require_marshal () const
 Returns true if the execution platform requires marshalling before sending data over the stream, false otherwise. More...
 

Detailed Description

Virtual class that represents a stream.

The actual implementations of this class (socket or shared_memory) may rely on a unidirectional data channel to perform communication. The classes that use this stream shall ensure that there won't be concurrent access to an end of the stream (either input or output), otherwise the behavior of the stream is undefined. Concurrent access to different ends of the stream is instead a good practice, also because some implementations may block a sending task waiting for a receiving task to free some space consuming data.

Member Enumeration Documentation

§ type

The type of the stream.

The underlying value of the enumeration uses the most significant bit to check the socket type, so it can be bit-wisely ORed with the remotely called method ID.

Constructor & Destructor Documentation

§ ~stream()

virtual forb::streams::stream::~stream ( )
virtualdefaultnoexcept

This class is virtual, so it requires a virtual destructor.

It has no fields, so no copy/move operations are needed.

Member Function Documentation

§ recv()

virtual void forb::streams::stream::recv ( void *  buffer,
size_t  sise 
)
pure virtual

Blocking receive operation.

It repeats the underlying call until all data are received or an error occurs.

Implemented in forb::streams::socket, and forb::streams::shared_memory.

§ require_marshal()

virtual bool forb::streams::stream::require_marshal ( ) const
inlinevirtual

Returns true if the execution platform requires marshalling before sending data over the stream, false otherwise.

Reimplemented in forb::streams::socket, and forb::streams::shared_memory.

§ send()

virtual void forb::streams::stream::send ( const void *  buffer,
size_t  sise 
)
pure virtual

Blocking send operation.

It repeats the underlying call until all data are received or an error occurs.

Implemented in forb::streams::socket, and forb::streams::shared_memory.


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