Program Listing for File RatatoskDouble3.hpp

Return to documentation for file (sinspekto/ratatosk/RatatoskDouble3.hpp)

#pragma once

#include "sinspekto/QtToDds.hpp"
#include "QDateTime"
#include "QVector3D"

class RatatoskDouble3Subscriber : public QObject
{
  Q_OBJECT
  Q_PROPERTY(QVector3D value READ value NOTIFY valueChanged)
  Q_PROPERTY(QDateTime timestamp READ timestamp NOTIFY timestampChanged)

public:
  explicit RatatoskDouble3Subscriber(QObject *parent = nullptr);
  virtual ~RatatoskDouble3Subscriber();
  QVector3D value() const;
  QDateTime timestamp() const;
  Q_INVOKABLE void init(
      QtToDds* dds,
      const QString& topic,
      bool with_listener=true);

signals:
  void valueChanged(QVector3D value);
  void timestampChanged(QDateTime timestamp);
  void eventHeard();

public slots:
  void updateValue();

private:
  std::unique_ptr<sinspekto::Reader<ratatosk::types::Double3>> m_reader;

};

class RatatoskDouble3Publisher : public QObject
{
  Q_OBJECT
  Q_PROPERTY(QVector3D value READ value WRITE setValue NOTIFY valueChanged)

public:
  explicit RatatoskDouble3Publisher(QObject *parent = nullptr);
  virtual ~RatatoskDouble3Publisher();

  QVector3D value() const;
  Q_INVOKABLE void init(
      QtToDds* dds,
      const QString& topic,
      QVector3D start_value,
      bool send_first);

signals:
  void valueChanged(QVector3D value);

public slots:
  void setValue(QVector3D value);

  void publish();

private:
  std::unique_ptr<sinspekto::Writer<ratatosk::types::Double3>> m_writer;
};