Skip to content

Commit

Permalink
Pass (const) reference not copy of listener and sender lists
Browse files Browse the repository at this point in the history
Resolves #246
  • Loading branch information
marcusbirkin authored and Tom Steer committed Jan 30, 2022
1 parent d3d031b commit d0d4de5
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions src/sacn/streamingacn.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,59 @@ enum StreamingACNProtocolVersion
sACNProtocolRelease,
};

// The sACNManager class is a singleton that manages the lifespan of sACNTransmitters and sACNListeners.
class sACNManager : public QObject
{
Q_OBJECT
public:
static sACNManager *getInstance();

typedef QSharedPointer<sACNListener> tListener;
typedef QSharedPointer<sACNSentUniverse> tSender;

public slots:
void listenerDelete(QObject *obj = Q_NULLPTR);

void senderDelete(QObject *obj = Q_NULLPTR);
private:
sACNManager();
static sACNManager *m_instance;
QMutex sACNManager_mutex;

QHash<QObject*, quint16> m_objToUniverse;
QHash<QObject*, CID> m_objToCid;

QHash<quint16, QWeakPointer<sACNListener>> m_listenerHash;
QHash<quint16, QThread *> m_listenerThreads;

tSender createSender(CID cid, quint16 universe);
QHash<CID, QHash<quint16, QWeakPointer<sACNSentUniverse>> > m_senderHash;

public:
tListener getListener(quint16 universe);
const decltype(m_listenerHash) &getListenerList() { return m_listenerHash; }

tSender getSender(quint16 universe, CID cid = CID::CreateCid());
const decltype(m_senderHash) &getSenderList() { return m_senderHash; }

signals:
void newSender();
void deletedSender(CID cid, quint16 universe);

void newListener(quint16 universe);
void deletedListener(quint16 universe);

void sourceFound(quint16 universe, sACNSource *source);
void sourceLost(quint16 universe, sACNSource *source);
void sourceResumed(quint16 universe, sACNSource *source);
void sourceChanged(quint16 universe, sACNSource *source);

private slots:
void senderUniverseChanged();
void senderCIDChanged();

private:
};

class sACNSource : public QObject
{
Expand Down

0 comments on commit d0d4de5

Please sign in to comment.