Skip to main content

Guid Class

Representative of a Globally Unique Identifier. More...

Declaration

class helios::engine::util::Guid { ... }

Public Constructors Index

Guid (helios::ecs::types::no_init_t)

Unsafe Guid initializer for (local) var initialization. More...

Private Constructors Index

Guid (uint64_t value) noexcept

Public Operators Index

constexpr booloperator== (const Guid &guid) const =default

Compares two Guid instances for equality. More...

constexpr booloperator!= (const Guid &guid) const =default

Compares two Guid instances for inequality. More...

constexpr booloperator< (const Guid &guid) const noexcept

Less-than comparison operator, enabling ordering of Guid instances. More...

constexpr booloperator> (const Guid &guid) const noexcept

Greater-than comparison operator, enabling ordering of Guid instances. More...

Public Member Functions Index

constexpr uint64_tvalue () const noexcept

Returns the raw 64-bit value of this Guid. More...

std::size_thash () const noexcept

Calculates a hash fot this GUID. More...

Private Member Attributes Index

uint64_tvalue_ {}

Public Static Functions Index

static Guidgenerate () noexcept

Generates a new Guid. More...

Description

Representative of a Globally Unique Identifier.

Generating GUIDs with this class is considered thread-safe.

Definition at line 24 of file Guid.ixx.

Public Constructors

Guid()

helios::engine::util::Guid::Guid (helios::ecs::types::no_init_t)
inline explicit

Unsafe Guid initializer for (local) var initialization.

Definition at line 34 of file Guid.ixx.

34 explicit Guid(helios::ecs::types::no_init_t) {};

Private Constructors

Guid()

helios::engine::util::Guid::Guid (uint64_t value)
inline explicit noexcept

Definition at line 26 of file Guid.ixx.

26 explicit Guid(uint64_t value) noexcept : value_(value) {}

Public Operators

operator!=()

constexpr bool helios::engine::util::Guid::operator!= (const Guid & guid)
constexpr default

Compares two Guid instances for inequality.

Parameters
guid

The Guid to compare against.

Returns

true if the Guids have different underlying values, false otherwise.

Definition at line 52 of file Guid.ixx.

operator<()

constexpr bool helios::engine::util::Guid::operator< (const Guid & guid)
inline constexpr noexcept

Less-than comparison operator, enabling ordering of Guid instances.

Parameters
guid

The Guid to compare against.

Returns

true if this Guid's value is less than the other, false otherwise.

Definition at line 61 of file Guid.ixx.

61 constexpr bool operator<(const Guid& guid) const noexcept {
62 return value_ < guid.value();
63 }

operator==()

constexpr bool helios::engine::util::Guid::operator== (const Guid & guid)
constexpr default

Compares two Guid instances for equality.

Parameters
guid

The Guid to compare against.

Returns

true if both Guids have the same underlying value, false otherwise.

Definition at line 43 of file Guid.ixx.

operator>()

constexpr bool helios::engine::util::Guid::operator> (const Guid & guid)
inline constexpr noexcept

Greater-than comparison operator, enabling ordering of Guid instances.

Parameters
guid

The Guid to compare against.

Returns

true if this Guid's value is greater than the other, false otherwise.

Definition at line 72 of file Guid.ixx.

72 constexpr bool operator>(const Guid& guid) const noexcept {
73 return value_ > guid.value();
74 }

Public Member Functions

hash()

std::size_t helios::engine::util::Guid::hash ()
inline noexcept

Calculates a hash fot this GUID.

The hash simply defaults to the value_ of this Guid.

Returns

The hash value for this Guid.

Definition at line 106 of file Guid.ixx.

106 [[nodiscard]] std::size_t hash() const noexcept {
107 return std::hash<uint64_t>{}(value_);
108 }

value()

constexpr uint64_t helios::engine::util::Guid::value ()
inline constexpr noexcept

Returns the raw 64-bit value of this Guid.

Returns

The underlying uint64_t value representing this Guid.

Definition at line 95 of file Guid.ixx.

96 return value_;
97 }

Private Member Attributes

value_

uint64_t helios::engine::util::Guid::value_ {}

Definition at line 27 of file Guid.ixx.

27 uint64_t value_{};

Public Static Functions

generate()

Guid helios::engine::util::Guid::generate ()
inline noexcept static

Generates a new Guid.

This function produces a new, unique Guid value. It is safe to call from multiple threads.

Returns

A newly generated Guid instance.

Definition at line 85 of file Guid.ixx.

86 static std::atomic<uint64_t> counter{1};
87 return Guid(counter.fetch_add(1, std::memory_order_relaxed));
88 }

Reference helios::registerComponents.


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


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.8.