Sen API
Sen Libraries
Loading...
Searching...
No Matches
sen::UnitRegistry Class Referencefinal

A registry of units. More...

#include <unit_registry.h>

Public Types

using UnitList = std::vector<Unit*>
using UnitStorage = std::vector<std::unique_ptr<Unit>>
using UnitRange = sen::util::IteratorRange<util::SmartPtrIteratorAdapter<UnitStorage::const_iterator>>

Public Member Functions

UnitRange getUnits () const noexcept
 The currently registered units. Does not include the builtin units.
UnitList getUnitsByCategory (UnitCategory category) const
 Returns all registered units that belong to a given category. It also searches in the built-in units.
std::optional< const Unit * > searchUnitByName (std::string_view name) const
 Tries to find a unit with a specific name (case sensitive) It also searches in the built-in units. Returns nullopt if the unit was not found, otherwise a valid pointer to the unit.
std::optional< const Unit * > searchUnitByAbbreviation (std::string_view abbrev) const
 Tries to find a unit with a specific abbreviation (case sensitive). It also searches in the built-in units. Returns nullopt if the unit was not found, otherwise a valid pointer to the unit.

Static Public Member Functions

static const UnitRegistry & get ()

Detailed Description

A registry of units.

Member Typedef Documentation

◆ UnitList

using sen::UnitRegistry::UnitList = std::vector<Unit*>

◆ UnitStorage

using sen::UnitRegistry::UnitStorage = std::vector<std::unique_ptr<Unit>>

◆ UnitRange

Member Function Documentation

◆ get()

const UnitRegistry & sen::UnitRegistry::get ( )
static

◆ getUnits()

UnitRange sen::UnitRegistry::getUnits ( ) const
nodiscardnoexcept

The currently registered units. Does not include the builtin units.

◆ getUnitsByCategory()

UnitList sen::UnitRegistry::getUnitsByCategory ( UnitCategory category) const
nodiscard

Returns all registered units that belong to a given category. It also searches in the built-in units.

◆ searchUnitByName()

std::optional< const Unit * > sen::UnitRegistry::searchUnitByName ( std::string_view name) const
nodiscard

Tries to find a unit with a specific name (case sensitive) It also searches in the built-in units. Returns nullopt if the unit was not found, otherwise a valid pointer to the unit.

◆ searchUnitByAbbreviation()

std::optional< const Unit * > sen::UnitRegistry::searchUnitByAbbreviation ( std::string_view abbrev) const
nodiscard

Tries to find a unit with a specific abbreviation (case sensitive). It also searches in the built-in units. Returns nullopt if the unit was not found, otherwise a valid pointer to the unit.


The documentation for this class was generated from the following file: