![]() |
NDEVR
API Documentation
|
Manages a collection of units across multiple data categories with INI persistence. More...
Public Member Functions | |
| UnitManager () | |
| Default constructor. | |
| UnitManager (const UnitManager &manager) | |
| Copy constructor. | |
| ~UnitManager () | |
| Destructor. | |
| void | addFormatOption (UnitCategory unit_type, const ConstPointer< UnitOption > &format_option) |
| Adds a format option to the specified unit category. | |
| void | addSpecialUnit (const DynamicPointer< CustomUnit > &custom_unit) |
| Adds a custom unit to this manager. | |
| const Buffer< ConstPointer< UnitOption > > & | angleUnitOptions () const |
| Returns the available angle unit options. | |
| const Buffer< ConstPointer< UnitOption > > & | areaUnitOptions () const |
| Returns the available area unit options. | |
| bool | canBeImperial (const ConstPointer< Unit > &unit) const |
| Checks whether the given unit can be classified as imperial. | |
| bool | canBeMetric (const ConstPointer< Unit > &unit) const |
| Checks whether the given unit can be classified as metric. | |
| void | clearUnitOptions (UnitCategory type) |
| Clears all unit options for the given category. | |
| const Buffer< ConstPointer< UnitOption > > & | coordinateSpaceFormatOptions () const |
| Returns the available coordinate space format options. | |
| ConstPointer< Unit > | determineUnit (const Buffer< String > &unit_parts, UnitCategory type) const |
| Determines a unit from a set of string parts and a category. | |
| const Buffer< ConstPointer< UnitOption > > & | distanceUnitOptions () const |
| Returns the available distance unit options. | |
| void | finishReadingINI (INIFactory &factory) override |
| Finalizes unit state after reading INI data. | |
| void | getINI (INIFactory &factory) override |
| Serializes or deserializes unit settings to/from an INI factory. | |
| bool | hasSpecialUnit (const StringView &name) const |
| Checks whether a special unit with the given name exists. | |
| const Buffer< ConstPointer< UnitOption > > & | latLonUnitOptions () const |
| Returns the available latitude/longitude unit options. | |
| UnitManager & | operator= (const UnitManager &manager) |
| Copy assignment operator. | |
| ConstPointer< Unit > | orientationOffsetUnit () const |
| Returns the orientation offset unit used for orientation space. | |
| ConstPointer< Unit > | parseUnit (const StringView &name, UnitCategory type=UnitCategory::e_undefined_unit) const |
| Parses a unit from a string name, optionally constrained to a category. | |
| void | prepareForINI (INIFactory &factory) override |
| Prepares internal state before INI serialization. | |
| void | removeFormatOption (UnitCategory unit_type, const ConstPointer< UnitOption > &format_option) |
| Removes a format option from the specified unit category. | |
| void | setToDefaultImperial (bool preserve_spacial) |
| Sets all units to default imperial values. | |
| void | setToDefaultMetric (bool preserve_spacial) |
| Sets all units to default metric values. | |
| void | setUnit (UnitCategory type, const ConstPointer< Unit > &unit) |
| Sets the unit for the given category. | |
| void | setUnitOptions (UnitCategory type, const Buffer< ConstPointer< Unit > > &options) |
| Sets the unit options for the given category from Unit objects. | |
| void | setUnitOptions (UnitCategory type, const Buffer< ConstPointer< UnitOption > > &options) |
| Sets the unit options for the given category from UnitOption objects. | |
| void | setUnitOptionsToDefault (UnitCategory type) |
| Resets unit options for the given category to their defaults. | |
| void | setupDefaultAngleUnitOptions () |
| Populates the angle unit options with default values. | |
| void | setupDefaultAreaOptions () |
| Populates the area unit options with default values. | |
| void | setupDefaultCoordinateSpaceOptions () |
| Populates the coordinate space format options with default values. | |
| void | setupDefaultDistanceOptions () |
| Populates the distance unit options with default values. | |
| void | setupDefaultLatLonOptions () |
| Populates the latitude/longitude unit options with default values. | |
| void | setupDefaultVolumeOptions () |
| Populates the volume unit options with default values. | |
| void | setupDefaultWeightOptions () |
| Populates the weight unit options with default values. | |
| ConstPointer< Unit > | specialUnit (const StringView &name) |
| Retrieves a special unit by name. | |
| Resource< ConstPointer< Unit > > & | specialUnitResource (const StringView &name) |
| Retrieves the resource for a special unit by name. | |
| const Buffer< DynamicPointer< CustomUnit > > & | specialUnits () const |
| Returns all registered special (custom) units. | |
| void | tieToManager (const UnitManager &manager) |
| Ties this manager's units to mirror changes from another UnitManager. | |
| ConstPointer< Unit > | unit (const StringView &name) const |
| Looks up a unit by its string name. | |
| ConstPointer< Unit > | unit (UnitCategory type) const |
| Returns the currently selected unit for the given category. | |
| Buffer< ConstPointer< UnitOption > > | unitOptions (UnitCategory units) const |
| Returns the unit options for the given category. | |
| Resource< ConstPointer< Unit > > & | unitResource (UnitCategory type) |
| Returns a mutable reference to the unit resource for the given category. | |
| void | updateCoordinateBase (const ConstPointer< Unit > &base) |
| Updates the coordinate base unit and adjusts related coordinate options. | |
| const Buffer< ConstPointer< UnitOption > > & | volumeUnitOptions () const |
| Returns the available volume unit options. | |
| const Buffer< ConstPointer< UnitOption > > & | weightUnitOptions () const |
| Returns the available weight unit options. | |
| Public Member Functions inherited from INIInterface | |
| INIInterface () | |
| Constructs an INIInterface with no default INI file. | |
| INIInterface (const File &default_ini) | |
| Constructs an INIInterface with the specified default INI file. | |
| virtual | ~INIInterface () |
| Virtual destructor for safe polymorphic cleanup. | |
| virtual bool | readINIOptions () |
| Reads INI options from the default INI file. | |
| virtual bool | readINIOptions (File &ini_file) |
| Reads INI options from the specified INI file. | |
| virtual bool | saveINIOptions (bool multithead=false) |
| Saves INI options to the default INI file. | |
| virtual bool | saveINIOptions (File &ini_file, bool multithead=false) |
| Saves INI options to the specified INI file. | |
| void | setDefaultINIFile (const File &file) |
| Sets the default INI file path used for reading and writing options. | |
| virtual void | writeToLog (const StringView &title, LogPtr log, uint01 log_level=2U) |
| Writes the current INI options to the specified log with a title. | |
| virtual void | writeToLog (LogPtr log, uint01 log_level=2U) |
| Writes the current INI options to the specified log. | |
Static Public Member Functions | |
| static ConstPointer< UnitOption > | ActiveOption (const Buffer< ConstPointer< UnitOption > > &options, const ConstPointer< Unit > &unit) |
| Finds the active option matching the given unit from a buffer of options. | |
| static UnitManager & | DefaultManager () |
| Returns the singleton default UnitManager instance. | |
Public Attributes | |
| Resource< ConstPointer< Unit > > | angle_unit |
| Unit for describing non-dimensional angles. | |
| Resource< ConstPointer< Unit > > | coordinate_space_unit |
| Unit for describing dimensional distances. | |
| Resource< ConstPointer< Unit > > | distance_unit |
| Unit for describing non-dimensional distances. | |
| Resource< ConstPointer< Unit > > | lat_lon_unit |
| Unit for describing position on the globe. | |
| Resource< ConstPointer< Unit > > | orientation_space_unit |
| Unit for describing dimensional angles. | |
| Resource< ConstPointer< Unit > > | surface_area_unit |
| Unit for describing surface areas. | |
| Resource< ConstPointer< Unit > > | temperature_unit |
| Unit for describing temperature. | |
| Resource< ConstPointer< Unit > > | time_unit |
| Unit for describing time. | |
| Resource< ConstPointer< Unit > > | volume_unit |
| Unit for describing volumes. | |
| Resource< ConstPointer< Unit > > | weight_unit |
| Unit for describing weights. | |
Static Public Attributes | |
| static Resource< ConstPointer< Unit > > | default_angle_unit |
| Default program-wide unit for describing non-dimensional angles. | |
| static Resource< ConstPointer< Unit > > | default_orientation_space_unit |
| Default program-wide unit for describing dimensional angles. | |
Protected Attributes | |
| Buffer< ConstPointer< UnitOption > > | m_angle_unit_options |
| All unit options for describing non-dimensional angles. | |
| Buffer< ConstPointer< UnitOption > > | m_area_unit_options |
| All unit options for describing surface areas. | |
| Buffer< ConstPointer< UnitOption > > | m_coordinate_format_options |
| All unit options for describing dimensional distances. | |
| Buffer< ConstPointer< UnitOption > > | m_distance_unit_options |
| All unit options for describing non-dimensional distances. | |
| Buffer< ConstPointer< UnitOption > > | m_lat_lon_unit_options |
| All unit options for describing position on the globe. | |
| Dictionary< String, ConstPointer< UnitOption > > | m_registered_units |
| Lookup of all registered unit options by name. | |
| Dictionary< String, DynamicPointer< CustomUnit > > | m_special_unit_lookup |
| Lookup of special units by name. | |
| Buffer< DynamicPointer< CustomUnit > > | m_special_units |
| All registered special (custom) units. | |
| ResourceListener * | m_tie_to_listener = nullptr |
| Listener used when this manager is tied to another manager. | |
| Buffer< ConstPointer< UnitOption > > | m_volume_unit_options |
| All unit options for describing volumes. | |
| Buffer< ConstPointer< UnitOption > > | m_weight_unit_options |
| All unit options for describing weights. | |
| Protected Attributes inherited from INIInterface | |
| File | m_default_ini |
| The default file path used for reading and writing INI options. | |
Manages a collection of units across multiple data categories with INI persistence.
Definition at line 357 of file UnitManager.h.
| UnitManager::UnitManager | ( | ) |
Default constructor.
Initializes unit resources to default values.
Referenced by UnitManager(), DefaultManager(), operator=(), and tieToManager().
| UnitManager::UnitManager | ( | const UnitManager & | manager | ) |
Copy constructor.
Copies unit state from another UnitManager.
| [in] | manager | The UnitManager to copy from. |
References UnitManager().
| UnitManager::~UnitManager | ( | ) |
Destructor.
Cleans up any tied resource listeners.
|
staticnodiscard |
Finds the active option matching the given unit from a buffer of options.
| [in] | options | The buffer of unit options to search. |
| [in] | unit | The unit to match against. |
References unit().
| void UnitManager::addFormatOption | ( | UnitCategory | unit_type, |
| const ConstPointer< UnitOption > & | format_option ) |
Adds a format option to the specified unit category.
| [in] | unit_type | The unit category to add the option to. |
| [in] | format_option | The unit option to add. |
| void UnitManager::addSpecialUnit | ( | const DynamicPointer< CustomUnit > & | custom_unit | ) |
Adds a custom unit to this manager.
| [in] | custom_unit | The custom unit to register. |
|
inlinenodiscard |
Returns the available angle unit options.
Definition at line 469 of file UnitManager.h.
References m_angle_unit_options.
|
inlinenodiscard |
Returns the available area unit options.
Definition at line 484 of file UnitManager.h.
References m_area_unit_options.
| bool UnitManager::canBeImperial | ( | const ConstPointer< Unit > & | unit | ) | const |
| bool UnitManager::canBeMetric | ( | const ConstPointer< Unit > & | unit | ) | const |
| void UnitManager::clearUnitOptions | ( | UnitCategory | type | ) |
Clears all unit options for the given category.
| [in] | type | The unit category whose options should be cleared. |
|
inlinenodiscard |
Returns the available coordinate space format options.
Definition at line 499 of file UnitManager.h.
References m_coordinate_format_options.
|
staticnodiscard |
Returns the singleton default UnitManager instance.
References UnitManager().
|
nodiscard |
Determines a unit from a set of string parts and a category.
| [in] | unit_parts | The buffer of string components describing the unit. |
| [in] | type | The unit category to resolve against. |
|
inlinenodiscard |
Returns the available distance unit options.
Definition at line 479 of file UnitManager.h.
References m_distance_unit_options.
|
overridevirtual |
Finalizes unit state after reading INI data.
| [in] | factory | The INI factory that was read from. |
Reimplemented from INIInterface.
|
overridevirtual |
Serializes or deserializes unit settings to/from an INI factory.
| [in] | factory | The INI factory to read from or write to. |
Implements INIInterface.
| bool UnitManager::hasSpecialUnit | ( | const StringView & | name | ) | const |
Checks whether a special unit with the given name exists.
| [in] | name | The string identifier to look up. |
|
inlinenodiscard |
Returns the available latitude/longitude unit options.
Definition at line 474 of file UnitManager.h.
References m_lat_lon_unit_options.
| UnitManager & UnitManager::operator= | ( | const UnitManager & | manager | ) |
Copy assignment operator.
| [in] | manager | The UnitManager to copy from. |
References UnitManager().
|
nodiscard |
Returns the orientation offset unit used for orientation space.
|
nodiscard |
Parses a unit from a string name, optionally constrained to a category.
| [in] | name | The string name to parse. |
| [in] | type | The unit category hint for disambiguation. |
References e_undefined_unit.
|
overridevirtual |
Prepares internal state before INI serialization.
| [in] | factory | The INI factory being prepared for. |
Reimplemented from INIInterface.
| void UnitManager::removeFormatOption | ( | UnitCategory | unit_type, |
| const ConstPointer< UnitOption > & | format_option ) |
Removes a format option from the specified unit category.
| [in] | unit_type | The unit category to remove the option from. |
| [in] | format_option | The unit option to remove. |
| void UnitManager::setToDefaultImperial | ( | bool | preserve_spacial | ) |
Sets all units to default imperial values.
| [in] | preserve_spacial | Whether to preserve the current spatial/coordinate unit. |
| void UnitManager::setToDefaultMetric | ( | bool | preserve_spacial | ) |
Sets all units to default metric values.
| [in] | preserve_spacial | Whether to preserve the current spatial/coordinate unit. |
| void UnitManager::setUnit | ( | UnitCategory | type, |
| const ConstPointer< Unit > & | unit ) |
| void UnitManager::setUnitOptions | ( | UnitCategory | type, |
| const Buffer< ConstPointer< Unit > > & | options ) |
Sets the unit options for the given category from Unit objects.
| [in] | type | The unit category to configure. |
| [in] | options | The buffer of units to create options from. |
| void UnitManager::setUnitOptions | ( | UnitCategory | type, |
| const Buffer< ConstPointer< UnitOption > > & | options ) |
Sets the unit options for the given category from UnitOption objects.
| [in] | type | The unit category to configure. |
| [in] | options | The buffer of unit options to assign. |
| void UnitManager::setUnitOptionsToDefault | ( | UnitCategory | type | ) |
Resets unit options for the given category to their defaults.
| [in] | type | The unit category to reset. |
| ConstPointer< Unit > UnitManager::specialUnit | ( | const StringView & | name | ) |
Retrieves a special unit by name.
| [in] | name | The string identifier of the special unit. |
| Resource< ConstPointer< Unit > > & UnitManager::specialUnitResource | ( | const StringView & | name | ) |
Retrieves the resource for a special unit by name.
| [in] | name | The string identifier of the special unit. |
|
inlinenodiscard |
Returns all registered special (custom) units.
Definition at line 504 of file UnitManager.h.
References m_special_units.
| void UnitManager::tieToManager | ( | const UnitManager & | manager | ) |
Ties this manager's units to mirror changes from another UnitManager.
| [in] | manager | The UnitManager to mirror. |
References UnitManager().
|
nodiscard |
Looks up a unit by its string name.
| [in] | name | The name of the unit to find. |
|
nodiscard |
Returns the currently selected unit for the given category.
| [in] | type | The unit category to query. |
Referenced by ActiveOption(), canBeImperial(), canBeMetric(), and setUnit().
|
nodiscard |
Returns the unit options for the given category.
| [in] | units | The unit category to query. |
|
nodiscard |
Returns a mutable reference to the unit resource for the given category.
| [in] | type | The unit category to query. |
| void UnitManager::updateCoordinateBase | ( | const ConstPointer< Unit > & | base | ) |
Updates the coordinate base unit and adjusts related coordinate options.
| [in] | base | The new base unit for coordinates. |
|
inlinenodiscard |
Returns the available volume unit options.
Definition at line 489 of file UnitManager.h.
References m_volume_unit_options.
|
inlinenodiscard |
Returns the available weight unit options.
Definition at line 494 of file UnitManager.h.
References m_weight_unit_options.