1#ifndef PHYTH_UNIT_REGISTRY_HPP
2#define PHYTH_UNIT_REGISTRY_HPP
5#include <unordered_map>
61 template<
typename UnitT>
62 void RegisterUnit(
const std::string &name,
const std::string &symbol) {
64 registry_[std::type_index(
typeid(
UnitT))] = {.name = name, .symbol = symbol};
75 template<
typename UnitT>
78 return it->second.name;
91 template<
typename UnitT>
94 return it->second.symbol;
102 std::unordered_map<std::type_index, UnitInfo>
registry_;
121 template<
typename UnitT>
Singleton registry for unit names and symbols.
std::unordered_map< std::type_index, UnitInfo > registry_
std::string GetName() const
Get the full name of a unit type.
static UnitRegistry & GetInstance()
Get the singleton instance.
std::string GetSymbol() const
Get the symbol of a unit type.
void RegisterUnit(const std::string &name, const std::string &symbol)
Register a unit type with its display information.
Display information for a unit type.
Static registrar for unit types.
UnitRegistrar(const std::string &name, const std::string &symbol)
Register the unit with the given name and symbol.