|
dimval 0.2.0
Modern C++23 header-only library of dimensional values (units, measures, ranges)
|
Registry of unit descriptors. More...
#include <registry.hpp>
Public Member Functions | |
| void | register_unit (const UnitDescriptor &d) |
| Register a descriptor. Existing entries with the same id are replaced. | |
| template<UnitLike Unit> | |
| bool | register_unit () |
| Register a unit by tag — pulls the descriptor through Unit::descriptor(). | |
| const UnitDescriptor * | find (const std::string_view id_or_symbol) const |
| Look up by id, then by symbol. Returns nullptr if not found. | |
| std::vector< UnitDescriptor > | list () const |
| Snapshot all registered descriptors. | |
| std::vector< UnitDescriptor > | by_kind (const std::string_view kind) const |
Snapshot all descriptors whose kind matches. | |
| bool | compatible (const std::string_view a, const std::string_view b) const |
| True iff both ids resolve and share the same kind. | |
| std::size_t | size () const |
| Number of registered descriptors. | |
Static Public Member Functions | |
| static UnitRegistry & | global () |
| Process-wide singleton. | |
Registry of unit descriptors.
Lookups are guarded by a shared lock, registrations by a unique lock. Use UnitRegistry::global() for the process-wide instance; built-ins live there.
|
inline |
Register a unit by tag — pulls the descriptor through Unit::descriptor().
Returns false if the id was already present (no replacement); true if this call inserted a fresh entry.