Buffer

The list of Buffer objects in a Frame is iterated using a the following typedef:

rogue::interfaces::stream::Frame::BufferIterator

The uint8_t data within a Buffer is iterated using a the following typedef:

rogue::interfaces::stream::Buffer::iterator

Buffer objects in C++ are referenced by the following shared pointer typedef:

typedef std::shared_ptr<rogue::interfaces::stream::Buffer> rogue::interfaces::stream::BufferPtr

Shared pointer alias for Buffer.

The class description is shown below:

class Buffer

Stream frame buffer container.

Represents a contiguous memory block (allocated by a Pool) that contributes to a frame. Buffers reserve header/tail regions for protocol layers. Most users should access payload data through FrameIterator; Buffer is a lower-level C++ API.

Public Types

typedef uint8_t *iterator

Iterator alias for byte-wise buffer access.

Public Functions

Buffer(std::shared_ptr<rogue::interfaces::stream::Pool> source, void *data, uint32_t meta, uint32_t size, uint32_t alloc)

Constructs a buffer around a pool allocation.

This constructor is a low-level C++ allocation path. Prefer create() when shared ownership or Python exposure is required.

This constructor is used internally by pool implementations when a frame buffer is allocated. The alloc size may be larger than size when the allocator rounds up to alignment or slab boundaries.

Parameters:
  • sourcePool that owns the backing allocation.

  • data – Pointer to raw data allocation.

  • meta – Pool-defined metadata associated with the allocation.

  • size – Requested/usable raw buffer size in bytes.

  • alloc – Actual allocated bytes for this buffer.

~Buffer()

Destroys the buffer wrapper and returns ownership to the pool path.

void setFrame(std::shared_ptr<rogue::interfaces::stream::Frame> frame)

Associates this buffer with its owning frame.

Called by Frame while building or reparenting frame buffer lists.

Parameters:

frame – Owning frame object.

uint32_t getMeta()

Returns metadata associated with this buffer.

Metadata is used by Pool implementations to track allocations.

Returns:

Metadata value.

void setMeta(uint32_t meta)

Sets metadata associated with this buffer.

Metadata is used by Pool implementations to track allocations.

Parameters:

meta – Metadata value.

void adjustHeader(int32_t value)

Adjusts header reservation size.

Parameters:

value – Header adjustment in bytes.

void zeroHeader()

Clears header reservation.

void adjustTail(int32_t value)

Adjusts tail reservation size.

Parameters:

value – Tail adjustment in bytes.

void zeroTail()

Clears tail reservation.

uint8_t *begin()

Returns iterator to start of buffer payload region.

Excludes reserved header space.

Returns:

Begin buffer iterator.

uint8_t *end()

Returns iterator to end of usable buffer region.

Excludes reserved tail space.

Returns:

End buffer iterator.

uint8_t *endPayload()

Returns iterator to end of current payload.

Returns:

End payload iterator.

uint32_t getSize()

Returns payload-capable buffer size.

Full buffer size minus current header/tail reservations.

Returns:

Buffer size in bytes.

uint32_t getAvailable()

Returns remaining available payload space.

Returns:

Available payload space in bytes.

uint32_t getPayload()

Returns current payload size.

Returns:

Payload size in bytes.

void setPayload(uint32_t size)

Sets payload size.

Parameters:

size – New payload size in bytes.

void minPayload(uint32_t size)

Ensures payload size is at least size.

Payload size is unchanged when already larger than size.

Parameters:

size – Minimum payload size in bytes.

void adjustPayload(int32_t value)

Adjusts payload size by signed delta.

Parameters:

value – Payload adjustment in bytes.

void setPayloadFull()

Sets payload size to maximum available buffer space.

Fills buffer minus header and tail reservations.

void setPayloadEmpty()

Clears payload (sets payload size to zero).

void debug(uint32_t idx)

Emits debug information for this buffer.

Parameters:

idxBuffer index/tag to print with the debug output.

Public Static Functions

static std::shared_ptr<rogue::interfaces::stream::Buffer> create(std::shared_ptr<rogue::interfaces::stream::Pool> source, void *data, uint32_t meta, uint32_t size, uint32_t alloc)

Creates a buffer backed by memory owned by a stream Pool.

Parameter semantics are identical to the constructor; see Buffer() for allocation and ownership behavior details. This static factory is the preferred construction path when the object is shared across Rogue graph connections or exposed to Python. It returns std::shared_ptr ownership compatible with Rogue pointer typedefs.

Not exposed to Python.

Parameters:
  • sourcePool that owns the backing allocation.

  • data – Pointer to raw data allocation.

  • meta – Pool-defined metadata associated with the allocation.

  • size – Requested/usable raw buffer size in bytes.

  • alloc – Actual allocated bytes for this buffer.

Returns:

Shared pointer to the created buffer object.