feat(data): SPSC ring buffer, incremental min/max LOD pyramid, series types
This commit is contained in:
1 parent
c93c98002b
commit
138fa478c3
15 files changed
+1182
-8
No files matched your search
@@ -0,0 +1,43 @@
|
||||
#pragma once
|
||||
#include <vector>
|
||||
|
||||
#include <plot/core/types.hpp>
|
||||
#include <plot/data/series.hpp>
|
||||
|
||||
namespace plot::data {
|
||||
|
||||
/// Series over a uniform-dx sample vector.
|
||||
///
|
||||
/// The vector is taken by value and owned from then on, so the caller cannot
|
||||
/// mutate the samples behind the series' back; the store changes only through
|
||||
/// reset() (a whole new vector) or commit(), which rebuilds the pyramid and the
|
||||
/// cached bounds for whatever y_ currently holds.
|
||||
class ArraySeries final : public Series {
|
||||
public:
|
||||
ArraySeries(std::vector<f32> y, f64 x0, f64 dx);
|
||||
/// Replaces samples and grid, then rebuilds derived state (== commit()).
|
||||
void reset(std::vector<f32> y, f64 x0, f64 dx);
|
||||
/// Rebuilds the pyramid and cached bounds from y_ as it stands now.
|
||||
void commit();
|
||||
|
||||
u64 size() const override;
|
||||
f64 x0() const override;
|
||||
f64 dx() const override;
|
||||
Range x_bounds() const override;
|
||||
Range y_bounds() const override;
|
||||
const MinMaxPyramid& pyramid() const override;
|
||||
void gather(u32 level, u64 begin, u64 end, std::vector<f32>& out_xy) const override;
|
||||
|
||||
protected:
|
||||
void copy_raw(u64 begin, u64 end, f32* out) const override;
|
||||
|
||||
private:
|
||||
std::vector<f32> y_;
|
||||
f64 x0_ = 0.0;
|
||||
f64 dx_ = 1.0;
|
||||
MinMaxPyramid pyramid_;
|
||||
Range x_bounds_{};
|
||||
Range y_bounds_{};
|
||||
};
|
||||
|
||||
} // namespace plot::data
|
||||
Reference in new issue
Block a user