Continues migration with DDS, Common
This commit is contained in:
1 parent
9b15cee841
commit
fa48db111e
668 files changed
+111841
-2
No files matched your search
Executable
+64
@@ -0,0 +1,64 @@
|
||||
#pragma once
|
||||
|
||||
#include <Core/core_dtc.h>
|
||||
|
||||
#include <QSet>
|
||||
#include <QString>
|
||||
|
||||
|
||||
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::DdsConnector> &ddsConnector);
|
||||
~TopicLockMaster();
|
||||
|
||||
bool init(const std::shared_ptr<DDSConnector::DdsConnector> &ddsConnector);
|
||||
|
||||
template<typename E>
|
||||
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<key> m_lockedEntitys;
|
||||
std::shared_ptr<Core::Interface::Dtc> m_coreDtc;
|
||||
};
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user