#include <SampleBuffer.h>
Inheritance diagram for gadget::SampleBuffer:

Public Types | |
| typedef std::vector< std::vector< DATA_TYPE > > | buffer_t |
Public Methods | |
| SampleBuffer () | |
| void | addSample (const std::vector< DATA_TYPE > &dataSample) |
| Add a new sample to the buffer. More... | |
| void | swapBuffers () |
| Swap the data buffers. More... | |
| void | lock () |
| void | unlock () |
| buffer_t & | stableBuffer () |
Protected Methods | |
| SampleBuffer (const SampleBuffer &b) | |
| void | operator= (const SampleBuffer &b) |
Protected Attributes | |
| buffer_t | mStableBuffer |
| buffer_t | mReadyBuffer |
| vpr::Mutex | mLock |
| Lock to protect the buffer. More... | |
The SampleBuffer stores the readings from an input device.
It consists of two buffers (vectors of vectors of samples) that hold The "stable" samples and the "ready" samples.
Stable - Samples that the application is actually looking at Ready - Samples that have been completed and could be swapped over to current
ASSERTION: The buffers can be empty at the start, but after the first cycle (first time stable gets values) the Stable buffer must have at least one sample.
| MAX_BUFFER_SIZE | - The maximum allowable size of the buffer. After it gets this large we will start throwing away old data. |
Definition at line 65 of file SampleBuffer.h.
|
|||||
|
Definition at line 68 of file SampleBuffer.h. Referenced by gadget::SampleBuffer< DigitalData >::stableBuffer. |
|
|||||||||
|
Definition at line 71 of file SampleBuffer.h. Referenced by gadget::SampleBuffer< DigitalData >::operator=, and gadget::SampleBuffer< DigitalData >::SampleBuffer.
00072 {
00073 /* Do nothing. */ ;
00074 }
|
|
||||||||||
|
Definition at line 118 of file SampleBuffer.h.
00118 {;}
|
|
||||||||||
|
Add a new sample to the buffer.
Definition at line 79 of file SampleBuffer.h.
00080 {
00081 vprASSERT(mLock.test()); // Verify that it is locked
00082 mReadyBuffer.push_back(dataSample);
00083 if(mReadyBuffer.size() > MAX_BUFFER_SIZE)
00084 {
00085 while(mReadyBuffer.size() > MAX_BUFFER_SIZE)
00086 { mReadyBuffer.erase(mReadyBuffer.begin()); }
00087 }
00088 }
|
|
|||||||||
|
Swap the data buffers.
Definition at line 95 of file SampleBuffer.h.
00096 {
00097 vpr::Guard<vpr::Mutex> guard(mLock);
00098
00099 if(!mReadyBuffer.empty()) // If Ready buffer has data
00100 {
00101 mStableBuffer = mReadyBuffer; // Copy over the ready values
00102 }
00103
00104 mReadyBuffer.clear();
00105 }
|
|
|||||||||
|
Definition at line 107 of file SampleBuffer.h.
00108 { mLock.acquire(); }
|
|
|||||||||
|
Definition at line 110 of file SampleBuffer.h.
00111 { mLock.release(); }
|
|
|||||||||
|
Definition at line 113 of file SampleBuffer.h.
00114 { return mStableBuffer; }
|
|
||||||||||
|
Definition at line 119 of file SampleBuffer.h.
00119 {;}
|
|
|||||
|
Definition at line 121 of file SampleBuffer.h. Referenced by gadget::SampleBuffer< DigitalData >::stableBuffer, and gadget::SampleBuffer< DigitalData >::swapBuffers. |
|
|||||
|
Definition at line 122 of file SampleBuffer.h. Referenced by gadget::SampleBuffer< DigitalData >::addSample, and gadget::SampleBuffer< DigitalData >::swapBuffers. |
|
|||||
|
Lock to protect the buffer.
Definition at line 124 of file SampleBuffer.h. Referenced by gadget::SampleBuffer< DigitalData >::addSample, gadget::SampleBuffer< DigitalData >::lock, gadget::SampleBuffer< DigitalData >::swapBuffers, and gadget::SampleBuffer< DigitalData >::unlock. |
1.2.14 written by Dimitri van Heesch,
© 1997-2002