mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-27 11:05:44 +08:00
Ref T211, fake and anonymous identifier static const
This commit is contained in:
@@ -32,29 +32,22 @@ namespace BlackMisc
|
|||||||
m_processId(QCoreApplication::applicationPid())
|
m_processId(QCoreApplication::applicationPid())
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
CIdentifier CIdentifier::anonymous()
|
CIdentifier::CIdentifier(const QString &name, const QString &machineId, const QString &machineName,
|
||||||
|
const QString &processName, qint64 processId) :
|
||||||
|
ITimestampBased(QDateTime::currentMSecsSinceEpoch()),
|
||||||
|
m_name(name), m_machineIdBase64(machineId), m_machineName(machineName),
|
||||||
|
m_processName(processName), m_processId(processId)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
const CIdentifier &CIdentifier::anonymous()
|
||||||
{
|
{
|
||||||
static CIdentifier id;
|
static const CIdentifier id("anonymous", "", "", "", 0);
|
||||||
if (id.m_processId)
|
|
||||||
{
|
|
||||||
id.m_processId = 0;
|
|
||||||
id.m_processName = "";
|
|
||||||
id.m_machineName = "";
|
|
||||||
id.m_machineIdBase64 = "";
|
|
||||||
}
|
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
CIdentifier CIdentifier::fake()
|
const CIdentifier &CIdentifier::fake()
|
||||||
{
|
{
|
||||||
static CIdentifier id;
|
static const CIdentifier id("fake", QByteArrayLiteral("0").repeated(32).toBase64(), "fake machine", "fake process", 0);
|
||||||
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;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,7 +94,7 @@ namespace BlackMisc
|
|||||||
|
|
||||||
bool CIdentifier::isAnonymous() const
|
bool CIdentifier::isAnonymous() const
|
||||||
{
|
{
|
||||||
return anonymous() == *this;
|
return &anonymous() == this || anonymous() == *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CIdentifier::convertToQString(bool i18n) const
|
QString CIdentifier::convertToQString(bool i18n) const
|
||||||
|
|||||||
@@ -53,10 +53,10 @@ namespace BlackMisc
|
|||||||
CIdentifier(const QString &name = QString());
|
CIdentifier(const QString &name = QString());
|
||||||
|
|
||||||
//! Returns an anonymous identifier.
|
//! Returns an anonymous identifier.
|
||||||
static CIdentifier anonymous();
|
static const CIdentifier &anonymous();
|
||||||
|
|
||||||
//! Returns a fake identifier.
|
//! Returns a fake identifier.
|
||||||
static CIdentifier fake();
|
static const CIdentifier &fake();
|
||||||
|
|
||||||
//! Produces a UUID generated from the identifier.
|
//! Produces a UUID generated from the identifier.
|
||||||
QUuid toUuid() const;
|
QUuid toUuid() const;
|
||||||
@@ -110,6 +110,10 @@ namespace BlackMisc
|
|||||||
void setPropertyByIndex(const BlackMisc::CPropertyIndex &index, const CVariant &variant);
|
void setPropertyByIndex(const BlackMisc::CPropertyIndex &index, const CVariant &variant);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
//! Constructor.
|
||||||
|
CIdentifier(const QString &name, const QString &machineId, const QString &machineName,
|
||||||
|
const QString &processName, qint64 processId = 0);
|
||||||
|
|
||||||
QString m_name; //!< object name
|
QString m_name; //!< object name
|
||||||
QString m_machineIdBase64; //!< base 64 encoded machine id
|
QString m_machineIdBase64; //!< base 64 encoded machine id
|
||||||
QString m_machineName; //!< human readable machine name
|
QString m_machineName; //!< human readable machine name
|
||||||
|
|||||||
Reference in New Issue
Block a user