#include <BufferChunk.hpp>
A BufferChunk holds a managed buffer, address, and length. BufferChunk makes it easy to manipulate pieces of a managed buffer. The caller manipulates a MangedBuffer into multiple BufferChunks; then a BufferAccumulator can piece BufferChunks back together.
◆ BufferChunk() [1/7]
Pothos::BufferChunk::BufferChunk |
( |
void |
| ) |
|
|
inline |
Create a null BufferChunk. The fields will be zeroed out and buffer null.
◆ BufferChunk() [2/7]
Pothos::BufferChunk::BufferChunk |
( |
const size_t |
numBytes | ) |
|
|
inline |
Create a BufferChunk given the number of bytes. This is a convenience method to create a BufferChunk using memory from the standard memory allocator (new/delete). Memory will automatically deallocate via reference counting.
- Parameters
-
numBytes | the number of bytes to allocate |
◆ BufferChunk() [3/7]
Pothos::BufferChunk::BufferChunk |
( |
const DType & |
dtype, |
|
|
const size_t |
numElems |
|
) |
| |
|
inline |
Create a BufferChunk given data type and number of elements. This is a convenience method to create a BufferChunk from a type. using memory from the standard memory allocator (new/delete). Memory will automatically deallocate via reference counting.
- Parameters
-
dtype | the data type of the result buffer |
numElems | the size in number of elements |
◆ BufferChunk() [4/7]
Pothos::BufferChunk::BufferChunk |
( |
const SharedBuffer & |
buffer | ) |
|
|
inline |
◆ BufferChunk() [5/7]
◆ BufferChunk() [6/7]
Pothos::BufferChunk::BufferChunk |
( |
const BufferChunk & |
other | ) |
|
|
inline |
◆ BufferChunk() [7/7]
Pothos::BufferChunk::BufferChunk |
( |
BufferChunk && |
other | ) |
|
|
inlinenoexcept |
◆ ~BufferChunk()
Pothos::BufferChunk::~BufferChunk |
( |
void |
| ) |
|
|
inline |
◆ append()
void Pothos::BufferChunk::append |
( |
const BufferChunk & |
other | ) |
|
Append another buffer onto the back of this buffer. This call allocates a new memory slab the size of both buffers and copies the contents from each one into the new memory slab. The length and address members will be updated accordingly. When empty, append simply copies a reference to the other buffer.
- Parameters
-
other | the other buffer to append to the end |
◆ as()
template<typename ElementType >
ElementType Pothos::BufferChunk::as |
( |
void |
| ) |
const |
Get a pointer to the front of the buffer as the specified data type.
auto ptr = buffer.as<const int *>();
- Template Parameters
-
ElementType | the desired pointer type |
- Returns
- the front of the buffer casted into the specified pointer type
◆ clear()
void Pothos::BufferChunk::clear |
( |
void |
| ) |
|
|
inline |
Make this buffer chunk null by clearing its contents. All fields will be zero and containers will be empty.
◆ convert() [1/2]
BufferChunk Pothos::BufferChunk::convert |
( |
const DType & |
dtype, |
|
|
const size_t |
numElems = 0 |
|
) |
| const |
Convert a buffer chunk to the specified data type. When the number of elements are 0, the entire buffer is converted.
- Exceptions
-
BufferConvertError | when the conversion is not possible |
- Parameters
-
dtype | the data type of the result buffer |
numElems | the number of elements to convert |
- Returns
- a new buffer chunk with converted elements
◆ convert() [2/2]
size_t Pothos::BufferChunk::convert |
( |
const BufferChunk & |
outBuff, |
|
|
const size_t |
numElems = 0 |
|
) |
| const |
Convert a buffer chunk into the specified output buffer. When the number of elements are 0, the entire buffer is converted. The buffer length should be large enough to contain the entire conversion.
- Exceptions
-
BufferConvertError | when the conversion is not possible |
- Parameters
-
[out] | outBuff | the output buffer, also specifies the dtype |
| numElems | the number of elements to convert |
- Returns
- the number of output elements written to the buffer
◆ convertComplex() [1/2]
Convert a buffer chunk of complex elements to two real buffers. When the number of elements are 0, the entire buffer is converted.
- Exceptions
-
BufferConvertError | when the conversion is not possible |
- Parameters
-
dtype | the data type of the result buffer |
numElems | the number of elements to convert |
- Returns
- a real + complex pair of buffer chunks
◆ convertComplex() [2/2]
size_t Pothos::BufferChunk::convertComplex |
( |
const BufferChunk & |
outBuffRe, |
|
|
const BufferChunk & |
outBuffIm, |
|
|
const size_t |
numElems = 0 |
|
) |
| const |
Convert a buffer chunk of complex elements into two real buffers. When the number of elements are 0, the entire buffer is converted. The buffer length should be large enough to contain the entire conversion.
- Exceptions
-
BufferConvertError | when the conversion is not possible |
- Parameters
-
[out] | outBuffRe | the real output buffer, also specifies the dtype |
[out] | outBuffIm | the imaginary output buffer, also specifies the dtype |
| numElems | the number of elements to convert |
- Returns
- the number of output elements written to the buffers
◆ elements()
size_t Pothos::BufferChunk::elements |
( |
void |
| ) |
const |
|
inline |
How many elements are held in this buffer chunk?
- Returns
- the length in bytes divided by the dtype size.
◆ getAlias()
size_t Pothos::BufferChunk::getAlias |
( |
void |
| ) |
const |
|
inline |
Get the alias address of the address. Only valid when the underlying buffer is circular.
- Returns
- the alias address or 0 if non-circular
◆ getBuffer()
The underlying reference counted shared buffer.
◆ getEnd()
size_t Pothos::BufferChunk::getEnd |
( |
void |
| ) |
const |
|
inline |
Get the end address - front address + length. The end address is non-inclusive.
- Returns
- the end address
◆ getManagedBuffer()
The underlying reference counted managed buffer.
◆ null()
static const BufferChunk& Pothos::BufferChunk::null |
( |
void |
| ) |
|
|
static |
◆ operator bool()
Pothos::BufferChunk::operator bool |
( |
void |
| ) |
const |
|
inlineexplicit |
Is this buffer chunk valid?
- Returns
- true when there is underlying memory
◆ operator ElementType()
template<typename ElementType >
Pothos::BufferChunk::operator ElementType |
( |
void |
| ) |
const |
Get a pointer to the front of the buffer as the specified data type. This call overloads the conversion operator to provide implicit conversion.
- Returns
- the front of the buffer casted into the specified pointer type
- Template Parameters
-
ElementType | the desired pointer type |
◆ operator=() [1/2]
◆ operator=() [2/2]
◆ serialize()
template<class Archive >
void Pothos::BufferChunk::serialize |
( |
Archive & |
ar, |
|
|
const unsigned int |
version |
|
) |
| |
◆ setElements()
void Pothos::BufferChunk::setElements |
( |
const size_t |
numElements | ) |
|
|
inline |
Set the number of elements held by this buffer. This call modifies the length field in bytes based on the configured data type and the specified number of elements.
◆ unique()
bool Pothos::BufferChunk::unique |
( |
void |
| ) |
const |
|
inline |
Is the reference to the shared buffer unique?
- Returns
- true if this is the only copy of the shared buffer
◆ useCount()
size_t Pothos::BufferChunk::useCount |
( |
void |
| ) |
const |
|
inline |
The number of copies of the shared buffer. An extra copy held by the managed buffer is not counted.
◆ address
size_t Pothos::BufferChunk::address |
The address of the start of the buffer.
◆ dtype
DType Pothos::BufferChunk::dtype |
The data type of the contents of this buffer.
◆ length
size_t Pothos::BufferChunk::length |
The number of valid bytes in the buffer.
The documentation for this class was generated from the following file: