Program Listing for File DdsTimepointBuffer.hpp

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

#pragma once

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

#include <QAbstractSeries>
#include <QXYSeries>
#include <QDateTime>

QT_CHARTS_USE_NAMESPACE

namespace sinspekto
{

  typedef std::pair<std::pair<QDateTime, QDateTime>, std::pair<double, double>> RangeTX;

  RangeTX replace_data_points(
      boost::circular_buffer<int64_t>& b1,
      boost::circular_buffer<double>& b2,
      QXYSeries *xySeries);
}

class DdsTimepointBuffer : public QObject
{
  Q_OBJECT
  Q_PROPERTY(QDateTime rangeTmin READ rangeTmin NOTIFY rangeTminChanged)
  Q_PROPERTY(QDateTime rangeTmax READ rangeTmax NOTIFY rangeTmaxChanged)

public:
  explicit DdsTimepointBuffer(QObject *parent = nullptr);
  virtual ~DdsTimepointBuffer();
  QDateTime rangeTmin() const;
  QDateTime rangeTmax() const;
  void setCapacity(int buffer_size);
  boost::circular_buffer<int64_t>& Buffer() { return m_buffer; }

signals:
  void rangeTminChanged(QDateTime min);
  void rangeTmaxChanged(QDateTime max);
  void rangeChanged();

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

private:
  boost::circular_buffer<int64_t> m_buffer;
  QDateTime m_min_t,
    m_max_t;
};