Small library for using circular buffers (forked from François Berder's implementation in order to add methods and fix problems)
Dependents: CircularBufferTest XBeeApi
Fork of CircularBuffer by
Test suite can be found in this application, CircularBufferTest
Revision 4:e15dee1d59ee, committed 2013-09-20
- Comitter:
- feb11
- Date:
- Fri Sep 20 10:32:30 2013 +0000
- Parent:
- 3:9a45d6675e65
- Child:
- 5:abe8909f9603
- Commit message:
- added comments
Changed in this revision
CircularBuffer.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/CircularBuffer.h Fri Sep 20 10:04:23 2013 +0000 +++ b/CircularBuffer.h Fri Sep 20 10:32:30 2013 +0000 @@ -1,19 +1,55 @@ #ifndef CIRCULAR_BUFFER_H #define CIRCULAR_BUFFER_H +/** This class implements a static circular buffer. +*/ template<size_t T> class CircularBuffer { public : + /** Default constructor + */ CircularBuffer(); + /** Reads data from buffer + + \param data output buffer + \param length Maximum number of bytes to read + \return Number of bytes read + + \note The return value cannot exceed max(length,capacity) + */ uint32_t read(uint8_t *data, uint32_t length); + + /** Writes data in buffer + + \param data input buffer + \param length Maximum number of bytes to write + \return Number of bytes wrote + + \note The return value cannot exceed max(length,capacity) + */ uint32_t write(uint8_t *data, uint32_t length); + /** Returns the total capacity of this buffer + \return Capacity of buffer + */ uint32_t getCapacity() const; + + /** Returns the number of bytes available in the buffer + \return Number of bytes available in the buffer + */ uint32_t getSize() const; + + /** Checks if this buffer is empty + \return True if the buffer is empty, false otherwise + */ bool isEmpty() const; + + /** Checks if this buffer is full + \return True if the buffer is full, false otherwise + */ bool isFull() const; private :