refactor to unmask virtual functions
This commit is contained in:
parent
eaf49608e5
commit
23a4647342
|
@ -19,7 +19,7 @@ QSacnNode::QSacnNode(QObject *parent, QUuid cid)
|
|||
bind(QHostAddress::AnyIPv4, SACN::ACN_SDT_MULTICAST_PORT);
|
||||
|
||||
connect(this, &QUdpSocket::readyRead,
|
||||
this, &QSacnNode::UdpPayloadReceiver);
|
||||
this, &QSacnNode::udpReceive);
|
||||
|
||||
onDiscovered(std::bind(&QSacnNode::emitFound, this,
|
||||
std::placeholders::_1));
|
||||
|
@ -64,7 +64,7 @@ void QSacnNode::unsubscribe(const uint16_t num)
|
|||
/**
|
||||
* @brief QSacnNode::UdpPayloadReceiver
|
||||
*/
|
||||
void QSacnNode::UdpPayloadReceiver()
|
||||
void QSacnNode::udpReceive()
|
||||
{
|
||||
while (hasPendingDatagrams()) {
|
||||
QNetworkDatagram datagram = receiveDatagram();
|
||||
|
@ -76,7 +76,7 @@ void QSacnNode::UdpPayloadReceiver()
|
|||
SACN::PDU::Stream stream(new SACN::PDU::pdu_stream(
|
||||
(uint8_t*)datagram.data().constData(),
|
||||
datagram.data().length()));
|
||||
Receiver::UdpPayloadReceiver(stream);
|
||||
UdpPayloadReceiver(stream);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,22 +9,9 @@
|
|||
#include <QUuid>
|
||||
|
||||
|
||||
// 9.3.1 Allocation of IPv4 Multicast Addresses
|
||||
// Multicast addresses are from the IPv4 Local Scope.
|
||||
inline QHostAddress IPv4MulticastAddress(uint16_t universe) {
|
||||
quint32 address = 239 << 24 | 255 << 16 | universe;
|
||||
return QHostAddress(address);
|
||||
};
|
||||
|
||||
|
||||
// 9.3.2 Allocation of IPv6 Multicast Addresses
|
||||
inline QHostAddress IPv6MulticastAddress(uint16_t universe) {
|
||||
quint8 address [] = {255, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 131, 0,
|
||||
(quint8)(universe >> 8), (quint8)(universe & 0xff)};
|
||||
return QHostAddress(address);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @brief The QSacnNode class
|
||||
*/
|
||||
class QT_EXPORT QSacnNode
|
||||
: public QUdpSocket
|
||||
, public SACN::Node
|
||||
|
@ -44,10 +31,24 @@ signals:
|
|||
std::shared_ptr<SACN::EXTENDED::DISCOVERY::DiscoveredUniverse>);
|
||||
|
||||
private:
|
||||
void UdpPayloadReceiver();
|
||||
void udpReceive();
|
||||
void emitFound(
|
||||
std::shared_ptr<SACN::EXTENDED::DISCOVERY::DiscoveredUniverse>);
|
||||
|
||||
QHash<uint16_t, QSacnUniverse*> universes_;
|
||||
|
||||
public:
|
||||
// 9.3.1 Allocation of IPv4 Multicast Addresses
|
||||
// Multicast addresses are from the IPv4 Local Scope.
|
||||
static inline QHostAddress IPv4MulticastAddress(uint16_t universe) {
|
||||
quint32 address = 239 << 24 | 255 << 16 | universe;
|
||||
return QHostAddress(address);
|
||||
};
|
||||
// 9.3.2 Allocation of IPv6 Multicast Addresses
|
||||
static inline QHostAddress IPv6MulticastAddress(uint16_t universe) {
|
||||
quint8 address [] = {255, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 131, 0,
|
||||
(quint8)(universe >> 8), (quint8)(universe & 0xff)};
|
||||
return QHostAddress(address);
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -2,17 +2,23 @@
|
|||
|
||||
#include <QObject>
|
||||
|
||||
#include "qsacnnode_global.h"
|
||||
#include "../../sacn/universe.h"
|
||||
|
||||
/**
|
||||
* @brief The QSacnUniverse class
|
||||
*/
|
||||
class QSacnUniverse
|
||||
class QT_EXPORT QSacnUniverse
|
||||
: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
friend DMX::Universe; // permit callback to access the private notifier
|
||||
/**
|
||||
* @brief QSacnUniverse
|
||||
* @param parent
|
||||
* @param universe
|
||||
*/
|
||||
explicit QSacnUniverse(QObject *parent = nullptr,
|
||||
SACN::Universe *universe = nullptr)
|
||||
: QObject(parent)
|
||||
|
@ -42,7 +48,7 @@ public:
|
|||
return universe_->rxRate();
|
||||
}
|
||||
|
||||
uint8_t value(const u_int16_t slot) const
|
||||
uint8_t slot(const u_int16_t slot) const
|
||||
{
|
||||
return universe_->slot(slot);
|
||||
}
|
||||
|
|
|
@ -88,15 +88,15 @@ QVariant UniverseModel::data(const QModelIndex &index, int role) const
|
|||
return QVariant();
|
||||
switch (data_mode_) {
|
||||
case Decimal:
|
||||
return universe_->value(slot);
|
||||
return universe_->slot(slot);
|
||||
break;
|
||||
case Hex:
|
||||
return QString("%1")
|
||||
.arg(universe_->value(slot), 2, 16, QChar('0'))
|
||||
.arg(universe_->slot(slot), 2, 16, QChar('0'))
|
||||
.toUpper();
|
||||
break;
|
||||
case Percent:
|
||||
return QString("%1%").arg((universe_->value(slot) / 255.0F) * 100,
|
||||
return QString("%1%").arg((universe_->slot(slot) / 255.0F) * 100,
|
||||
0, 'f', 0, '0');
|
||||
break;
|
||||
}
|
||||
|
@ -121,7 +121,8 @@ QVariant UniverseModel::data(const QModelIndex &index, int role) const
|
|||
* @param role
|
||||
* @return
|
||||
*/
|
||||
bool UniverseModel::setData(const QModelIndex &index, const QVariant &value, int role)
|
||||
bool UniverseModel::setData(const QModelIndex &index, const QVariant &value,
|
||||
int role)
|
||||
{
|
||||
if (data(index, role) != value) {
|
||||
// FIXME: Implement me!
|
||||
|
@ -172,7 +173,7 @@ void UniverseModel::universeRefreshed() {
|
|||
void UniverseModel::setDataMode(const QString mode)
|
||||
{
|
||||
auto&& metaEnum = QMetaEnum::fromType<data_modes>();
|
||||
data_mode_ = static_cast<data_modes>(metaEnum.keyToValue(mode.toLocal8Bit())); emit dataChanged(index(0,0), index(rowCount(), columnCount()));
|
||||
data_mode_ = static_cast<data_modes>(metaEnum.keyToValue(mode.toLocal8Bit()));
|
||||
emit dataChanged(index(0,0), index(rowCount(), columnCount()));
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
#pragma once
|
||||
|
||||
#include "qsacnnode_global.h"
|
||||
#include <QAbstractTableModel>
|
||||
#include "qsacnuniverse.h"
|
||||
|
||||
class UniverseModel : public QAbstractTableModel
|
||||
class QT_EXPORT UniverseModel
|
||||
: public QAbstractTableModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
@ -35,7 +37,7 @@ public:
|
|||
// Data source:
|
||||
void setUniverse(QSacnUniverse *universe);
|
||||
QSacnUniverse * universe() const { return universe_; }
|
||||
const data_modes dataMode() { return data_mode_; }
|
||||
data_modes dataMode() { return data_mode_; }
|
||||
|
||||
signals:
|
||||
void recievedUpdate(const QSacnUniverse*);
|
||||
|
|
Loading…
Reference in New Issue