Program Listing for File DdsIdVec2d.hpp

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

#pragma once

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

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

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

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

public slots:
  void updateValue();

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

};

class DdsIdVec2dPublisher : public QObject
{
  Q_OBJECT
  Q_PROPERTY(QVector2D value READ value WRITE setValue NOTIFY valueChanged)

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

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

signals:
  void valueChanged(QVector2D value);

public slots:
  void setValue(QVector2D value);

  void publish();

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