WvStreams
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
WvLinkedBufferStore Class Reference

The WvLinkedBuffer storage class. More...

#include <wvbufstore.h>

Inheritance diagram for WvLinkedBufferStore:
Inheritance graph
[legend]

Public Member Functions

 WvLinkedBufferStore (int _granularity)
 
virtual size_t used () const
 
virtual size_t optgettable () const
 
virtual const void * get (size_t count)
 
virtual void unget (size_t count)
 
virtual size_t ungettable () const
 
virtual void zap ()
 
virtual size_t free () const
 
virtual size_t optallocable () const
 
virtual void * alloc (size_t count)
 
virtual void unalloc (size_t count)
 
virtual size_t unallocable () const
 
virtual size_t optpeekable (int offset) const
 
virtual void * mutablepeek (int offset, size_t count)
 
virtual bool isreadable () const
 
virtual void skip (size_t count)
 
virtual size_t peekable (int offset) const
 
virtual const void * peek (int offset, size_t count)
 
void move (void *buf, size_t count)
 
void copy (void *buf, int offset, size_t count)
 
virtual bool iswritable () const
 
void put (const void *data, size_t count)
 
void fastput (const void *data, size_t count)
 
void poke (const void *data, int offset, size_t count)
 
virtual void merge (WvBufStore &instore, size_t count)
 
void basicmerge (WvBufStore &instore, size_t count)
 

Protected Member Functions

virtual bool usessubbuffers () const
 Returns true if the buffer uses subbuffers for storage.
 
virtual size_t numsubbuffers () const
 Returns the number of subbuffers in the buffer.
 
virtual WvBufStorefirstsubbuffer () const
 Returns the first subbuffer. More...
 
virtual void appendsubbuffer (WvBufStore *buffer, bool autofree)
 Appends a subbuffer to the buffer.
 
virtual void prependsubbuffer (WvBufStore *buffer, bool autofree)
 Prepends a subbuffer to the buffer.
 
virtual bool unlinksubbuffer (WvBufStore *buffer, bool allowautofree)
 Unlinks the specified subbuffer. More...
 
virtual WvBufStorenewbuffer (size_t minsize)
 Called when a new buffer must be allocated to coalesce chunks. More...
 
virtual void recyclebuffer (WvBufStore *buffer)
 Called when a buffer with autofree is removed from the list. More...
 
int search (WvBufStoreList::Iter &it, int offset) const
 Searches for the buffer containing the offset. More...
 
WvBufStorecoalesce (WvBufStoreList::Iter &it, size_t count)
 Coalesces a sequence of buffers. More...
 

Protected Attributes

WvBufStoreList list
 
size_t totalused
 
size_t maxungettable
 
int granularity
 

Detailed Description

The WvLinkedBuffer storage class.

A buffer store built out of a list of other buffers linked together. Buffers may be appended or prepended to the list at any time, at which point they act as slaves for the master buffer. Slaves may be expunged from the list at any time when the master buffer determines that they are of no further use.

This is mostly useful for building other buffer storage classes.

Definition at line 401 of file wvbufstore.h.

Member Function Documentation

◆ firstsubbuffer()

WvBufStore * WvLinkedBufferStore::firstsubbuffer ( ) const
protectedvirtual

Returns the first subbuffer.

Returns: the buffer or NULL if none or not supported

Reimplemented from WvBufStore.

Definition at line 757 of file wvbufferstore.cc.

◆ unlinksubbuffer()

bool WvLinkedBufferStore::unlinksubbuffer ( WvBufStore buffer,
bool  allowautofree 
)
protectedvirtual

Unlinks the specified subbuffer.

Only autofrees the buffer if allowautofree == true. Returns: the autofree flag for the buffer

Reimplemented from WvBufStore.

Definition at line 780 of file wvbufferstore.cc.

◆ newbuffer()

WvBufStore * WvLinkedBufferStore::newbuffer ( size_t  minsize)
protectedvirtual

Called when a new buffer must be allocated to coalesce chunks.

"minsize" is the minimum size for the new buffer Returns: the new buffer

Reimplemented in WvDynBufStore.

Definition at line 996 of file wvbufferstore.cc.

Referenced by coalesce(), and WvDynBufStore::newbuffer().

◆ recyclebuffer()

void WvLinkedBufferStore::recyclebuffer ( WvBufStore buffer)
protectedvirtual

Called when a buffer with autofree is removed from the list.

This function is not called during object destruction.

"buffer" is the buffer to be destroyed

Definition at line 1004 of file wvbufferstore.cc.

◆ search()

int WvLinkedBufferStore::search ( WvBufStoreList::Iter &  it,
int  offset 
) const
protected

Searches for the buffer containing the offset.

"it" is the iterator updated to point to buffer found, or to an invalid region if the offset is invalid "offset" is the offset for which to search Returns: the corrected offset within the buffer at it.ptr()

Definition at line 1010 of file wvbufferstore.cc.

◆ coalesce()

WvBufStore * WvLinkedBufferStore::coalesce ( WvBufStoreList::Iter &  it,
size_t  count 
)
protected

Coalesces a sequence of buffers.

"it" is the iterator pointing to the first buffer "count" is the required number of contiguous used bytes Returns: the composite buffer

Definition at line 1042 of file wvbufferstore.cc.

References newbuffer().


The documentation for this class was generated from the following files: