Taskolib  1.3.3
Public Types | Public Member Functions | Static Public Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
task::UniqueId Class Reference

Detailed Description

An unsigned 64-bit integer for use as a unique ID.

#include <UniqueId.h>

Public Types

using ValueType = std::uint64_t
 

Public Member Functions

 UniqueId ()
 Default-construct a random unique ID. More...
 
 UniqueId (ValueType id)
 Construct a unique ID from a given integer. More...
 

Static Public Member Functions

static gul14::optional< UniqueIdfrom_string (gul14::string_view str)
 Create a unique ID from the given string, returning an empty optional if the string does not represent a valid hexadecimal number. More...
 

Private Attributes

ValueType id_
 

Static Private Attributes

static thread_local std::mt19937_64 random_number_generator_ { std::random_device{}() }
 

Friends

bool operator== (UniqueId a, UniqueId b)
 Determine if two unique IDs are equal. More...
 
bool operator!= (UniqueId a, UniqueId b)
 Determine if two unique IDs are different. More...
 
std::string to_string (UniqueId uid)
 Return a hexadecimal string representation of the given unique ID. More...
 

Member Typedef Documentation

◆ ValueType

using task::UniqueId::ValueType = std::uint64_t

Constructor & Destructor Documentation

◆ UniqueId() [1/2]

task::UniqueId::UniqueId ( )

Default-construct a random unique ID.

References id_, and random_number_generator_.

◆ UniqueId() [2/2]

task::UniqueId::UniqueId ( ValueType  id)
explicit

Construct a unique ID from a given integer.

Member Function Documentation

◆ from_string()

gul14::optional< UniqueId > task::UniqueId::from_string ( gul14::string_view  str)
static

Create a unique ID from the given string, returning an empty optional if the string does not represent a valid hexadecimal number.

The string must represent a hexadecimal number with a maximum of 16 characters. Neither leading whitespace nor a "0x" prefix are allowed.

Referenced by task::SequenceManager::parse_folder_name().

Friends And Related Function Documentation

◆ operator!=

bool operator!= ( UniqueId  a,
UniqueId  b 
)
friend

Determine if two unique IDs are different.

◆ operator==

bool operator== ( UniqueId  a,
UniqueId  b 
)
friend

Determine if two unique IDs are equal.

◆ to_string

std::string to_string ( UniqueId  uid)
friend

Return a hexadecimal string representation of the given unique ID.

Member Data Documentation

◆ id_

ValueType task::UniqueId::id_
private

Referenced by UniqueId().

◆ random_number_generator_

thread_local std::mt19937_64 task::UniqueId::random_number_generator_ { std::random_device{}() }
staticprivate

Referenced by UniqueId().


The documentation for this class was generated from the following files: