Program Listing for File DdsIdVec4d.hpp

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

#pragma once

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

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

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

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

public slots:
  void updateValue();

private:
  std::unique_ptr<sinspekto::Reader<fkin::IdVec4d>> m_reader;
  QString m_id;

};

class DdsIdVec4dPublisher : public QObject
{
  Q_OBJECT
  Q_PROPERTY(QVector4D value READ value WRITE setValue NOTIFY valueChanged)

public:
  explicit DdsIdVec4dPublisher(QObject *parent = nullptr);
  virtual ~DdsIdVec4dPublisher();
  QVector4D value() const;
  Q_INVOKABLE void init(
      QtToDds* dds,
      const QString& topic,
      const QString& id,
      QVector4D start_value,
      bool send_first);

signals:
  void valueChanged(QVector4D value);

public slots:
  void setValue(QVector4D value);

  void publish();

private:
  std::unique_ptr<sinspekto::Writer<fkin::IdVec4d>> m_writer;
};