Program Listing for File DdsIdVec3d.hpp

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

#pragma once

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

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

public:
  explicit DdsIdVec3dSubscriber(QObject *parent = nullptr);
  virtual ~DdsIdVec3dSubscriber();
  QVector3D value() const;
  QDateTime timestamp() const;
  Q_INVOKABLE void init(
      QtToDds* dds,
      const QString& topic,
      const QString& id,
      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<fkin::IdVec3d>> m_reader;
  QString m_id;

};

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

public:
  explicit DdsIdVec3dPublisher(QObject *parent = nullptr);
  virtual ~DdsIdVec3dPublisher();
  QVector3D value() const;
  Q_INVOKABLE void init(
      QtToDds* dds,
      const QString& topic,
      const QString& id,
      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<fkin::IdVec3d>> m_writer;
};