#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.
Pothos::BufferChunk::BufferChunk |
( |
void |
| ) |
|
|
inline |
Create a null BufferChunk. The fields will be zeroed out and buffer null.
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 |
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 |
Pothos::BufferChunk::BufferChunk |
( |
const SharedBuffer & |
buffer | ) |
|
|
inline |
Pothos::BufferChunk::BufferChunk |
( |
const BufferChunk & |
other | ) |
|
|
inline |
Pothos::BufferChunk::BufferChunk |
( |
BufferChunk && |
other | ) |
|
|
inline |
Pothos::BufferChunk::~BufferChunk |
( |
void |
| ) |
|
|
inline |
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 |
template<typename ElementType >
ElementType Pothos::BufferChunk::as |
( |
void |
| ) |
const |
Get a pointer to the front of the buffer casted to the desired data type.
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.
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
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
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
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
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.
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
The underlying reference counted shared buffer.
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
The underlying reference counted managed buffer.
static const BufferChunk& Pothos::BufferChunk::null |
( |
void |
| ) |
|
|
static |
Pothos::BufferChunk::operator bool |
( |
void |
| ) |
const |
|
inlineexplicit |
Is this buffer chunk valid?
- Returns
- true when there is underlying memory
template<class Archive >
void Pothos::BufferChunk::serialize |
( |
Archive & |
ar, |
|
|
const unsigned int |
version |
|
) |
| |
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.
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
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.
size_t Pothos::BufferChunk::address |
The address of the start of the buffer.
DType Pothos::BufferChunk::dtype |
The data type of the contents of this buffer.
size_t Pothos::BufferChunk::length |
The number of valid bytes in the buffer.
The documentation for this class was generated from the following file: