Homepage Demos Overview Downloads Tutorials Reference
Credits

Buffer Class Reference

#include <Buffer.h>

List of all members.


Detailed Description

Buffer.

A buffer has three main properties: position, capacity and limit. Capacity is the real size of the underlying array. Position is the index of the current element in the buffer (used only by buffer filling operations at the moment). Limit is the virtual size of the buffer. Operations such as filling up the buffer, seeking and so on never go over the limit mark of the buffer.

0 <= position <= limit <= capacity.

Definition at line 15 of file Buffer.h.

Public Member Functions

 Buffer (int size)
 Constructs a new buffer of specified capacity and limit.
 Buffer (const Buffer &rhs)
 Constructs a copy of the buffer.
Bufferoperator= (const Buffer &rhs)
 Makes this buffer a copy of the rhs buffer.
virtual ~Buffer ()
const char * GetData () const
 Gets the pointer to the first element of the underlying array.
char * GetData ()
 Gets the pointer to the first element of the underlying array.
int GetCapacity () const
 Gets the capacity of the buffer.
void SetCapacity (int size)
 Sets the capacity of the buffer. The underlying array grows and shrinks.
int GetPosition () const
 Gets the current position. position <= limit.
int GetLimit () const
 Gets the limit mark of the buffer. limit <= capacity.
void SetPosition (int pos)
 Sets the current position.
void SetLimit (int lim)
 Sets the limit mark. limit <= capacity.
bool Fill (const char *&src, int &srcLen)
 Tries to fill the buffer from current position up to the limit mark. Advances the position, src and srcLen. Returns true if the buffer has been filled.
bool Fill (char *&src, int &srcLen)
 Tries to fill the buffer from current position up to the limit mark. Advances the position, src and srcLen. Returns true if the buffer has been filled.
bool IsFull () const
 Checks whether the buffer is full, that is position == limit.

Static Private Member Functions

int min (int a, int b)

Private Attributes

char * data
int capacity
int limit
int position


Constructor & Destructor Documentation

Buffer::Buffer int  size  ) 
 

Constructs a new buffer of specified capacity and limit.

Definition at line 4 of file Buffer.cc.

Buffer::Buffer const Buffer rhs  ) 
 

Constructs a copy of the buffer.

Definition at line 16 of file Buffer.cc.

Buffer::~Buffer  )  [virtual]
 

Definition at line 22 of file Buffer.cc.


Member Function Documentation

bool Buffer::Fill char *&  src,
int &  srcLen
[inline]
 

Tries to fill the buffer from current position up to the limit mark. Advances the position, src and srcLen. Returns true if the buffer has been filled.

Definition at line 44 of file Buffer.h.

bool Buffer::Fill const char *&  src,
int &  srcLen
 

Tries to fill the buffer from current position up to the limit mark. Advances the position, src and srcLen. Returns true if the buffer has been filled.

Definition at line 84 of file Buffer.cc.

Referenced by SpeakerServer::AddPacket(), and SpeakerServer::GotSocketData().

int Buffer::GetCapacity  )  const [inline]
 

Gets the capacity of the buffer.

Definition at line 30 of file Buffer.h.

Referenced by SpeakerServer::AddPacket(), operator=(), and SpeakerServer::ResampleForSpeaker().

char* Buffer::GetData  )  [inline]
 

Gets the pointer to the first element of the underlying array.

Definition at line 28 of file Buffer.h.

const char* Buffer::GetData  )  const [inline]
 

Gets the pointer to the first element of the underlying array.

Definition at line 26 of file Buffer.h.

Referenced by SpeakerServer::AddPacket(), SpeakerServer::GotSocketData(), operator=(), and SpeakerServer::ResampleForSpeaker().

int Buffer::GetLimit  )  const [inline]
 

Gets the limit mark of the buffer. limit <= capacity.

Definition at line 36 of file Buffer.h.

Referenced by SpeakerServer::AddPacket(), SpeakerServer::GotSocketData(), and operator=().

int Buffer::GetPosition  )  const [inline]
 

Gets the current position. position <= limit.

Definition at line 34 of file Buffer.h.

Referenced by SpeakerServer::AddPacket(), and operator=().

bool Buffer::IsFull  )  const [inline]
 

Checks whether the buffer is full, that is position == limit.

Definition at line 46 of file Buffer.h.

Referenced by Fill(), and SpeakerServer::GotSocketData().

int Buffer::min int  a,
int  b
[inline, static, private]
 

Definition at line 53 of file Buffer.h.

Referenced by SetCapacity(), SetLimit(), and SetPosition().

Buffer & Buffer::operator= const Buffer rhs  ) 
 

Makes this buffer a copy of the rhs buffer.

Definition at line 26 of file Buffer.cc.

void Buffer::SetCapacity int  size  ) 
 

Sets the capacity of the buffer. The underlying array grows and shrinks.

Definition at line 63 of file Buffer.cc.

Referenced by SpeakerServer::AddPacket(), SpeakerServer::DoStop(), SpeakerServer::GotSocketData(), and SpeakerServer::ResampleForSpeaker().

void Buffer::SetLimit int  lim  ) 
 

Sets the limit mark. limit <= capacity.

Definition at line 54 of file Buffer.cc.

Referenced by SpeakerServer::AddPacket(), and SpeakerServer::GotSocketData().

void Buffer::SetPosition int  pos  ) 
 

Sets the current position.

Definition at line 46 of file Buffer.cc.

Referenced by SpeakerServer::AddPacket(), SpeakerServer::DoStart(), and SpeakerServer::GotSocketData().


Member Data Documentation

int Buffer::capacity [private]
 

Definition at line 49 of file Buffer.h.

Referenced by Buffer(), operator=(), SetCapacity(), and SetLimit().

char* Buffer::data [private]
 

Definition at line 48 of file Buffer.h.

Referenced by Buffer(), Fill(), operator=(), and SetCapacity().

int Buffer::limit [private]
 

Definition at line 50 of file Buffer.h.

Referenced by Buffer(), Fill(), operator=(), SetCapacity(), SetLimit(), and SetPosition().

int Buffer::position [private]
 

Definition at line 51 of file Buffer.h.

Referenced by operator=(), SetCapacity(), SetLimit(), and SetPosition().


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

Tekkotsu v2.2.1
Generated Tue Nov 23 16:37:43 2004 by Doxygen 1.3.9.1