#pragma once

#include <QObject>
#include "interfaces/plugin_interface.hpp"
#include <fastdds/dds/domain/DomainParticipant.hpp>
#include <fastdds/dds/publisher/Publisher.hpp>
#include <fastdds/dds/publisher/DataWriter.hpp>
#include <fastdds/dds/topic/Topic.hpp>
#include <fastdds/dds/topic/TypeSupport.hpp>

using namespace eprosima::fastdds::dds;

class AQTPackageMachinePlug : public QObject, public AuseftDDSPluginInterface
{
    Q_OBJECT
    Q_PLUGIN_METADATA(IID AuseftDDSPluginInterface_iid FILE "AQTPackageMachinePlug.json")
    Q_INTERFACES(AuseftDDSPluginInterface)

public:
    explicit AQTPackageMachinePlug(QObject *parent = nullptr);
    ~AQTPackageMachinePlug() override;

    Q_INVOKABLE bool init() override;
    Q_INVOKABLE void publishOnce() override;
    Q_INVOKABLE QString echo(const QString& message) override;
    Q_INVOKABLE int calculate(int a, int b) override;

signals:
    void messagePublished(const QString& message, int index);

private:
    DomainParticipant* participant_;
    Publisher* publisher_;
    Topic* topic_;
    DataWriter* writer_;
    TypeSupport type_;
    int message_index_;
}; 