#pragma once #include #include #include namespace DDSConnector { class DdsConnector; } namespace Core { struct key { inline key() = default; inline key(int64_t id, int exId, const QString &name) : entityTypeName(name) , entityId(id) , exerciseId(exId) {} inline bool operator==(const key &o) const { return entityId == o.entityId && exerciseId == o.exerciseId && entityTypeName == o.entityTypeName; } QString entityTypeName; int64_t entityId = 0; int exerciseId = 0; }; inline uint qHash(const Core::key &k, uint seed = 0) { return ::qHash(k.entityTypeName, seed) ^ ::qHash(k.entityId, seed) ^ ::qHash(k.exerciseId, seed); } class CORE_CLIENT_EXPORT TopicLockMaster : public QObject { Q_OBJECT public: explicit TopicLockMaster(const std::shared_ptr &ddsConnector); ~TopicLockMaster(); bool init(const std::shared_ptr &ddsConnector); template bool isLocked(const E &data, int exerciseId) { auto it = m_lockedEntitys.constFind(key(data.id(), exerciseId, QString::fromStdString(typeid(E).name()))); return !(it == m_lockedEntitys.cend()); } private: QSet m_lockedEntitys; std::shared_ptr m_coreDtc; }; }