#include <uid.h>
Definition at line 27 of file uid.h.
◆ getCurrentMiroseconds()
uint64_t UidCalculator::getCurrentMiroseconds |
( |
| ) |
|
|
staticprivate |
Definition at line 69 of file uid.cpp.
Referenced by getNewObjectId().
71 #if (defined _WIN32_) || (defined _MSC_VER) 72 LARGE_INTEGER tickPerSecond;
76 QueryPerformanceFrequency(&tickPerSecond);
79 QueryPerformanceCounter(&tick);
82 return (tick.QuadPart % tickPerSecond.QuadPart);
◆ getNewInstanceId()
uint32_t UidCalculator::getNewInstanceId |
( |
| ) |
|
|
static |
Get a new instance unique Id. It is made of from LSB to MSB:
- 2 byte process id
- 2 byte hashed host name
Definition at line 50 of file uid.cpp.
References i.
52 uint32_t uid = (QCoreApplication::applicationPid() % (1<<16));
54 QString hostname = QHostInfo::localHostName();
55 QByteArray hashKey = QCryptographicHash::hash(hostname.toUtf8(), QCryptographicHash::Sha1);
58 for (
int i = 0;
i < hashKey.size();
i++) {
59 char c = hashKey.at(
i);
64 uid += (hashHost<<16);
◆ getNewObjectId()
uint64_t UidCalculator::getNewObjectId |
( |
| ) |
|
|
static |
Get a new object unique Id. It is the addition of:
- 6 digit microseconds in current second
- 4 byte Unix epoch multiplied by 1000000
Definition at line 35 of file uid.cpp.
References getCurrentMiroseconds().
37 QDateTime currentDateTime = QDateTime::currentDateTime();
38 uint64_t uid = currentDateTime.toTime_t();
static uint64_t getCurrentMiroseconds()
unsigned __int64 uint64_t
The documentation for this class was generated from the following files: