|
Hyperiso 1.0.3
Modular flavour-physics calculations, Wilson coefficients and statistical inference
|
Case-insensitive registry of SymbolId entries with optional external keys. More...
#include <dynamic_registry.h>
Classes | |
| struct | Entry |
| Entry stored in the registry. More... | |
Public Member Functions | |
| bool | register_id (const SymbolId< Tag > &id, std::vector< std::string > aliases, std::optional< ExternalKey > ext, bool builtin) |
| Registers or updates an identifier in the registry. | |
| std::optional< SymbolId< Tag > > | find (std::string_view name) const |
| Finds an identifier by name (or alias), case-insensitively. | |
| std::optional< SymbolId< Tag > > | find_by_external (const ExternalKey &k) const |
| Finds an identifier by external key. | |
| std::optional< ExternalKey > | external_of (const SymbolId< Tag > &id) const |
| Returns the external key associated with a given identifier. | |
| bool | update_external (const SymbolId< Tag > &id, const ExternalKey &k) |
| Updates or sets the external key of a given identifier. | |
| std::vector< SymbolId< Tag > > | list_all () const |
| Lists all distinct identifiers stored in the registry. | |
Case-insensitive registry of SymbolId entries with optional external keys.
The primary template manages:
Typical usage:
Builtin entries can be protected against being overridden by later registrations.
| Tag | Tag used for the SymbolId type. |
| ExternalKey | Type of the external key (e.g. int, std::string). |
| Hash | Hash functor type used for ExternalKey. |
Definition at line 201 of file dynamic_registry.h.
| std::optional< ExternalKey > DynamicRegistry< Tag, ExternalKey, Hash >::external_of | ( | const SymbolId< Tag > & | id | ) | const |
Returns the external key associated with a given identifier.
| id | SymbolId to query. |
| std::optional< SymbolId< Tag > > DynamicRegistry< Tag, ExternalKey, Hash >::find | ( | std::string_view | name | ) | const |
Finds an identifier by name (or alias), case-insensitively.
The input name is normalized via normalize_key() and looked up in the internal map. If found, the corresponding SymbolId<Tag> is returned.
| name | Name or alias to search for. |
| std::optional< SymbolId< Tag > > DynamicRegistry< Tag, ExternalKey, Hash >::find_by_external | ( | const ExternalKey & | k | ) | const |
Finds an identifier by external key.
Looks up k in the external-key map and then resolves the associated canonical name to retrieve the SymbolId<Tag>.
| k | External key value. |
| std::vector< SymbolId< Tag > > DynamicRegistry< Tag, ExternalKey, Hash >::list_all | ( | ) | const |
Lists all distinct identifiers stored in the registry.
The registry may contain multiple entries for different aliases pointing to the same canonical id. This function returns each distinct canonical id exactly once.
| bool DynamicRegistry< Tag, ExternalKey, Hash >::register_id | ( | const SymbolId< Tag > & | id, |
| std::vector< std::string > | aliases, | ||
| std::optional< ExternalKey > | ext, | ||
| bool | builtin | ||
| ) |
Registers or updates an identifier in the registry.
The given id is inserted with the provided aliases and optional external key. The canonical map key is normalize_key(id.str()).
Behavior:
| id | Identifier to register. |
| aliases | List of aliases for lookup. |
| ext | Optional external key to associate. |
| builtin | Whether this is a builtin entry (protected). |
| bool DynamicRegistry< Tag, ExternalKey, Hash >::update_external | ( | const SymbolId< Tag > & | id, |
| const ExternalKey & | k | ||
| ) |
Updates or sets the external key of a given identifier.
If the identifier is found in the registry, its external key is set to k and the external-key index is updated accordingly.
| id | Identifier whose external key is to be set. |
| k | New external key value. |