A class to represent units of measure. More...
#include <UnitOfMeasure.h>
Public Member Functions | |
const unsigned int | getBaseUnitId () const |
Returns the base unit id from which this unit derives of. More... | |
void | getConversionFactors (double &A, double &B, double &C, double &D) const |
Returns the conversion factors to convert the unit to its base unit. More... | |
double | getConversionValue () const |
Returns a multiplicative value to convert the unit to its base unit. More... | |
const std::string & | getDescription () const |
Returns the unit of measure description. More... | |
unsigned int | getId () const |
Returns the unit of measure identification. More... | |
const std::string & | getName () const |
Returns the unit of measure oficial name. More... | |
const std::string & | getSymbol () const |
Returns the unit of measure symbol. More... | |
MeasureType | getType () const |
Returns the unit of measure type. More... | |
std::string | getWKT () const |
Returns the WKT description of a unit of measure. More... | |
bool | isBaseUnit () const |
Returns true if this is a base unit; otherwise returns false. More... | |
void | setDescription (const std::string &description) |
Sets the unit of measure description. More... | |
UnitOfMeasure (unsigned int id, const std::string &name, const std::string &symbol, MeasureType type, const std::string &description="") | |
Creates a new base unit of measure. More... | |
UnitOfMeasure (unsigned int id, const std::string &name, const std::string &symbol, MeasureType type, unsigned int baseUnitId, double A, double B=0.0, double C=0.0, double D=1.0, const std::string &description="") | |
Creates a new derived unit of measure. More... | |
~UnitOfMeasure () | |
Destructor. More... | |
Private Attributes | |
double | m_a |
double | m_b |
unsigned int | m_baseUnitId |
Unique identification number of the base unit to which a conversion operation is provided. More... | |
double | m_c |
double | m_d |
std::string | m_description |
unit of measure description. More... | |
unsigned int | m_id |
Unique identification number for a unit of measure. More... | |
std::string | m_name |
unit of measure name according to SI. More... | |
std::string | m_symbol |
Unit symbol. More... | |
MeasureType | m_type |
Unit type of measure. More... | |
A class to represent units of measure.
The use of a unit of measure is meant to encompass the means by which a measured value is tied explicitly to its unit of measure.
Units of measure can be Base or Derived. Base units are well-defined units which by convention are regarded as dimensionally independent. There is only one Base Unit per type of measure.
Derived units are those formed by combining base units according to the algebraic relations linking the corresponding quantities.
Units have an unique numerical identification, an oficial name, a symbol, the type of measures that they refer to and an optional description. Derived Units also have the identification of its Base Unit and 4 factors to relate them, using the following formula:
where Y is the measure in the derived unit and X is measure in base unit.
Definition at line 74 of file UnitOfMeasure.h.
te::common::UnitOfMeasure::UnitOfMeasure | ( | unsigned int | id, |
const std::string & | name, | ||
const std::string & | symbol, | ||
MeasureType | type, | ||
const std::string & | description = "" |
||
) |
Creates a new base unit of measure.
id | Unique identification number. |
name | Unit official name. |
symbol | Unit symbol. |
type | Unit type of measure. |
description | Unit description (by default empty). |
te::common::UnitOfMeasure::UnitOfMeasure | ( | unsigned int | id, |
const std::string & | name, | ||
const std::string & | symbol, | ||
MeasureType | type, | ||
unsigned int | baseUnitId, | ||
double | A, | ||
double | B = 0.0 , |
||
double | C = 0.0 , |
||
double | D = 1.0 , |
||
const std::string & | description = "" |
||
) |
Creates a new derived unit of measure.
id | Unit unique identification number for a unit of measure. |
name | Unit official name. |
symbol | Unit symbol. |
type | Unit type of measure |
baseUnitId | Identification of the base unit from which this is derived of. |
A | A factor in the conversion formula. |
B | B factor in the conversion formula. |
C | C factor in the conversion formula. |
D | D factor in the conversion formula. |
description | Unit description (by default empty). |
te::common::UnitOfMeasure::~UnitOfMeasure | ( | ) |
Destructor.
const unsigned int te::common::UnitOfMeasure::getBaseUnitId | ( | ) | const |
Returns the base unit id from which this unit derives of.
void te::common::UnitOfMeasure::getConversionFactors | ( | double & | A, |
double & | B, | ||
double & | C, | ||
double & | D | ||
) | const |
Returns the conversion factors to convert the unit to its base unit.
A | To return the A factor in the conversion formula (output). |
B | To return the B factor in the conversion formula (output). |
C | To return the C factor in the conversion formula (output). |
D | To return the D factor in the conversion formula (output). |
double te::common::UnitOfMeasure::getConversionValue | ( | ) | const |
Returns a multiplicative value to convert the unit to its base unit.
The retuned value is calculated as (A + B)/(C + D) rounded to a double.
const std::string& te::common::UnitOfMeasure::getDescription | ( | ) | const |
Returns the unit of measure description.
unsigned int te::common::UnitOfMeasure::getId | ( | ) | const |
Returns the unit of measure identification.
const std::string& te::common::UnitOfMeasure::getName | ( | ) | const |
Returns the unit of measure oficial name.
const std::string& te::common::UnitOfMeasure::getSymbol | ( | ) | const |
Returns the unit of measure symbol.
MeasureType te::common::UnitOfMeasure::getType | ( | ) | const |
Returns the unit of measure type.
std::string te::common::UnitOfMeasure::getWKT | ( | ) | const |
Returns the WKT description of a unit of measure.
bool te::common::UnitOfMeasure::isBaseUnit | ( | ) | const |
Returns true if this is a base unit; otherwise returns false.
void te::common::UnitOfMeasure::setDescription | ( | const std::string & | description | ) |
Sets the unit of measure description.
description | The unit of measure description. |
|
private |
Definition at line 206 of file UnitOfMeasure.h.
|
private |
Definition at line 207 of file UnitOfMeasure.h.
|
private |
Unique identification number of the base unit to which a conversion operation is provided.
Definition at line 204 of file UnitOfMeasure.h.
|
private |
Definition at line 208 of file UnitOfMeasure.h.
|
private |
Definition at line 209 of file UnitOfMeasure.h.
|
private |
unit of measure description.
Definition at line 202 of file UnitOfMeasure.h.
|
private |
Unique identification number for a unit of measure.
Definition at line 198 of file UnitOfMeasure.h.
|
private |
unit of measure name according to SI.
Definition at line 199 of file UnitOfMeasure.h.
|
private |
Unit symbol.
Definition at line 200 of file UnitOfMeasure.h.
|
private |
Unit type of measure.
Definition at line 201 of file UnitOfMeasure.h.