cRingBufferLinear Class Reference

#include <ringbuffer.h>

Inheritance diagram for cRingBufferLinear:

Inheritance graph
[legend]
Collaboration diagram for cRingBufferLinear:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 cRingBufferLinear (int Size, int Margin=0, bool Statistics=false, const char *Description=NULL)
virtual ~cRingBufferLinear ()
virtual int Available (void)
virtual int Free (void)
virtual void Clear (void)
 Immediately clears the ring buffer.
int Read (int FileHandle, int Max=0)
int Put (const uchar *Data, int Count)
ucharGet (int &Count)
void Del (int Count)

Protected Member Functions

virtual int DataReady (const uchar *Data, int Count)

Private Attributes

int margin
int head
int tail
int gotten
ucharbuffer
char * description


Detailed Description

Definition at line 46 of file ringbuffer.h.


Constructor & Destructor Documentation

cRingBufferLinear::cRingBufferLinear ( int  Size,
int  Margin = 0,
bool  Statistics = false,
const char *  Description = NULL 
)

Creates a linear ring buffer. The buffer will be able to hold at most Size-Margin-1 bytes of data, and will be guaranteed to return at least Margin bytes in one consecutive block. The optional Description is used for debugging only.

Definition at line 154 of file ringbuffer.c.

References buffer, Clear(), description, esyslog, gotten, head, MALLOC, margin, and tail.

Here is the call graph for this function:

cRingBufferLinear::~cRingBufferLinear (  )  [virtual]

Definition at line 181 of file ringbuffer.c.

References buffer, and description.


Member Function Documentation

int cRingBufferLinear::DataReady ( const uchar Data,
int  Count 
) [protected, virtual]

By default a ring buffer has data ready as soon as there are at least 'margin' bytes available. A derived class can reimplement this function if it has other conditions that define when data is ready. The return value is either 0 if there is not yet enough data available, or the number of bytes from the beginning of Data that are "ready".

Definition at line 190 of file ringbuffer.c.

References margin.

Referenced by Get().

int cRingBufferLinear::Available ( void   )  [virtual]

Implements cRingBuffer.

Definition at line 195 of file ringbuffer.c.

References head, margin, cRingBuffer::Size(), and tail.

Referenced by Free().

Here is the call graph for this function:

virtual int cRingBufferLinear::Free ( void   )  [inline, virtual]

Reimplemented from cRingBuffer.

Definition at line 78 of file ringbuffer.h.

References Available(), margin, and cRingBuffer::Size().

Here is the call graph for this function:

void cRingBufferLinear::Clear ( void   )  [virtual]

Immediately clears the ring buffer.

Implements cRingBuffer.

Definition at line 201 of file ringbuffer.c.

References cRingBuffer::EnablePut(), head, cRingBuffer::maxFill, and tail.

Referenced by cRingBufferLinear().

Here is the call graph for this function:

int cRingBufferLinear::Read ( int  FileHandle,
int  Max = 0 
)

Reads at most Max bytes from FileHandle and stores them in the ring buffer. If Max is 0, reads as many bytes as possible. Only one actual read() call is done.

Returns:
Returns the number of bytes actually read and stored, or an error value from the actual read() call.

Definition at line 213 of file ringbuffer.c.

References buffer, cRingBuffer::EnableGet(), head, margin, safe_read(), cRingBuffer::Size(), cRingBuffer::statistics, tail, cRingBuffer::UpdatePercentage(), and cRingBuffer::WaitForPut().

Referenced by cTSBuffer::Action().

Here is the call graph for this function:

int cRingBufferLinear::Put ( const uchar Data,
int  Count 
)

Puts at most Count bytes of Data into the ring buffer.

Returns:
Returns the number of bytes actually stored.

Definition at line 250 of file ringbuffer.c.

References buffer, cRingBuffer::EnableGet(), head, margin, cRingBuffer::Size(), cRingBuffer::statistics, tail, cRingBuffer::UpdatePercentage(), and cRingBuffer::WaitForPut().

Referenced by cRecorder::Receive().

Here is the call graph for this function:

uchar * cRingBufferLinear::Get ( int &  Count  ) 

Gets data from the ring buffer. The data will remain in the buffer until a call to Del() deletes it.

Returns:
Returns a pointer to the data, and stores the number of bytes actually available in Count. If the returned pointer is NULL, Count has no meaning.

Definition at line 290 of file ringbuffer.c.

References buffer, DataReady(), cRingBuffer::getThreadTid, gotten, head, margin, cRingBuffer::Size(), tail, cThread::ThreadId(), and cRingBuffer::WaitForGet().

Referenced by cRecorder::Action(), and cTSBuffer::Get().

Here is the call graph for this function:

void cRingBufferLinear::Del ( int  Count  ) 

Deletes at most Count bytes from the ring buffer. Count must be less or equal to the number that was returned by a previous call to Get().

Definition at line 315 of file ringbuffer.c.

References cRingBuffer::EnablePut(), esyslog, gotten, margin, cRingBuffer::Size(), and tail.

Referenced by cRecorder::Action(), and cTSBuffer::Get().

Here is the call graph for this function:


Member Data Documentation

Definition at line 59 of file ringbuffer.h.

Referenced by Available(), cRingBufferLinear(), DataReady(), Del(), Free(), Get(), Put(), and Read().

int cRingBufferLinear::head [private]

Definition at line 59 of file ringbuffer.h.

Referenced by Available(), Clear(), cRingBufferLinear(), Get(), Put(), and Read().

int cRingBufferLinear::tail [private]

Definition at line 59 of file ringbuffer.h.

Referenced by Available(), Clear(), cRingBufferLinear(), Del(), Get(), Put(), and Read().

Definition at line 60 of file ringbuffer.h.

Referenced by cRingBufferLinear(), Del(), and Get().

Definition at line 61 of file ringbuffer.h.

Referenced by cRingBufferLinear(), Get(), Put(), Read(), and ~cRingBufferLinear().

Definition at line 62 of file ringbuffer.h.

Referenced by cRingBufferLinear(), and ~cRingBufferLinear().


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

Generated on Tue Jan 13 14:31:48 2009 for VDR by  doxygen 1.5.6