Skip to content

ScratchBuffer

Source: ScratchBuffer.h

ScratchBuffer

template<class T>
class ScratchBuffer
src/core/util/ScratchBuffer.h:54

Inherits: ScratchBufferBase

The typed face, pure inline sugar: every method folds into its call site, so a new element type adds no flash.

Public Methods

inline explicit ScratchBuffer(MoonModule & owner) : Declared as a member of the module that owns it.

inline bool resize(std::size_t count) : Size to hold count elements (0 frees). Returns true on success.

inline T * data() : the one cast in the design

inline const T * data() const : the same, read-only

inline std::size_t count() const : how many elements fit

inline std::size_t bytes() const : how many bytes are held

inline explicit operator bool() const : whether anything is allocated

inline T & operator[](std::size_t i)

inline const T & operator[](std::size_t i) const

ScratchBufferBase

class ScratchBufferBase
src/core/util/ScratchBuffer.h:26

The type-erased base, which owns the allocation, the tie to its module, and the one heavy body.

Friends

friend class MoonModule

Public Methods

ScratchBufferBase(const ScratchBufferBase &) = delete : Non-copyable, and public though the constructors are protected: a deleted private member reports as inaccessible instead.

ScratchBufferBase(ScratchBufferBase &&) = delete : Non-movable: a fixed member tied to one module and threaded into its free list, so moving would dangle the owner.