PikeAero::CRingBuffer Class Reference

#include <cringbuffer.h>

Inheritance diagram for PikeAero::CRingBuffer:

Inheritance graph
[legend]
Collaboration diagram for PikeAero::CRingBuffer:

Collaboration graph
[legend]

Public Member Functions

 CRingBuffer ()
bool empty ()
CMachine::ubit32 free ()
bool full ()
CMachine::ubit32 insert (CMachine::ubit8 ch)
CMachine::ubit32 length ()
CMachine::ubit8 peek ()
CMachine::ubit8 remove ()
 ~CRingBuffer ()

Private Attributes

CMachine::ubit32 mHead
CMachine::ubit32 mTail

Detailed Description

Implements a ring buffer of bytes.

Author:
Michael Sharkey <mike@pikeaero.com>

Definition at line 32 of file cringbuffer.h.


Constructor & Destructor Documentation

PikeAero::CRingBuffer::CRingBuffer (  ) 

Definition at line 24 of file cringbuffer.cpp.

00025  : CByteArray()
00026  , mHead(0)
00027  , mTail(0)
00028 {
00029 }

PikeAero::CRingBuffer::~CRingBuffer (  ) 

Definition at line 31 of file cringbuffer.cpp.

00032 {
00033 }


Member Function Documentation

bool PikeAero::CRingBuffer::empty (  )  [inline]

Definition at line 44 of file cringbuffer.h.

References length().

00044 {return length() == 0;}

Here is the call graph for this function:

CMachine::ubit32 PikeAero::CRingBuffer::free (  )  [inline]

Definition at line 43 of file cringbuffer.h.

References length(), and PikeAero::CByteArray::size().

Referenced by PikeAero::CCommunication::txReady().

00043 {return (size()-length())-1;}

Here is the call graph for this function:

Here is the caller graph for this function:

bool PikeAero::CRingBuffer::full (  )  [inline]

Definition at line 42 of file cringbuffer.h.

References length(), and PikeAero::CByteArray::size().

Referenced by insert().

00042 {return (length() >= size()-1);}

Here is the call graph for this function:

Here is the caller graph for this function:

CMachine::ubit32 PikeAero::CRingBuffer::insert ( CMachine::ubit8  ch  ) 

Definition at line 35 of file cringbuffer.cpp.

References full(), PikeAero::CByteArray::mData, mHead, and PikeAero::CByteArray::size().

Referenced by PikeAero::CCommunicationUART::irq().

00036 {
00037     if ( !full() )
00038     {
00039         mData[mHead] = ch;
00040         if ( ++mHead >= size() )
00041         {
00042             mHead = 0;
00043         }
00044         return 1;
00045     }
00046     return 0;
00047 }

Here is the call graph for this function:

Here is the caller graph for this function:

CMachine::ubit32 PikeAero::CRingBuffer::length (  )  [virtual]

Reimplemented from PikeAero::CByteArray.

Definition at line 68 of file cringbuffer.cpp.

References mHead, mTail, and PikeAero::CByteArray::size().

Referenced by empty(), free(), full(), remove(), and PikeAero::CCommunication::rxReady().

00069 {
00070     if ( mHead > mTail )
00071     {
00072         return mHead-mTail;
00073     }
00074     else if ( mHead < mTail )
00075     {
00076         return (size()-mTail)+mHead;
00077     }
00078     return 0;
00079 }

Here is the call graph for this function:

Here is the caller graph for this function:

CMachine::ubit8 PikeAero::CRingBuffer::peek (  ) 

Definition at line 49 of file cringbuffer.cpp.

References PikeAero::CByteArray::mData, and mTail.

00050 {
00051     return mData[mTail];
00052 }

CMachine::ubit8 PikeAero::CRingBuffer::remove (  ) 

Definition at line 54 of file cringbuffer.cpp.

References length(), PikeAero::CByteArray::mData, mTail, and PikeAero::CByteArray::size().

Referenced by PikeAero::CCommunicationUART::irq(), and PikeAero::CCommunication::rx().

00055 {
00056     if ( length() > 0 )
00057     {
00058         CMachine::ubit8 ch = mData[mTail];
00059         if ( ++mTail >= size() )
00060         {
00061             mTail = 0;
00062         }
00063         return ch;
00064     }
00065     return '\0';
00066 }

Here is the call graph for this function:

Here is the caller graph for this function:


Field Documentation

Definition at line 47 of file cringbuffer.h.

Referenced by insert(), and length().

Definition at line 48 of file cringbuffer.h.

Referenced by length(), peek(), and remove().


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

Generated on Sun Oct 25 14:00:14 2009 for stingray3 by  doxygen 1.5.8