StormByte C++ Library 0.0.9999
StormByte is a comprehensive, cross-platform C++ library aimed at easing system programming, configuration management, logging, and database handling tasks. This library provides a unified API that abstracts away the complexities and inconsistencies of different platforms (Windows, Linux).
Loading...
Searching...
No Matches
Public Member Functions | List of all members
StormByte::Buffer::Producer Class Referencefinal

A write-only interface for accessing a shared buffer. More...

#include <producer.hxx>

Public Member Functions

 Producer () noexcept
 Default constructor.
 
 Producer (const Consumer &consumer)
 Constructor.
 
 Producer (std::shared_ptr< Shared > shared) noexcept
 Constructor.
 
 Producer (const Simple &simple) noexcept
 Constructor.
 
 Producer (Simple &&simple) noexcept
 Move constructor.
 
 Producer (const Producer &other)=default
 Deleted copy constructor.
 
 Producer (Producer &&other) noexcept=default
 Default move constructor.
 
 ~Producer () noexcept=default
 Destructor.
 
Produceroperator= (const Producer &other)=default
 Deleted copy assignment operator.
 
Produceroperator= (Producer &&other) noexcept=default
 Default move assignment operator.
 
Produceroperator= (const Consumer &consumer) noexcept
 Assignment operator using a consumer.
 
Produceroperator<< (const Status &status)
 Sets the buffer status.
 
Produceroperator<< (const Simple &buffer)
 Appends a buffer to the current buffer.
 
Produceroperator<< (Simple &&buffer)
 Moves a buffer and appends it to the current buffer.
 
Produceroperator<< (const std::string &data)
 Appends a string to the current shared buffer.
 
Produceroperator<< (const Buffer::Data &data)
 Appends a byte vector to the current shared buffer.
 
Produceroperator<< (Buffer::Data &&data)
 Moves a byte vector and appends it to the current shared buffer.
 
Consumer Consumer () const noexcept
 Gets the consumer interface to consume this buffer.
 
void Lock ()
 Locks the shared buffer for exclusive access. Prevents other threads from reading or writing to the buffer until Unlock() is called.
 
void Reserve (const std::size_t &size)
 Reserves shared buffer size.
 
void Unlock ()
 Unlocks the shared buffer, releasing exclusive access. Allows other threads to access the buffer after it has been locked using Lock().
 
Write::Status Write (const Simple &buffer)
 Writes a simple buffer to the current shared buffer.
 
Write::Status Write (Simple &&buffer)
 Moves a simple buffer and writes it to the current shared buffer.
 
Write::Status Write (const std::string &data)
 Writes a string to the current shared buffer.
 
Write::Status Write (const Buffer::Data &data)
 Writes a byte vector to the current shared buffer.
 
Write::Status Write (Buffer::Data &&data)
 Moves a byte vector and writes it to the current shared buffer.
 

Detailed Description

A write-only interface for accessing a shared buffer.

Forward declaration of the Producer class.

The Producer class provides a thread-safe, write-only interface for modifying data in a shared buffer. Unlike Consumer, empty Producer instances can be created directly. This allows for flexibility in scenarios where a producer needs to be initialized without an associated shared buffer.

Key Features:

Constructor & Destructor Documentation

◆ Producer() [1/7]

StormByte::Buffer::Producer::Producer ( )
noexcept

Default constructor.

Initializes an empty producer buffer. Unlike Consumer, empty Producer instances can be created directly. This allows for flexibility in scenarios where a producer needs to be initialized without an associated shared buffer.

◆ Producer() [2/7]

StormByte::Buffer::Producer::Producer ( const Consumer consumer)

Constructor.

Binds a producer with a consumer

Parameters
consumerThe consumer to bind to.

◆ Producer() [3/7]

StormByte::Buffer::Producer::Producer ( std::shared_ptr< Shared shared)
noexcept

Constructor.

Initializes a producer with a shared buffer.

Parameters
sharedThe shared buffer to bind to.

◆ Producer() [4/7]

StormByte::Buffer::Producer::Producer ( const Simple simple)
noexcept

Constructor.

Initializes a producer with a simple buffer.

Parameters
simpleThe simple buffer to bind to.

◆ Producer() [5/7]

StormByte::Buffer::Producer::Producer ( Simple &&  simple)
noexcept

Move constructor.

Initializes a producer with a simple buffer.

Parameters
simpleThe simple buffer to bind to.

◆ Producer() [6/7]

StormByte::Buffer::Producer::Producer ( const Producer other)
default

Deleted copy constructor.

The Producer class cannot be copied to ensure data integrity and prevent unintended sharing of the buffer.

◆ Producer() [7/7]

StormByte::Buffer::Producer::Producer ( Producer &&  other)
defaultnoexcept

Default move constructor.

Allows moving a Producer instance. The moved-from instance is left in a valid but unspecified state.

◆ ~Producer()

StormByte::Buffer::Producer::~Producer ( )
defaultnoexcept

Destructor.

Cleans up the Producer instance. The destructor ensures that any resources held by the Producer are properly released.

Member Function Documentation

◆ Consumer()

Consumer StormByte::Buffer::Producer::Consumer ( ) const
noexcept

Gets the consumer interface to consume this buffer.

Creates and returns a Consumer instance that is bound to this producer's shared buffer. The returned Consumer instance allows read-only access to the buffer.

Returns
A Consumer instance bound to this producer's buffer.

◆ operator<<() [1/6]

Producer & StormByte::Buffer::Producer::operator<< ( Buffer::Data &&  data)

Moves a byte vector and appends it to the current shared buffer.

Parameters
dataThe byte vector to append.
Returns
Reference to the updated producer.

◆ operator<<() [2/6]

Producer & StormByte::Buffer::Producer::operator<< ( const Buffer::Data data)

Appends a byte vector to the current shared buffer.

Parameters
dataThe byte vector to append.
Returns
Reference to the updated producer.

◆ operator<<() [3/6]

Producer & StormByte::Buffer::Producer::operator<< ( const Simple buffer)

Appends a buffer to the current buffer.

Parameters
bufferThe buffer to append.
Returns
Reference to the updated producer.

◆ operator<<() [4/6]

Producer & StormByte::Buffer::Producer::operator<< ( const Status status)

Sets the buffer status.

See also
Buffer::Status

◆ operator<<() [5/6]

Producer & StormByte::Buffer::Producer::operator<< ( const std::string &  data)

Appends a string to the current shared buffer.

Parameters
dataThe string to append.
Returns
Reference to the updated producer.

◆ operator<<() [6/6]

Producer & StormByte::Buffer::Producer::operator<< ( Simple &&  buffer)

Moves a buffer and appends it to the current buffer.

Parameters
bufferThe buffer to append.
Returns
Reference to the updated producer.

◆ operator=() [1/3]

Producer & StormByte::Buffer::Producer::operator= ( const Consumer consumer)
noexcept

Assignment operator using a consumer.

Allows binding a producer to a consumer. This is useful for initializing a producer with an existing consumer.

◆ operator=() [2/3]

Producer & StormByte::Buffer::Producer::operator= ( const Producer other)
default

Deleted copy assignment operator.

The Producer class cannot be copied to ensure data integrity and prevent unintended sharing of the buffer.

◆ operator=() [3/3]

Producer & StormByte::Buffer::Producer::operator= ( Producer &&  other)
defaultnoexcept

Default move assignment operator.

Allows moving a Producer instance. The moved-from instance is left in a valid but unspecified state.

◆ Reserve()

void StormByte::Buffer::Producer::Reserve ( const std::size_t &  size)

Reserves shared buffer size.

Parameters
sizeThe size to reserve.

◆ Write() [1/5]

Write::Status StormByte::Buffer::Producer::Write ( Buffer::Data &&  data)

Moves a byte vector and writes it to the current shared buffer.

Parameters
dataThe byte vector to write.
Returns
Write::Status of the operation.

◆ Write() [2/5]

Write::Status StormByte::Buffer::Producer::Write ( const Buffer::Data data)

Writes a byte vector to the current shared buffer.

Parameters
dataThe byte vector to write.
Returns
Write::Status of the operation.

◆ Write() [3/5]

Write::Status StormByte::Buffer::Producer::Write ( const Simple buffer)

Writes a simple buffer to the current shared buffer.

Parameters
bufferThe simple buffer to write.
Returns
Write::Status of the operation.

◆ Write() [4/5]

Write::Status StormByte::Buffer::Producer::Write ( const std::string &  data)

Writes a string to the current shared buffer.

Parameters
dataThe string to write.
Returns
Write::Status of the operation.

◆ Write() [5/5]

Write::Status StormByte::Buffer::Producer::Write ( Simple &&  buffer)

Moves a simple buffer and writes it to the current shared buffer.

Parameters
bufferThe simple buffer to write.
Returns
Write::Status of the operation.

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