Class LayerRegistry

Class Documentation

class LayerRegistry

Registry of named layers (per-NavCel).

Provides creation-or-lookup semantics with navmap::LayerRegistry::add_or_get(). All layers in the registry are expected to have a size equal to the number of NavCels in the owning navmap::NavMap.

Public Functions

template<typename T>
inline std::shared_ptr<LayerView<T>> add_or_get(const std::string &name, size_t nitems, LayerType type)

Add a new typed layer or return an existing one with the same name.

If a layer with name already exists, it is returned (no resize). Otherwise a new layer is created with nitems elements.

Template Parameters:

T – Storage type (e.g., uint8_t, float, double).

Parameters:
  • name – Layer name (unique key).

  • nitems – Number of NavCels to allocate.

  • type – Runtime type tag corresponding to T.

Returns:

Shared pointer to the typed view.

inline std::shared_ptr<LayerViewBase> get(const std::string &name) const

Get an existing layer by name (untyped view).

Parameters:

name – Layer name.

Returns:

Pointer to base view, or nullptr if not found.

inline std::vector<std::string> list() const

List layer names currently in the registry.

Returns:

Vector of names (unordered).

inline bool remove(const std::string &name)

Remove a layer by name.

Returns:

true if the layer existed and was removed.

inline void resize_all(size_t nitems)

Resize all known typed layers to nitems.

Useful after changing the number of NavCels. Unknown types are ignored.

Parameters:

nitems – New number of items (NavCels).