跳转至

cf::ui::core::EmbeddedTokenRegistry

Embeddable token registry for component-scoped token storage. More...

#include <token.hpp>

Public Types

Name
template <typenameT >
using cf::expected< T, TokenError >
Result

Public Functions

Name
EmbeddedTokenRegistry() =default
~EmbeddedTokenRegistry() =default
EmbeddedTokenRegistry(constEmbeddedTokenRegistry & ) =delete
EmbeddedTokenRegistry & operator=(constEmbeddedTokenRegistry & ) =delete
EmbeddedTokenRegistry(EmbeddedTokenRegistry && other)
EmbeddedTokenRegistry & operator=(EmbeddedTokenRegistry && other)
template <typenameT ,typename... Args>
Result< void >
register_dynamic(std::string_view name, Args &&... args)
template <typenameT >
Result< void >
register_dynamic(std::string_view name, constT & value)
template <typenameT >
Result< void >
register_dynamic(std::string_view name, T && value)
template <typenameT >
Result< T * >
get_dynamic(std::string_view name)
Gets a dynamic token's value by name.
template <typenameT >
Result< T * >
get_dynamic_by_hash(uint64_t hash)
Gets a dynamic token's value by hash.
template <typenameT >
Result< constT * >
get_dynamic_const(std::string_view name) const
Gets a dynamic token's value by name (const).
bool contains(uint64_t hash) const
Checks if a token exists by hash.
bool contains(std::string_view name) const
Checks if a token exists by name.
bool remove(uint64_t hash)
Removes a token from the registry by hash.
bool remove(std::string_view name)
Removes a token from the registry by name.
size_t size() const
Gets the number of registered tokens.
template <typenameT ,typename... Args>
auto
register_dynamic(std::string_view name, Args &&... args)
template <typenameT >
auto
register_dynamic(std::string_view name, constT & value)
template <typenameT >
auto
register_dynamic(std::string_view name, T && value)
template <typenameT >
auto
get_by_hash_impl(uint64_t hash, const std::string & name_hint)
template <typenameT >
auto
get_by_hash_impl_const(uint64_t hash, const std::string & name_hint) const
template <typenameT >
auto
get_dynamic(std::string_view name)
template <typenameT >
auto
get_dynamic_by_hash(uint64_t hash)
template <typenameT >
auto
get_dynamic_const(std::string_view name) const

Detailed Description

class cf::ui::core::EmbeddedTokenRegistry;

Embeddable token registry for component-scoped token storage.

Note: Thread-safe for all operations.

Provides the same API as TokenRegistry but without singleton semantics. Can be embedded in other classes for independent token management.

class MyComponent {
public:
    EmbeddedTokenRegistry registry;
    void init() { registry.register_dynamic<int>("counter", 0); }
};

Public Types Documentation

using Result

template <typenameT >
using cf::ui::core::EmbeddedTokenRegistry::Result =  cf::expected<T, TokenError>;

Public Functions Documentation

function EmbeddedTokenRegistry

EmbeddedTokenRegistry() =default

function ~EmbeddedTokenRegistry

~EmbeddedTokenRegistry() =default

function EmbeddedTokenRegistry

EmbeddedTokenRegistry(
    constEmbeddedTokenRegistry & 
) =delete

function operator=

EmbeddedTokenRegistry & operator=(
    constEmbeddedTokenRegistry & 
) =delete

function EmbeddedTokenRegistry

inline EmbeddedTokenRegistry(
    EmbeddedTokenRegistry && other
)

function operator=

inline EmbeddedTokenRegistry & operator=(
    EmbeddedTokenRegistry && other
)

function register_dynamic

template <typenameT ,
typename... Args>
Result< void > register_dynamic(
    std::string_view name,
    Args &&... args
)

function register_dynamic

template <typenameT >
Result< void > register_dynamic(
    std::string_view name,
    constT & value
)

function register_dynamic

template <typenameT >
Result< void > register_dynamic(
    std::string_view name,
    T && value
)

function get_dynamic

template <typenameT >
Result< T * > get_dynamic(
    std::string_view name
)

Gets a dynamic token's value by name.

Return: Result containing pointer to the token's value or TokenError.

function get_dynamic_by_hash

template <typenameT >
Result< T * > get_dynamic_by_hash(
    uint64_t hash
)

Gets a dynamic token's value by hash.

Return: Result containing pointer to the token's value or TokenError.

function get_dynamic_const

template <typenameT >
Result< constT * > get_dynamic_const(
    std::string_view name
) const

Gets a dynamic token's value by name (const).

Return: Result containing const pointer to the token's value or TokenError.

function contains

inline bool contains(
    uint64_t hash
) const

Checks if a token exists by hash.

Parameters:

  • hash Hash value of the token to check.

Exceptions:

  • None

Return:

  • true if the token exists, false otherwise.
  • true if the token exists, false otherwise.

Since: 0.1

Note: Thread-safe for concurrent reads.

Warning: None

function contains

inline bool contains(
    std::string_view name
) const

Checks if a token exists by name.

Parameters:

  • name Name of the token to check.

Exceptions:

  • None

Return:

  • true if the token exists, false otherwise.
  • true if the token exists, false otherwise.

Since: 0.1

Note: Thread-safe for concurrent reads.

Warning: None

function remove

inline bool remove(
    uint64_t hash
)

Removes a token from the registry by hash.

Parameters:

  • hash Hash value of the token to remove.

Exceptions:

  • None

Return:

  • true if the token was removed, false if not found.
  • true if the token was removed, false if not found.

Since: 0.1

Note: Thread-safe for exclusive access.

Warning: None

function remove

inline bool remove(
    std::string_view name
)

Removes a token from the registry by name.

Parameters:

  • name Name of the token to remove.

Exceptions:

  • None

Return:

  • true if the token was removed, false if not found.
  • true if the token was removed, false if not found.

Since: 0.1

Note: Thread-safe for exclusive access.

Warning: None

function size

inline size_t size() const

Gets the number of registered tokens.

Exceptions:

  • None

Return:

  • Number of tokens in the registry.
  • Number of tokens in the registry.

Since: 0.1

Note: Thread-safe for concurrent reads.

Warning: None

function register_dynamic

template <typenameT ,
typename... Args>
auto register_dynamic(
    std::string_view name,
    Args &&... args
)

function register_dynamic

template <typenameT >
auto register_dynamic(
    std::string_view name,
    constT & value
)

function register_dynamic

template <typenameT >
auto register_dynamic(
    std::string_view name,
    T && value
)

function get_by_hash_impl

template <typenameT >
auto get_by_hash_impl(
    uint64_t hash,
    const std::string & name_hint
)

function get_by_hash_impl_const

template <typenameT >
auto get_by_hash_impl_const(
    uint64_t hash,
    const std::string & name_hint
) const

function get_dynamic

template <typenameT >
auto get_dynamic(
    std::string_view name
)

function get_dynamic_by_hash

template <typenameT >
auto get_dynamic_by_hash(
    uint64_t hash
)

function get_dynamic_const

template <typenameT >
auto get_dynamic_const(
    std::string_view name
) const

Updated on 2026-03-09 at 10:14:00 +0000