Skip to content

NameTable

Generated from engine/core/name_table.h at 862e08b. The text under each declaration is the header's own comment, word for word. About the reference says how these pages are made.

Browse the core module

#include "engine/core/name_table.h" · namespace labrador

class NameTable

Named elements stored by value, resolved to handles once and then read by index. The same names-in, handles-out bargain as Registry, for the case where the elements are part of a larger asset rather than assets in their own right: a sprite sheet's frames and animation strips.

Registry is the one to reach for when the entries have independent lifetimes - when something can be released and reloaded underneath a live handle. A NameTable is filled once by a loader and is const thereafter, so it stores elements directly: one allocation for the lot, contiguous, and no indirection on the read.

Because it never grows after loading, references into it are stable, which is what lets a caller hold a const Element& across a frame.

explicit NameTable(const char* kind);

kind names the element type in error messages: "sprite frame", "animation strip". Stored, not copied - pass a literal.

void add(const std::string& name, Element element);

Load-time only. A repeated name replaces the earlier element and keeps its index, so no handle resolved from this table is ever left dangling.

Handle<Element> resolve(const std::string& name) const;

Throws std::out_of_range naming the element and the kind if the table has no such name - a sheet asked for a frame it does not contain is a content bug, and it should say so at load rather than draw nothing.

const Element& get(Handle<Element> element_handle) const;

The per-frame read: a bounds check and an index. Throws rather than return a reference to nothing.

bool contains(const std::string& name) const;

Named in the public declarations above: Handle.

The files that include this header directly. A file can also reach it through another header.

Development documentation (unreleased). Built from Labrador 862e08b of 2026-10-08.