MaterialX 1.39.1
Loading...
Searching...
No Matches
UnitConverterRegistry Class Reference

A registry for unit converters. More...

#include <Unit.h>

Public Member Functions

bool addUnitConverter (UnitTypeDefPtr def, UnitConverterPtr converter)
 Add a unit converter for a given UnitDef. More...
 
bool removeUnitConverter (UnitTypeDefPtr def)
 Remove a unit converter for a given UnitDef. More...
 
UnitConverterPtr getUnitConverter (UnitTypeDefPtr def)
 Get a unit converter for a given UnitDef Returns any empty pointer if a converter does not exist for the given UnitDef.
 
void clearUnitConverters ()
 Clear all unit converters from the registry.
 
int getUnitAsInteger (const string &unitName) const
 Given a unit name return a value that it can map to as an integer Returns -1 value if not found.
 
void write (DocumentPtr doc) const
 Create unit definitions in a document based on registered converters.
 
bool convertToUnit (DocumentPtr doc, const string &unitType, const string &targetUnit)
 Convert input values which have a source unit to a given target unit. More...
 

Static Public Member Functions

static UnitConverterRegistryPtr create ()
 Creator.
 

Detailed Description

A registry for unit converters.

Member Function Documentation

◆ addUnitConverter()

bool addUnitConverter ( UnitTypeDefPtr  def,
UnitConverterPtr  converter 
)

Add a unit converter for a given UnitDef.

Returns false if a converter has already been registered for the given UnitDef

◆ convertToUnit()

bool convertToUnit ( DocumentPtr  doc,
const string &  unitType,
const string &  targetUnit 
)

Convert input values which have a source unit to a given target unit.

Returns if any unit conversion occured.

◆ removeUnitConverter()

bool removeUnitConverter ( UnitTypeDefPtr  def)

Remove a unit converter for a given UnitDef.

Returns false if a converter does not exist for the given UnitDef


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