WvStreams
|
A buffer that wraps a pre-allocated array and provides read-write access to its elements using a circular buffering scheme rather than a purely linear one, as used by WvInPlaceBuf. More...
#include <wvbufbase.h>
Public Member Functions | |
WvCircularBufBase (T *_data, size_t _avail, size_t _size, bool _autofree=false) | |
Creates a new circular buffer backed by the supplied array. More... | |
WvCircularBufBase (size_t _size) | |
Creates a new empty circular buffer backed by a new array. More... | |
WvCircularBufBase () | |
Creates a new empty buffer with no backing array. | |
virtual | ~WvCircularBufBase () |
Destroys the buffer. More... | |
T * | ptr () const |
Returns the underlying array pointer. More... | |
size_t | size () const |
Returns the total size of the buffer. More... | |
bool | get_autofree () const |
Returns the autofree flag. More... | |
void | set_autofree (bool _autofree) |
Sets or clears the autofree flag. More... | |
void | reset (T *_data, size_t _avail, size_t _size, bool _autofree=false) |
Resets the underlying buffer pointer and properties. More... | |
void | setavail (size_t _avail) |
Sets the amount of available data using the current buffer and resets the read index to the beginning of the buffer. More... | |
void | normalize () |
Normalizes the arrangement of the data such that the contents of the buffer are stored at the beginning of the array starting with the next element that would be returned by get(size_t). More... | |
Protected Types | |
typedef T | Elem |
Protected Attributes | |
WvCircularBufStore | mystore |
A buffer that wraps a pre-allocated array and provides read-write access to its elements using a circular buffering scheme rather than a purely linear one, as used by WvInPlaceBuf.
When there is insufficient contigous free/used space to satisfy a read or write request, the data is automatically reordered in-place to coalesce the free/used spaces into sufficiently large chunks. The process may also be manually triggered to explicitly renormalize the array and shift its contents to the front.
"T" is the type of object to store, must be a primitive or a struct without special initialization, copy, or assignment semantics
Definition at line 813 of file wvbufbase.h.
|
inline |
Creates a new circular buffer backed by the supplied array.
"_data" is the array of data to wrap "_avail" is the amount of data available for reading at the beginning of the buffer "_size" is the size of the array "_autofree" is if true, the array will be freed when discarded
Definition at line 830 of file wvbufbase.h.
|
inlineexplicit |
Creates a new empty circular buffer backed by a new array.
"_size" is the size of the array
Definition at line 841 of file wvbufbase.h.
|
inlinevirtual |
Destroys the buffer.
Frees the underlying array if autofree().
Definition at line 856 of file wvbufbase.h.
|
inline |
Returns the underlying array pointer.
Returns: the element pointer
Definition at line 863 of file wvbufbase.h.
|
inline |
Returns the total size of the buffer.
Returns: the number of elements
Definition at line 873 of file wvbufbase.h.
|
inline |
|
inline |
Sets or clears the autofree flag.
"_autofree" is if true, the array will be freed when discarded
Definition at line 893 of file wvbufbase.h.
|
inline |
Resets the underlying buffer pointer and properties.
If the old and new buffer pointers differ and the old buffer was specified as autofree, the old buffer is destroyed.
"_data" is the array of data to wrap "_avail" is the amount of data available for reading at the beginning of the buffer "_size" is the size of the array "_autofree" is if true, the array will be freed when discarded
Definition at line 910 of file wvbufbase.h.
|
inline |
Sets the amount of available data using the current buffer and resets the read index to the beginning of the buffer.
"_avail" is the amount of data available for reading at the beginning of the buffer
Definition at line 924 of file wvbufbase.h.
|
inline |
Normalizes the arrangement of the data such that the contents of the buffer are stored at the beginning of the array starting with the next element that would be returned by get(size_t).
After invocation, ungettable() may equal 0.
Definition at line 938 of file wvbufbase.h.