ECE 4180 - Final Project Team / Mbed 2 deprecated WalkieTalkie

Dependencies:   mbed 4DGL-uLCD-SE mbed-rtos nRF24L01P

CircularBuf.h

Committer:
Nurchu
Date:
2018-04-20
Revision:
17:604f9c4bd6d3
Parent:
16:d0d3bb2fc3ce
Child:
20:e068469ffb89

File content as of revision 17:604f9c4bd6d3:

template <class T>
class CircularBuff {
public:
    // Arguement:
    //          size, The size of the underlying array to use
    CircularBuff(unsigned int size);
    ~CircularBuff();
    
    // Pushes data onto the buffer
    // Arguement:
    //          data, The array of data to push
    //          size, The amount of data in the array
    // Return:
    //          Amount of data actually written
    unsigned int push(T* data, unsigned int size);
    
    
    // Pops data from the buffer
    // Arguement:
    //          data, The array of data popped
    //          size, The amount of data to pop
    // Return:
    //          Amount of data actually popped
    unsigned int pop(T* data, unsigned int size);
    
    // Amount of data in the buffer
    unsigned int size();
    
    // Clears the buffer completely
    void clear();
    
private:
    T* _data;
    // Size of the array
    unsigned int _size;
    // Start pointer
    unsigned int _head;
    // End pointer
    unsigned int _tail;
};