9 #ifndef CPPCOMMON_SYSTEM_UUID_H
10 #define CPPCOMMON_SYSTEM_UUID_H
14 #include "ns3/object.h"
43 explicit UUID(
const std::string& uuid);
53 UUID& operator=(const std::
string& uuid)
54 {
_data =
UUID(uuid).data();
return *
this; }
61 friend
bool operator==(const
UUID& uuid1, const
UUID& uuid2)
62 {
return uuid1.
_data == uuid2._data; }
75 explicit operator bool() const noexcept {
return *
this !=
Nil(); }
78 std::array<uint8_t, 16>&
data() noexcept {
return _data; }
80 const std::array<uint8_t, 16>&
data() const noexcept {
return _data; }
83 std::string
string()
const;
94 { os << uuid.
string();
return os; }
Universally unique identifier (UUID)
UUID()
Default constructor.
friend bool operator<(const UUID &uuid1, const UUID &uuid2)
const std::array< uint8_t, 16 > & data() const noexcept
Get the UUID data buffer.
std::array< uint8_t, 16 > & data() noexcept
Get the UUID data buffer.
friend bool operator>(const UUID &uuid1, const UUID &uuid2)
UUID(const std::array< uint8_t, 16 > &data)
Initialize UUID with a given 16 bytes data buffer.
friend bool operator<=(const UUID &uuid1, const UUID &uuid2)
friend std::ostream & operator<<(std::ostream &os, const UUID &uuid)
Output instance into the given output stream.
UUID(const UUID &)=default
void swap(UUID &uuid) noexcept
Swap two instances.
friend bool operator>=(const UUID &uuid1, const UUID &uuid2)
UUID & operator=(const std::array< uint8_t, 16 > &data)
static UUID Random()
Generate random UUID4 (randomly or pseudo-randomly generated version)
static UUID Nil()
Generate nil UUID0 (all bits set to zero)
static UUID Sequential()
Generate sequential UUID1 (time based version)
friend bool operator!=(const UUID &uuid1, const UUID &uuid2)
std::string string() const
Get string from the current UUID in format "00000000-0000-0000-0000-000000000000".
UUID & operator=(UUID &&) noexcept=default
std::array< uint8_t, 16 > _data
UUID & operator=(const UUID &)=default
UUID(UUID &&) noexcept=default
Every class exported by the ns3 library is enclosed in the ns3 namespace.