#pragma once

#include <QObject>
#include <QList>
#include <QMap>

#include "qsacn_global.h"
#include "sacn/universe.h"

/**
 * @brief The QSacnUniverse class
 */
class QT_EXPORT QSacnUniverse
        : public QObject
{
    Q_OBJECT
public:
  explicit QSacnUniverse(QObject *parent = nullptr,
                         std::shared_ptr<sACN::Universe> universe = nullptr);
  virtual ~QSacnUniverse();

  const QString description() const;
  uint16_t number() const;
  uint8_t  priority() const;
  double   rxRate() const;
  uint8_t  slot(const uint16_t) const;
  uint16_t activeSlots() const;
  bool isEditable() const;
  QList<sACN::DATA::data_header> sources() const;
  QSacnUniverse* sourceUniverse(const sACN::DATA::data_header&);

public slots:
  void setDescription(std::string desc);
  void setOptions(sACN::DATA::data_options o);
  void setPriority(uint8_t p);
  void setSyncAddress(uint16_t a);
  void setValue (const uint16_t addr, const uint8_t level);
  void setValue (const uint16_t addr, const uint16_t size,
                 const uint8_t* profile);
  void syncSources();

signals:
  void changed();
  void sourceListChanged();

private:
  std::shared_ptr<sACN::Universe> universe_;
  QMap<sACN::DATA::data_header, QSacnUniverse*> sources_;

  std::shared_ptr<void> data_change_token;
  std::shared_ptr<void> list_change_token;
};
Q_DECLARE_METATYPE(QSacnUniverse*)
