qb
2.0.0.0
C++17 Actor Framework
|
Base class for the extensible buffer. More...
#include <pipe.h>
Public Member Functions | |
base_pipe () | |
Default constructor. | |
base_pipe (base_pipe const &rhs) | |
Copy constructor. | |
base_pipe (base_pipe &&rhs) noexcept | |
Move constructor. | |
base_pipe & | operator= (base_pipe const &rhs) |
Copy assignment operator. | |
base_pipe & | operator= (base_pipe &&rhs) noexcept |
Move assignment operator. | |
~base_pipe () | |
Destructor. | |
std::size_t | capacity () const noexcept |
Returns the total capacity of the buffer. | |
T * | data () const noexcept |
Returns a pointer to the buffer data. | |
T * | begin () const noexcept |
Returns a pointer to the first valid element. | |
T * | end () const noexcept |
Returns a pointer just after the last valid element. | |
const T * | cbegin () const noexcept |
Returns a constant pointer to the first valid element. | |
const T * | cend () const noexcept |
Returns a constant pointer just after the last valid element. | |
std::size_t | size () const noexcept |
Returns the number of valid elements in the buffer. | |
void | resize (std::size_t new_size) |
Resizes the buffer. | |
void | free_front (std::size_t const size) noexcept |
Frees elements at the beginning of the buffer. | |
void | free_back (std::size_t const size) noexcept |
Frees elements at the end of the buffer. | |
void | reset (std::size_t const begin) noexcept |
Resets the buffer to a specific position. | |
void | reset () noexcept |
Completely resets the buffer. | |
void | clear () noexcept |
Clears the buffer content (alias for reset) | |
bool | empty () const noexcept |
Checks if the buffer is empty. | |
void | free (std::size_t const size) noexcept |
Frees a specified number of elements. | |
auto * | allocate_back (std::size_t const size) |
Allocates space at the end of the buffer. | |
template<typename U, typename... _Init> | |
U & | allocate_back (_Init &&...init) |
Allocates and constructs an object of type U at the end of the buffer. | |
template<typename U, typename... _Init> | |
U & | allocate_size (std::size_t const size, _Init &&...init) |
Allocates space with a custom size and constructs an object. | |
auto | allocate (std::size_t const size) |
Allocates space at the beginning or end of the buffer. | |
template<typename U, typename... _Init> | |
U & | allocate (_Init &&...init) |
Allocates space and constructs an object. | |
template<typename U> | |
U & | recycle_back (U const &data) |
Copies an object to the end of the buffer. | |
template<typename U> | |
U & | recycle_back (U const &data, std::size_t const size) |
Copies data to the end of the buffer. | |
template<typename U> | |
U & | recycle (U const &data) |
Copies an object to the beginning or end of the buffer. | |
template<typename U> | |
U & | recycle (U const &data, std::size_t const size) |
Copies data to the beginning or end of the buffer. | |
void | reorder () noexcept |
Reorganizes the buffer to consolidate free space. | |
void | flush () const noexcept |
Flushes the buffer (synchronization operation, no-op in this class) | |
void | reserve (std::size_t const size) |
Reserves space in the buffer. |
Base class for the extensible buffer.
Implements the fundamental functionalities of an extensible buffer:
T | Type of elements stored in the buffer |
|
inline |
Default constructor.
Initializes an empty buffer with default capacity
|
inline |
Copy constructor.
Copies data from another buffer
rhs | Buffer to copy from |
|
inlinenoexcept |
Move constructor.
Transfers ownership of data from another buffer
rhs | Buffer to move from |
|
inline |
Destructor.
Frees memory allocated by the buffer
|
inlinenoexcept |
Move assignment operator.
rhs | Buffer to move from |
|
inlinenodiscardnoexcept |
Returns the total capacity of the buffer.
|
inlinenodiscardnoexcept |
Returns a pointer to the buffer data.
|
inlinenodiscardnoexcept |
Returns a pointer to the first valid element.
|
inlinenodiscardnoexcept |
Returns a pointer just after the last valid element.
|
inlinenodiscardnoexcept |
Returns a constant pointer to the first valid element.
|
inlinenodiscardnoexcept |
Returns a constant pointer just after the last valid element.
|
inlinenodiscardnoexcept |
Returns the number of valid elements in the buffer.
|
inline |
Resizes the buffer.
If the new size is smaller than the current size, excess elements are removed. If the new size is larger, space is allocated at the end of the buffer.
new_size | Desired new size |
|
inlinenoexcept |
Frees elements at the beginning of the buffer.
size | Number of elements to free |
|
inlinenoexcept |
Frees elements at the end of the buffer.
size | Number of elements to free |
|
inlinenoexcept |
Resets the buffer to a specific position.
If the specified position is not the end, sets the beginning to this position. Otherwise, completely resets the buffer.
begin | New beginning position |
|
inlinenoexcept |
Completely resets the buffer.
Data remains in memory but is marked as invalid
|
inlinenoexcept |
Checks if the buffer is empty.
|
inlinenoexcept |
Frees a specified number of elements.
Depending on the _flag_front flag, frees at the beginning or end of the buffer
size | Number of elements to free |
|
inline |
Allocates space at the end of the buffer.
Automatically increases capacity if necessary.
size | Number of elements to allocate |
|
inline |
Allocates and constructs an object of type U at the end of the buffer.
U | Type of object to construct |
_Init | Types of arguments for construction |
init | Arguments for construction |
|
inline |
Allocates space with a custom size and constructs an object.
U | Type of object to construct |
_Init | Types of arguments for construction |
size | Additional size to allocate after the object |
init | Arguments for construction |
|
inline |
Allocates space at the beginning or end of the buffer.
Chooses the location based on available space
size | Number of elements to allocate |
|
inline |
Allocates space and constructs an object.
U | Type of object to construct |
_Init | Types of arguments for construction |
init | Arguments for construction |
|
inline |
Copies an object to the end of the buffer.
U | Type of object to copy |
data | Object to copy |
|
inline |
Copies data to the end of the buffer.
U | Type of data to copy |
data | Data to copy |
size | Number of elements to copy |
|
inline |
Copies an object to the beginning or end of the buffer.
U | Type of object to copy |
data | Object to copy |
|
inline |
Copies data to the beginning or end of the buffer.
U | Type of data to copy |
data | Data to copy |
size | Number of elements to copy |
|
inlinenoexcept |
Reorganizes the buffer to consolidate free space.
Moves data to the beginning of the buffer
|
inline |
Reserves space in the buffer.
Allocates space without marking it as used
size | Number of elements to reserve |