An implementation of a circular array allowing direct write and read.

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers CircularArray.h Source File

CircularArray.h

00001 
00002 #ifndef _CIRCULAR_ARRAY_H_
00003 #define _CIRCULAR_ARRAY_H_
00004 #include <stdint.h>
00005 
00006 class CircularArray
00007 {
00008     private:
00009     unsigned int m_capacity;
00010     volatile unsigned int w;
00011     volatile unsigned int r;
00012     volatile bool m_full;
00013     volatile bool m_empty;
00014     volatile uint8_t * data;
00015     volatile uint8_t * readerBuffer;
00016     uint16_t sizeRB;
00017     volatile uint8_t * writerBuffer;
00018     uint16_t sizeWB;
00019     
00020     public:
00021         CircularArray(unsigned int capacity);
00022         ~CircularArray();    
00023         uint8_t * getWritePointer();
00024         uint8_t * getReadPointer(uint16_t num);
00025         void writeElements(unsigned int num);
00026         void readElements(unsigned int num);
00027         unsigned int fillCapacity();
00028         unsigned int freeSpace();
00029         unsigned int size();
00030         unsigned int readable();
00031         bool full();
00032         bool empty();
00033 };
00034 
00035 #endif