Thread-safe UID generator that increments globally across the application.
More...
#include <GlobalUID.hpp>
|
static size_t | GetNew () |
| Returns a new unique identifier.
|
static size_t | GetNew (const std::string &key) |
| Returns a new unique identifier incrementing the given Keys count.
|
template<typename T> |
static int | GetSID () |
template<typename T> |
static void | InitStaticRestorable () |
Thread-safe UID generator that increments globally across the application.
◆ GetNew() [1/2]
size_t dz::GlobalUID::GetNew |
( |
| ) |
|
|
inlinestatic |
Returns a new unique identifier.
- Returns
- A size_t representing a new unique ID.
◆ GetNew() [2/2]
size_t dz::GlobalUID::GetNew |
( |
const std::string & | key | ) |
|
|
inlinestatic |
Returns a new unique identifier incrementing the given Keys count.
- Returns
- A size_t representing a new unique ID.
◆ BackupFunction
std::function<bool(Serial&)> dz::GlobalUID::BackupFunction |
|
inlinestatic |
Initial value:= [](auto& serial) {
serial << Count;
serial << KeyedCounts.size();
for (auto& [key, key_count] : KeyedCounts)
serial << key << key_count;
return true;
}
◆ RestoreFunction
std::function<bool(Serial&)> dz::GlobalUID::RestoreFunction |
|
inlinestatic |
Initial value:= [](auto& serial) {
serial >> Count;
auto keyed_counts_size = KeyedCounts.size();
serial >> keyed_counts_size;
for (size_t count = 1; count <= keyed_counts_size; ++count) {
std::string key;
size_t key_count = 0;
serial >> key >> key_count;
KeyedCounts[key] = key_count;
}
return true;
}
◆ SID
int dz::GlobalUID::SID = 1 |
|
inlinestatic |
The documentation for this struct was generated from the following file: