8a7dc10892
We're getting ready for the last mile of the StimulusBuffer API and the proto-completion of the LivoxGen1 StimBuffApi.
60 lines
1.5 KiB
C++
60 lines
1.5 KiB
C++
#ifndef _STIMULUS_BUFFER_H
|
|
#define _STIMULUS_BUFFER_H
|
|
|
|
#include <config.h>
|
|
#include <vector>
|
|
#include <memory>
|
|
#include <user/spMcRingBuffer.h>
|
|
#include "stimulusFrame.h"
|
|
|
|
namespace smo {
|
|
namespace stim_buff {
|
|
|
|
// Forward declaration
|
|
class StimulusProducer;
|
|
|
|
/**
|
|
* StimulusBuffer manages a collection of stimulus frames and ring buffer.
|
|
*
|
|
* This buffer holds the actual frame storage and ring buffer for stimulus
|
|
* data. It maintains a reference to the StimulusProducer that it owns.
|
|
*/
|
|
class StimulusBuffer
|
|
{
|
|
public:
|
|
explicit StimulusBuffer(
|
|
std::shared_ptr<StimulusProducer> &producer,
|
|
int histbuffMs,
|
|
const SpMcRingBuffer::InputEngineConstraints& ringBufferConstraints)
|
|
: producer(producer),
|
|
histbuffMs(histbuffMs),
|
|
frames_(static_cast<size_t>(histbuffMs / CONFIG_STIMBUFF_FRAME_PERIOD_MS)),
|
|
ringBufferConstraints(ringBufferConstraints),
|
|
ringBuffer(
|
|
static_cast<size_t>(histbuffMs / CONFIG_STIMBUFF_FRAME_PERIOD_MS),
|
|
ringBufferConstraints)
|
|
{}
|
|
|
|
~StimulusBuffer() = default;
|
|
|
|
// Non-copyable, movable
|
|
StimulusBuffer(const StimulusBuffer&) = delete;
|
|
StimulusBuffer& operator=(const StimulusBuffer&) = delete;
|
|
StimulusBuffer(StimulusBuffer&&) = default;
|
|
StimulusBuffer& operator=(StimulusBuffer&&) = default;
|
|
|
|
public:
|
|
std::shared_ptr<StimulusProducer> producer;
|
|
std::vector<StimulusFrame> frames_;
|
|
|
|
protected:
|
|
int histbuffMs;
|
|
SpMcRingBuffer::InputEngineConstraints ringBufferConstraints;
|
|
SpMcRingBuffer ringBuffer;
|
|
};
|
|
|
|
} // namespace stim_buff
|
|
} // namespace smo
|
|
|
|
#endif // _STIMULUS_BUFFER_H
|