libcommonc++  0.7
AbstractBuffer< T > Class Template Referenceabstract

An abstract base class for buffers. More...

#include <AbstractBuffer.h++>

Inheritance diagram for AbstractBuffer< T >:
Collaboration diagram for AbstractBuffer< T >:

Public Member Functions

virtual ~AbstractBuffer ()
 Destructor. More...
 
virtual void setSize (uint_t newSize)
 Resize the buffer. More...
 
virtual void clear ()
 Clear the buffer. More...
 
uint_t getSize () const
 Get the size of the buffer. More...
 
virtual uint_t getRemaining () const =0
 Get the number of elements remaining in the buffer. More...
 
virtual bool hasRemaining () const
 Test if the buffer has elements available to be read or written. More...
 
T * getBase ()
 Get a pointer to the base of the buffer. More...
 
const T * getBase () const
 Get a pointer to the base of the buffer. More...
 

Protected Member Functions

 AbstractBuffer (uint_t size)
 Construct a new buffer with the given size. More...
 
 AbstractBuffer (T *data, size_t size, bool takeOwnership=true)
 Construct a new buffer to wrap a raw byte buffer. More...
 

Protected Attributes

T * _data
 A pointer to the raw buffer. More...
 
uint_t _size
 The size of the buffer. More...
 
bool _owner
 Whether this object owns the raw buffer. More...
 

Detailed Description

template<typename T>
class ccxx::AbstractBuffer< T >

An abstract base class for buffers.

Author
Mark Lindner

Constructor & Destructor Documentation

◆ ~AbstractBuffer()

virtual ~AbstractBuffer ( )
virtual

Destructor.

◆ AbstractBuffer() [1/2]

AbstractBuffer ( uint_t  size)
protected

Construct a new buffer with the given size.

Parameters
sizeThe capacity of the buffer, in elements.

◆ AbstractBuffer() [2/2]

AbstractBuffer ( T *  data,
size_t  size,
bool  takeOwnership = true 
)
protected

Construct a new buffer to wrap a raw byte buffer.

Parameters
sizeThe capacity of the buffer, in elements.

Member Function Documentation

◆ clear()

virtual void clear ( )
virtual

◆ getBase() [1/2]

T* getBase ( )
inline

Get a pointer to the base of the buffer.

◆ getBase() [2/2]

const T* getBase ( ) const
inline

Get a pointer to the base of the buffer.

◆ getRemaining()

virtual uint_t getRemaining ( ) const
pure virtual

Get the number of elements remaining in the buffer.

Implemented in Buffer< T >, Buffer< char >, CircularBuffer< T >, CircularBuffer< C >, and CircularBuffer< byte_t >.

◆ getSize()

uint_t getSize ( ) const
inline

Get the size of the buffer.

Returns
The size, in elements.

◆ hasRemaining()

virtual bool hasRemaining ( ) const
inlinevirtual

Test if the buffer has elements available to be read or written.

Reimplemented in Buffer< T >, and Buffer< char >.

◆ setSize()

virtual void setSize ( uint_t  newSize)
virtual

Resize the buffer.

Parameters
newSizeThe new size, in elements.
Exceptions
UnsupportedOperationExceptionIf this object does not own the underlying byte buffer.

Reimplemented in CircularBuffer< T >, CircularBuffer< C >, and CircularBuffer< byte_t >.

Member Data Documentation

◆ _data

T* _data
protected

A pointer to the raw buffer.

◆ _owner

bool _owner
protected

Whether this object owns the raw buffer.

◆ _size

uint_t _size
protected

The size of the buffer.


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