Ringbuffer class

Revision:
0:fed94e516719
Child:
1:fa4c2377a741
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RingBuffer.h	Mon Jan 11 04:46:57 2016 +0000
@@ -0,0 +1,41 @@
+
+#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
+    
+    
+    T* LatchBuffer(void);
+    T* LatchBufferPartial(uint32_t SizeToLatch);
+    
+    ~RingBuffer();
+    
+    void put(T data);
+    
+    T get(void);
+    
+    
+    
+};
+
+#endif
\ No newline at end of file