mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 21:07:02 +08:00
CIdentifier utility classes
fake() returns a fake identifier, simulating an existing one. isFromSameMachine() is a utility class to compare whether another CIdentifier is from the same machine refs #881
This commit is contained in:
committed by
Mathew Sutcliffe
parent
42a13fceff
commit
54b76d91ad
@@ -38,6 +38,19 @@ namespace BlackMisc
|
||||
return id;
|
||||
}
|
||||
|
||||
CIdentifier CIdentifier::fake()
|
||||
{
|
||||
static CIdentifier id;
|
||||
if (id.m_processId)
|
||||
{
|
||||
id.m_processId = 0;
|
||||
id.m_processName = "fake process";
|
||||
id.m_machineName = "fake machine";
|
||||
id.m_machineIdBase64 = QByteArrayLiteral("0").repeated(32).toBase64();
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
QUuid CIdentifier::toUuid() const
|
||||
{
|
||||
static const QUuid ns = QUuid::createUuid();
|
||||
@@ -59,6 +72,11 @@ namespace BlackMisc
|
||||
return QDBusConnection::localMachineId() == getMachineId();
|
||||
}
|
||||
|
||||
bool CIdentifier::isFromSameMachine(const CIdentifier &other) const
|
||||
{
|
||||
return getMachineIdBase64() == other.getMachineIdBase64();
|
||||
}
|
||||
|
||||
bool CIdentifier::isFromSameProcess() const
|
||||
{
|
||||
return QCoreApplication::applicationPid() == getProcessId() && isFromLocalMachine();
|
||||
|
||||
Reference in New Issue
Block a user