4#include <NDEVR/SoftwareService.h>
5#include <NDEVR/Resource.h>
6#include <NDEVR/Pointer.h>
7#include <NDEVR/TranslatedString.h>
8#include <NDEVR/Dictionary.h>
9#include <NDEVR/INIInterface.h>
643 String orientation_space_name;
644 String coordinate_space_name;
645 String distance_space_name;
TranslatedString m_title
The translated display title.
virtual void finishReadingINI(UnitManager &manager) override
Resolves the unit from the INI-stored name after reading INI data.
virtual ConstPointer< Unit > defaultUnit(UnitManager &) const override
Returns the default unit for this custom unit.
virtual void setupINI(INIFactory &ini) override
Registers this custom unit's settings with the given INI factory.
virtual void prepareForINI(const UnitManager &manager) override
Prepares internal state for INI serialization by capturing the current unit name.
virtual Resource< ConstPointer< Unit > > & unitResource(UnitManager &manager) override
Returns a mutable reference to the resource holding the current unit.
BasicCustomUnit(const StringView &id, const TranslatedString &title, UnitCategory type)
Constructs a BasicCustomUnit with the given identifier, title, and unit category.
String m_ini_unit_name
The unit name stored in INI for serialization.
Buffer< ConstPointer< UnitOption > > options(UnitManager &manager) const override
Returns the available unit options for this custom unit.
Resource< ConstPointer< Unit > > m_unit
The resource holding the current unit selection.
virtual TranslatedString title() const override
Returns the display title for this custom unit.
virtual Buffer< ConstPointer< UnitOption > > & editSubOptions()
Returns a mutable reference to the sub-options for editing.
BasicUnitOption(const ConstPointer< Unit > &unit, const TranslatedString &custom_title=TranslatedString())
Constructs a BasicUnitOption from a unit and an optional custom title.
virtual TranslatedString title() const final override
Returns the display title, using the custom title if set.
TranslatedString custom_title
An optional custom display title.
Buffer< ConstPointer< UnitOption > > m_sub_options
Child sub-options within this unit option.
virtual ConstPointer< Unit > unit() const final override
Returns the base unit for this option.
virtual Buffer< ConstPointer< UnitOption > > subOptions() const final override
Returns the sub-options for this unit option.
virtual bool hasMemberUnit(const ConstPointer< Unit > &unit) const final override
Checks whether the given unit matches this option or any sub-option.
ConstPointer< Unit > base_unit
The underlying unit this option wraps.
The equivelent of std::vector but with a bit more control.
Provides a constant, unmodifiable pointer that has shared ownership of a dynamically allocated object...
CoordinateUnitOption(const StringView &id, const TranslatedString &name)
Constructs a CoordinateUnitOption with the given identifier and name.
virtual ConstPointer< Unit > unit() const final override
Returns the coordinate unit.
virtual bool hasMemberUnit(const ConstPointer< Unit > &unit) const final override
Checks whether the given unit is a member of this coordinate option.
virtual TranslatedString title() const
Returns the translated display title.
virtual ConstPointer< Unit > currentUnit()
Returns the current unit without a manager context.
virtual void prepareForINI(const UnitManager &)
Prepares internal state for INI serialization.
String id
The unique string identifier of this custom unit.
virtual void finishReadingINI(UnitManager &)
Called after INI data has been read to finalize state.
virtual ~CustomUnit()
Virtual destructor.
CustomUnit(const StringView &id, const TranslatedString &name, UnitCategory unit_type)
Constructs a CustomUnit with the given identifier, name, and unit category.
UnitCategory unit_type
The category of unit this custom unit belongs to.
TranslatedString name
The translated display name of this custom unit.
virtual Buffer< ConstPointer< UnitOption > > options(UnitManager &manager) const =0
Returns the available unit options for this custom unit.
virtual void setupINI(INIFactory &)=0
Registers this custom unit's settings with the given INI factory.
virtual Resource< ConstPointer< Unit > > & unitResource(UnitManager &manager)=0
Returns a mutable reference to the resource holding the current unit.
virtual void resetToDefault(UnitManager &)
Resets this custom unit to its default value.
virtual ConstPointer< Unit > currentUnit(UnitManager &manager)
Returns the current unit using the given manager context.
virtual ConstPointer< Unit > defaultUnit(UnitManager &) const =0
Returns the default unit for this custom unit.
A hash-based key-value store, useful for quick associative lookups.
Provides a modifiable pointer that has shared ownership of a dynamically allocated object.
Contains methods for easily reading and writing to an INI file including efficient casting,...
INIInterface()
Constructs an INIInterface with no default INI file.
virtual Buffer< ConstPointer< UnitOption > > options(UnitManager &manager) const override
Returns the available unit options from the referenced source.
virtual void prepareForINI(const UnitManager &) override
No-op for reference units since INI state is managed by the referenced source.
virtual void resetToDefault(UnitManager &) override
Resets this reference unit to its default value.
ReferenceCustomUnit(const StringView &id, const TranslatedString &name, UnitCategory unit_type)
Constructs a ReferenceCustomUnit with the given identifier, name, and unit category.
virtual void finishReadingINI(UnitManager &) override
No-op for reference units since INI state is managed by the referenced source.
virtual ConstPointer< Unit > defaultUnit(UnitManager &) const override
Returns the default unit from the referenced source.
virtual void setupINI(INIFactory &) override
No-op for reference units since INI state is managed by the referenced source.
virtual ConstPointer< Unit > currentUnit(UnitManager &manager) override
Returns the current unit from the referenced source.
virtual Resource< ConstPointer< Unit > > & unitResource(UnitManager &manager) override
Returns the unit resource from the referenced manager source.
virtual ~ReferenceCustomUnit()
Virtual destructor.
A class that can subscribe to any number of Resources which will get updates when the Resource(s) hav...
A core part of the engine, stores variables that can be listened to with ResourceListener which will ...
Software Service Managers take a Software service to modify the behavior of the software.
The core String View class for the NDEVR API.
The core String class for the NDEVR API.
Any text displayed to the user should be defined as a TranslatedString which allows the program to lo...
Manages a collection of units across multiple data categories with INI persistence.
void prepareForINI(INIFactory &factory) override
Prepares internal state before INI serialization.
void tieToManager(const UnitManager &manager)
Ties this manager's units to mirror changes from another UnitManager.
Resource< ConstPointer< Unit > > distance_unit
Unit for describing non-dimensional distances.
Resource< ConstPointer< Unit > > surface_area_unit
Unit for describing surface areas.
ConstPointer< Unit > unit(const StringView &name) const
Looks up a unit by its string name.
Buffer< ConstPointer< UnitOption > > m_coordinate_format_options
All unit options for describing dimensional distances.
bool canBeImperial(const ConstPointer< Unit > &unit) const
Checks whether the given unit can be classified as imperial.
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.
ConstPointer< Unit > specialUnit(const StringView &name)
Retrieves a special unit by name.
void addSpecialUnit(const DynamicPointer< CustomUnit > &custom_unit)
Adds a custom unit to this manager.
Buffer< ConstPointer< UnitOption > > m_lat_lon_unit_options
All unit options for describing position on the globe.
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 > > & latLonUnitOptions() const
Returns the available latitude/longitude unit options.
Buffer< ConstPointer< UnitOption > > m_area_unit_options
All unit options for describing surface areas.
const Buffer< ConstPointer< UnitOption > > & weightUnitOptions() const
Returns the available weight unit options.
void getINI(INIFactory &factory) override
Serializes or deserializes unit settings to/from an INI factory.
void setupDefaultLatLonOptions()
Populates the latitude/longitude unit options with default values.
Resource< ConstPointer< Unit > > volume_unit
Unit for describing volumes.
static UnitManager & DefaultManager()
Returns the singleton default UnitManager instance.
UnitManager(const UnitManager &manager)
Copy constructor.
const Buffer< DynamicPointer< CustomUnit > > & specialUnits() const
Returns all registered special (custom) units.
void setupDefaultVolumeOptions()
Populates the volume unit options with default values.
~UnitManager()
Destructor.
Resource< ConstPointer< Unit > > coordinate_space_unit
Unit for describing dimensional distances.
UnitManager & operator=(const UnitManager &manager)
Copy assignment operator.
ConstPointer< Unit > unit(UnitCategory type) const
Returns the currently selected unit for the given category.
Resource< ConstPointer< Unit > > & specialUnitResource(const StringView &name)
Retrieves the resource for a special unit by name.
void setupDefaultWeightOptions()
Populates the weight unit options with default values.
void clearUnitOptions(UnitCategory type)
Clears all unit options for the given category.
Resource< ConstPointer< Unit > > & unitResource(UnitCategory type)
Returns a mutable reference to the unit resource for the given category.
Buffer< ConstPointer< UnitOption > > m_distance_unit_options
All unit options for describing non-dimensional distances.
Buffer< ConstPointer< UnitOption > > m_weight_unit_options
All unit options for describing weights.
Resource< ConstPointer< Unit > > orientation_space_unit
Unit for describing dimensional angles.
Buffer< DynamicPointer< CustomUnit > > m_special_units
All registered special (custom) units.
void setToDefaultMetric(bool preserve_spacial)
Sets all units to default metric values.
void addFormatOption(UnitCategory unit_type, const ConstPointer< UnitOption > &format_option)
Adds a format option to the specified unit category.
ResourceListener * m_tie_to_listener
Listener used when this manager is tied to another manager.
static Resource< ConstPointer< Unit > > default_angle_unit
Default program-wide unit for describing non-dimensional angles.
void setUnitOptions(UnitCategory type, const Buffer< ConstPointer< UnitOption > > &options)
Sets the unit options for the given category from UnitOption objects.
void updateCoordinateBase(const ConstPointer< Unit > &base)
Updates the coordinate base unit and adjusts related coordinate options.
Buffer< ConstPointer< UnitOption > > m_volume_unit_options
All unit options for describing volumes.
void setUnitOptionsToDefault(UnitCategory type)
Resets unit options for the given category to their defaults.
UnitManager()
Default constructor.
Buffer< ConstPointer< UnitOption > > m_angle_unit_options
All unit options for describing non-dimensional angles.
const Buffer< ConstPointer< UnitOption > > & angleUnitOptions() const
Returns the available angle unit options.
const Buffer< ConstPointer< UnitOption > > & coordinateSpaceFormatOptions() const
Returns the available coordinate space format options.
void setToDefaultImperial(bool preserve_spacial)
Sets all units to default imperial values.
Buffer< ConstPointer< UnitOption > > unitOptions(UnitCategory units) const
Returns the unit options for the given category.
Dictionary< String, ConstPointer< UnitOption > > m_registered_units
Lookup of all registered unit options by name.
bool canBeMetric(const ConstPointer< Unit > &unit) const
Checks whether the given unit can be classified as metric.
Resource< ConstPointer< Unit > > lat_lon_unit
Unit for describing position on the globe.
void setUnit(UnitCategory type, const ConstPointer< Unit > &unit)
Sets the unit for the given category.
Resource< ConstPointer< Unit > > time_unit
Unit for describing time.
void setupDefaultAngleUnitOptions()
Populates the angle unit options with default values.
const Buffer< ConstPointer< UnitOption > > & distanceUnitOptions() const
Returns the available distance unit options.
void removeFormatOption(UnitCategory unit_type, const ConstPointer< UnitOption > &format_option)
Removes a format option from the specified unit category.
const Buffer< ConstPointer< UnitOption > > & volumeUnitOptions() const
Returns the available volume unit options.
Resource< ConstPointer< Unit > > angle_unit
Unit for describing non-dimensional angles.
void setupDefaultDistanceOptions()
Populates the distance unit options with default values.
void setupDefaultAreaOptions()
Populates the area unit options with default values.
void setUnitOptions(UnitCategory type, const Buffer< ConstPointer< Unit > > &options)
Sets the unit options for the given category from Unit objects.
const Buffer< ConstPointer< UnitOption > > & areaUnitOptions() const
Returns the available area unit options.
Resource< ConstPointer< Unit > > temperature_unit
Unit for describing temperature.
ConstPointer< Unit > orientationOffsetUnit() const
Returns the orientation offset unit used for orientation space.
bool hasSpecialUnit(const StringView &name) const
Checks whether a special unit with the given name exists.
static Resource< ConstPointer< Unit > > default_orientation_space_unit
Default program-wide unit for describing dimensional angles.
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 finishReadingINI(INIFactory &factory) override
Finalizes unit state after reading INI data.
Resource< ConstPointer< Unit > > weight_unit
Unit for describing weights.
Dictionary< String, DynamicPointer< CustomUnit > > m_special_unit_lookup
Lookup of special units by name.
void setupDefaultCoordinateSpaceOptions()
Populates the coordinate space format options with default values.
String id
The unique string identifier of this unit option.
UnitOption(const StringView &id, const TranslatedString &name)
Constructs a UnitOption with the given identifier and display name.
virtual ConstPointer< Unit > unit() const =0
Returns the unit associated with this option.
virtual bool hasMemberUnit(const ConstPointer< Unit > &unit) const =0
Checks whether the given unit is a member of this option.
TranslatedString name
The translated display name of this unit option.
virtual Buffer< ConstPointer< UnitOption > > subOptions() const
Returns the sub-options contained within this unit option.
virtual TranslatedString title() const
Returns the translated display title for this unit option.
virtual ConstPointer< Unit > unit(const ConstPointer< Unit > &) const
Returns a unit resolved relative to the given unit context.
virtual ~UnitOption()
Virtual destructor.
The primary namespace for the NDEVR SDK.
UnitCategory
A category of unit describing what it relates to.
@ e_undefined_unit
No specific unit category assigned.
Defines a unit of measurement for converting and displaying data values.