Ringbuffer class

RingBuffer.h

Committer:
chris215
Date:
2016-01-13
Revision:
1:fa4c2377a741
Parent:
0:fed94e516719
Child:
2:959aad917307

File content as of revision 1:fa4c2377a741:


#ifndef FIFO_H
#define FIFO_H

#include <stdint.h>
#include <string.h>

template <typename T>
class RingBuffer
{
    private:
    T   *m_buf;
    T   *m_LatchedBuf;
    volatile uint32_t   m_wloc;
    volatile uint32_t   m_rloc;
    volatile uint32_t   m_ActualCapacity;
    uint32_t            m_size;
    bool                m_SetBufferToReadOnly;      //Put ring buffer into readonly mode, this way we can acces the underlying raw data with less
                                                    //risk of behing overriten (Deprecated ... to be removed)                                            
    public:
    RingBuffer(uint32_t size = 128);
    void clear(void);
    uint32_t getSize(); //Return the size of the ring buffer
    
    uint32_t getCapacity(); //Return the number of elements stored in the buffer
    
    
    void LatchBuffer(T* DstBuffer);
    
    ~RingBuffer();
    
    void put(T data);
    
    T get(void);
    
    
    
};

#endif