Program Listing for File DdsDoubleBuffer.hpp

Return to documentation for file (sinspekto/DdsDoubleBuffer.hpp)

#pragma once

#include <cinttypes>
#include <utility>
#include <boost/circular_buffer.hpp>

#include <QAbstractSeries>
#include <QXYSeries>

QT_CHARTS_USE_NAMESPACE

namespace sinspekto
{

  typedef std::pair<std::pair<double, double>, std::pair<double, double>> RangeXY;

  RangeXY replace_double_points(
      boost::circular_buffer<double>& b1,
      boost::circular_buffer<double>& b2,
      QXYSeries *xySeries);
}

class DdsDoubleBuffer : public QObject
{
  Q_OBJECT
  Q_PROPERTY(QPointF range READ range NOTIFY rangeChanged)

public:
  explicit DdsDoubleBuffer(QObject *parent = nullptr);
  virtual ~DdsDoubleBuffer();
  QPointF range() const;
  void setCapacity(int buffer_size);
  boost::circular_buffer<double>& Buffer() { return m_buffer; }

signals:
  void rangeChanged(QPointF range);

public slots:
  void updateRange(double min, double max);

private:
  boost::circular_buffer<double> m_buffer;
  QPointF m_range;
};