Tesseract 0.28.4
Loading...
Searching...
No Matches
tesseract::common::NameId< Tag > Struct Template Reference

Tagged integer identity type for links and joints. More...

#include <types.h>

Public Member Functions

TESSERACT_NAMEID_EXPLICIT NameId (std::string name) noexcept
TESSERACT_NAMEID_EXPLICIT NameId (const char *name)
constexpr std::size_t value () const noexcept
 The numeric hash of the name. Zero for an invalid id, but zero is not reserved — a name may legitimately hash to it, so validity is decided by the name, not by this value.
const std::string & name () const noexcept
 Access the original name string. Empty for default-constructed (invalid) IDs.
bool isValid () const noexcept
 An id is valid iff it carries a name; the string constructors are the only source of one.
bool operator== (const NameId &other) const noexcept
 Watertight (hybrid) equality: compare the cached hash value first; only when the values match, confirm with the name strings. Two distinct names that collide on the hash value therefore compare UNEQUAL, so hash-keyed containers keep them as distinct keys and resolve the collision exactly like a string-keyed hash map would.
bool operator!= (const NameId &other) const noexcept
bool operator< (const NameId &other) const noexcept
 Order by hash value, NOT by name — hash-random, useful for ordered containers but produces no human-meaningful ordering (sort by name() explicitly for display). Value ties (hash collisions) are broken by name so ordering is consistent with operator== (a strict weak ordering whose equivalence is exactly hybrid equality).

Friends

struct NameIdTestAccess
 Test-only backdoor for manufacturing hash collisions (ids whose value is not derived from the name).

Detailed Description

template<typename Tag>
struct tesseract::common::NameId< Tag >

Tagged integer identity type for links and joints.

Wraps a hash value computed from the name via boost::hash<std::string>. Distinct tag types (LinkTag, JointTag) prevent accidental cross-use. IDs are runtime-only — never persisted. Deterministic within a single process execution.

Member Function Documentation

◆ operator==()

template<typename Tag>
bool tesseract::common::NameId< Tag >::operator== ( const NameId< Tag > & other) const
inlinenoexcept

Watertight (hybrid) equality: compare the cached hash value first; only when the values match, confirm with the name strings. Two distinct names that collide on the hash value therefore compare UNEQUAL, so hash-keyed containers keep them as distinct keys and resolve the collision exactly like a string-keyed hash map would.

Load-bearing invariant: every valid NameId carries the name it was constructed from (the string constructors are the only public way to obtain a valid id), so the name is always available for the confirming compare.