DUDS
Distributed Update of Data from Something
duds::data::Unit Class Reference

Represents an SI unit, either base or derived. More...

#include <Unit.hpp>

Public Member Functions

 Unit ()=default
 Construct the same as a std::int32_t; expect the value to be uninitalized. More...
 
 Unit (const Unit &)=default
 Copy construct the same as a std::int32_t. More...
 
constexpr Unit (std::int32_t U)
 Make a new Unit set to a specific unit value; intended for making common unit constants with DUDS_UNIT_VALUE and initializing to zero for no unit or abstract unit. More...
 
 Unit (int A, int cd, int K, int kg, int m, int mol, int s, int rad=0, int sr=0)
 Make a new Unit and set all the exponents to the given values with range checking. More...
 
int A () const
 Returns the exponent for the ampere (current) dimension. More...
 
void A (int e)
 Sets the exponent for the ampere (current) dimension without range checking. More...
 
int amp () const
 Returns the exponent for the ampere (current) dimension. More...
 
void amp (int e)
 Sets the exponent for the ampere (current) dimension without range checking. More...
 
int ampere () const
 Returns the exponent for the ampere (current) dimension. More...
 
void ampere (int e)
 Sets the exponent for the ampere (current) dimension without range checking. More...
 
int candela () const
 Returns the exponent for the candela (luminous intensity) dimension. More...
 
void candela (int e)
 Sets the exponent for the candela (luminous intensity) dimension without range checking. More...
 
int cd () const
 Returns the exponent for the candela (luminous intensity) dimension. More...
 
void cd (int e)
 Sets the exponent for the candela (luminous intensity) dimension without range checking. More...
 
void clear ()
 Makes the Unit unitless. More...
 
int K () const
 Returns the exponent for the kelvin (thermodynamic temperature) dimension. More...
 
void K (int e)
 Sets the exponent for the kelvin (thermodynamic temperature) dimension without range checking. More...
 
int kelvin () const
 Returns the exponent for the kelvin (thermodynamic temperature) dimension. More...
 
void kelvin (int e)
 Sets the exponent for the kelvin (thermodynamic temperature) dimension without range checking. More...
 
int kg () const
 Returns the exponent for the kilogram (mass) dimension. More...
 
void kg (int e)
 Sets the exponent for the kilogram (mass) dimension without range checking. More...
 
int kilogram () const
 Returns the exponent for the kilogram (mass) dimension. More...
 
void kilogram (int e)
 Sets the exponent for the ampere (current)kilogram (mass) dimension without range checking. More...
 
int m () const
 Returns the exponent for the meter (distance) dimension. More...
 
void m (int e)
 Sets the exponent for the meter (distance) dimension without range checking. More...
 
int meter () const
 Returns the exponent for the meter (distance) dimension. More...
 
void meter (int e)
 Sets the exponent for the meter (distance) dimension without range checking. More...
 
int metre () const
 Returns the exponent for the meter (distance) dimension. More...
 
void metre (int e)
 Sets the exponent for the meter (distance) dimension without range checking. More...
 
int mol () const
 Returns the exponent for the mole (amount of substance) dimension. More...
 
void mol (int e)
 Sets the exponent for the mole (amount of substance) dimension without range checking. More...
 
int mole () const
 Returns the exponent for the mole (amount of substance) dimension. More...
 
void mole (int e)
 Sets the exponent for the mole (amount of substance) dimension without range checking. More...
 
bool operator!= (const Unit &U) const
 Unit objects are compared using the u member. More...
 
const Unit operator* (const Unit &U) const
 Combines two units into a new unit. More...
 
Unitoperator*= (const Unit &U)
 Combines two units into a new unit. More...
 
const Unit operator/ (const Unit &U) const
 Combines two units into a new unit. More...
 
Unitoperator/= (const Unit &U)
 Combines two units into a new unit. More...
 
bool operator< (const Unit &U) const
 Unit objects are compared using the u member. More...
 
bool operator<= (const Unit &U) const
 Unit objects are compared using the u member. More...
 
bool operator== (const Unit &U) const
 Unit objects are compared using the u member. More...
 
bool operator> (const Unit &U) const
 Unit objects are compared using the u member. More...
 
bool operator>= (const Unit &U) const
 Unit objects are compared using the u member. More...
 
int rad () const
 Returns the exponent for radians (angle). More...
 
void rad (int e)
 Sets the exponent for radians (angle) without range checking. More...
 
int radian () const
 Returns the exponent for radians (angle). More...
 
void radian (int e)
 Sets the exponent for radians (angle) without range checking. More...
 
int s () const
 Returns the exponent for the second (time) dimension. More...
 
void s (int e)
 Sets the exponent for the second (time) dimension without range checking. More...
 
int second () const
 Returns the exponent for the second (time) dimension. More...
 
void second (int e)
 Sets the exponent for the second (time) dimension without range checking. More...
 
void setAmp (int e)
 Sets the exponent for the ampere (current) dimension. More...
 
void setAmpere (int e)
 Sets the exponent for the ampere (current) dimension. More...
 
void setCandela (int e)
 Sets the exponent for the candela (luminous intensity) dimension. More...
 
void setKelvin (int e)
 Sets the exponent for the kelvin (thermodynamic temperature) dimension. More...
 
void setKilogram (int e)
 Sets the exponent for the kilogram (mass) dimension. More...
 
void setMeter (int e)
 Sets the exponent for the meter (distance) dimension. More...
 
void setMetre (int e)
 Sets the exponent for the meter (distance) dimension. More...
 
void setMole (int e)
 Sets the exponent for the mole (amount of substance) dimension. More...
 
void setRadian (int e)
 Sets the exponent for radians (angle). More...
 
void setSecond (int e)
 Sets the exponent for the second (time) dimension. More...
 
void setSteradian (int e)
 Sets the exponent for steradians (solid angle). More...
 
int sr () const
 Returns the exponent for steradians (solid angle). More...
 
void sr (int e)
 Sets the exponent for steradians (solid angle) without range checking. More...
 
int steradian () const
 Returns the exponent for steradians (solid angle). More...
 
void steradian (int e)
 Sets the exponent for steradians (solid angle) without range checking. More...
 
bool unitless () const
 Returns true if the Unit represents no units. More...
 
std::int32_t value () const
 Returns the internal exponent fields. More...
 

Private Member Functions

template<class A >
void serialize (A &a, const unsigned int)
 Serialize the unit data. More...
 

Private Attributes

std::int32_t u
 Stores the exponent fields. More...
 

Friends

class boost::serialization::access
 Serialization support. More...
 

Detailed Description

Represents an SI unit, either base or derived.

Todo:
Rename to SiUnit? Not sure.

Each base SI unit has a nibble sized field inside a 32-bit integer. There are an additional two bits each for radians and steradians. Each of these fields is a signed integer that is the exponent for the unit. All the units are multiplied, with their exponent applied, to produce the final unit.

Functions named for the units are available to get the exponent for the unit and to change the exponent. The functions that begin with "set" will perform range checking, while the other functions will not. Without range checking, the exponent to change will be incorrect if it is outside of the allowable range (see Bit fields below), but all other exponents will always remain unchanged.

Multiply and divide operators are supplied for combining Unit objects. These operators perform range checking and will throw if any exponent goes beyond the allowable range.

Inconsistency with kilogram
In order to avoid having a bunch of unusual derived SI units, mass is in kilograms instead of grams. As a result, an exponent of 1 for mass denotes kilograms. This makes for a special case to avoid a user interface from showing something like "millikilograms" when the scale is adjusted.
Time
Time is typically stored in types defined by C++ in the std::chrono namespace. These types explicitly define the unit in use. If a Unit is associated with one of these types, the Unit should indicate seconds and the software should use the type for the actual units. While this is a special case, time is already a big and annoying special case.
Bit fields
Access to the fields are coded explicitly to improve portability. The 32-bit integer containing all the fields is stored in native endianness.
Base unit Byte Bit range Exponent range
Ampere 0 0-3 -8 to 7
Candela 0 4-7 -8 to 7
Kelvin 1 8-11, 0-3 -8 to 7
Kilogram 1 12-15, 4-7 -8 to 7
Meter 2 16-19. 0-3 -8 to 7
Mole 2 20-23, 4-7 -8 to 7
Second 3 24-27, 0-3 -8 to 7
Radian 3 28-29, 4-5 -2 to 1
Steradian 3 30-31, 6-7 -2 to 1
Possible change to 64-bit integer (bad):
Unit Byte Bit range Exponent range Notes
Ampere 0 0-4 -16 to 15 SI base unit
Candela 0-1 5-9 -16 to 15 SI base unit
Kelvin 1 10-14 -16 to 15 SI base unit
Kilogram 1-2 15-19 -16 to 15 SI base unit
Meter 2-3 20-24 -16 to 15 SI base unit
Mole 3 25-29 -16 to 15 SI base unit
Second 3-4 30-34 -16 to 15 SI base unit
Radian 4 35-38 -8 to 7 Needed for torque
Steradian 4-5 39-42 -8 to 7 Needed for lumen
Becquerel 5 43-46 -8 to 7 Not the same as hertz
Gray 5-6 47-50 -8 to 7 Not the same as sievert
Sievert 6 51-54 -8 to 7 Not the same as gray
Rel humid 6-7 55-58 -8 to 7 Unitless if not included
Another possible change (better):
Unit Byte Bit range Exponent range Notes
Ampere 0 0-4 -16 to 15 SI base unit
Candela 0-1 5-9 -16 to 15 SI base unit
Kelvin 1 10-14 -16 to 15 SI base unit
Kilogram 1-2 15-19 -16 to 15 SI base unit
Meter 2-3 20-24 -16 to 15 SI base unit
Mole 3 25-29 -16 to 15 SI base unit
Second 3-4 30-34 -16 to 15 SI base unit
Radian 4 35-38 -8 to 7 Needed for torque
Steradian 4-5 39-42 -8 to 7 Needed for lumen
Property 5 43-46 NA (4 bits) Arbitrary physical propery value
Scale/off 6-7 47-63 NA (17 bits) Scale or offset?
The propery value is an arbitrary value that, when taken with the context of the other values, indicates the physical property being measured. The above suggestion allows for 16 different properties for each possible combination of the base SI units.

Yet another possible change (best?):

Unit Byte Bit range Exponent range Notes
Ampere 0 0-4 -16 to 15 SI base unit
Candela 0-1 5-9 -16 to 15 SI base unit
Kelvin 1 10-14 -16 to 15 SI base unit
Kilogram 1-2 15-19 -16 to 15 SI base unit
Meter 2-3 20-24 -16 to 15 SI base unit
Mole 3 25-29 -16 to 15 SI base unit
Second 3-4 30-34 -16 to 15 SI base unit
Radian 4 35-39 -16 to 15 Needed for torque
Steradian 5 40-44 -16 to 15 Needed for lumen
Property 5-7 45-63 NA (19 bits) Arbitrary physical propery value

Property value meanings:

  • Ratio (non-zero to differentiate from unknown/unset)
    • Relative humidity
  • Calibrated instrument
  • Raw unconverted data; meaning/units are device specific
  • Value from local (device) axis (?)
  • Something to help with ambiguity:
    • Hertz versus Becquerel
    • Sievert versus Gray
Bug:
Some units, like Watts cubed, cannot be represented. Consider larger fields. Maybe use larger fields on another type used for intermediate results and unusual units and allow implicit conversions.
Author
Jeff Jackowski
Examples:
am2320test.cpp, apds9301test.cpp, and tsl2591test.cpp.

Definition at line 178 of file Unit.hpp.

Constructor & Destructor Documentation

◆ Unit() [1/4]

duds::data::Unit::Unit ( )
default

Construct the same as a std::int32_t; expect the value to be uninitalized.

◆ Unit() [2/4]

duds::data::Unit::Unit ( const Unit )
default

Copy construct the same as a std::int32_t.

◆ Unit() [3/4]

constexpr duds::data::Unit::Unit ( std::int32_t  U)
inline

Make a new Unit set to a specific unit value; intended for making common unit constants with DUDS_UNIT_VALUE and initializing to zero for no unit or abstract unit.

Warning
No range checking can be performed because this constructor is declared constexpr. The advantage is that Unit objects for any supported specific unit can also be declared constexpr.

Definition at line 220 of file Unit.hpp.

◆ Unit() [4/4]

duds::data::Unit::Unit ( int  A,
int  cd,
int  K,
int  kg,
int  m,
int  mol,
int  s,
int  rad = 0,
int  sr = 0 
)

Make a new Unit and set all the exponents to the given values with range checking.

Parameters
AThe exponent for amperes.
cdThe exponent for candelas.
KThe exponent for kelvin.
kgThe exponent for kilograms.
mThe exponent for meters.
molThe exponent for moles.
sThe exponent for seconds.
radThe exponent for radians.
srThe exponent for steradians.
Exceptions
UnitRangeErrorAn exponent is out of the allowable range.

Definition at line 96 of file Unit.cpp.

Member Function Documentation

◆ A() [1/2]

int duds::data::Unit::A ( ) const
inline

Returns the exponent for the ampere (current) dimension.

Definition at line 306 of file Unit.hpp.

◆ A() [2/2]

void duds::data::Unit::A ( int  e)
inline

Sets the exponent for the ampere (current) dimension without range checking.

Parameters
eThe exponent in a range between -8 to 7, inclusive.

Definition at line 448 of file Unit.hpp.

◆ amp() [1/2]

int duds::data::Unit::amp ( ) const
inline

Returns the exponent for the ampere (current) dimension.

Definition at line 294 of file Unit.hpp.

◆ amp() [2/2]

void duds::data::Unit::amp ( int  e)
inline

Sets the exponent for the ampere (current) dimension without range checking.

Parameters
eThe exponent in a range between -8 to 7, inclusive.

Definition at line 432 of file Unit.hpp.

◆ ampere() [1/2]

int duds::data::Unit::ampere ( ) const
inline

Returns the exponent for the ampere (current) dimension.

Definition at line 240 of file Unit.hpp.

Referenced by duds::data::ExtendedUnit::A(), duds::data::ExtendedUnit::amp(), duds::data::ExtendedUnit::ampere(), operator*(), and operator/().

◆ ampere() [2/2]

void duds::data::Unit::ampere ( int  e)
inline

Sets the exponent for the ampere (current) dimension without range checking.

Parameters
eThe exponent in a range between -8 to 7, inclusive.

Definition at line 362 of file Unit.hpp.

◆ candela() [1/2]

int duds::data::Unit::candela ( ) const
inline

Returns the exponent for the candela (luminous intensity) dimension.

Definition at line 246 of file Unit.hpp.

Referenced by duds::data::ExtendedUnit::candela(), duds::data::ExtendedUnit::cd(), operator*(), and operator/().

◆ candela() [2/2]

void duds::data::Unit::candela ( int  e)
inline

Sets the exponent for the candela (luminous intensity) dimension without range checking.

Parameters
eThe exponent in a range between -8 to 7, inclusive.

Definition at line 370 of file Unit.hpp.

◆ cd() [1/2]

int duds::data::Unit::cd ( ) const
inline

Returns the exponent for the candela (luminous intensity) dimension.

Definition at line 312 of file Unit.hpp.

◆ cd() [2/2]

void duds::data::Unit::cd ( int  e)
inline

Sets the exponent for the candela (luminous intensity) dimension without range checking.

Parameters
eThe exponent in a range between -8 to 7, inclusive.

Definition at line 456 of file Unit.hpp.

◆ clear()

void duds::data::Unit::clear ( )
inline

Makes the Unit unitless.

Definition at line 593 of file Unit.hpp.

Referenced by duds::data::QuantityNddArray::clear().

◆ K() [1/2]

int duds::data::Unit::K ( ) const
inline

Returns the exponent for the kelvin (thermodynamic temperature) dimension.

Definition at line 318 of file Unit.hpp.

◆ K() [2/2]

void duds::data::Unit::K ( int  e)
inline

Sets the exponent for the kelvin (thermodynamic temperature) dimension without range checking.

Parameters
eThe exponent in a range between -8 to 7, inclusive.

Definition at line 464 of file Unit.hpp.

◆ kelvin() [1/2]

int duds::data::Unit::kelvin ( ) const
inline

Returns the exponent for the kelvin (thermodynamic temperature) dimension.

Definition at line 252 of file Unit.hpp.

Referenced by duds::data::ExtendedUnit::K(), duds::data::ExtendedUnit::kelvin(), operator*(), and operator/().

◆ kelvin() [2/2]

void duds::data::Unit::kelvin ( int  e)
inline

Sets the exponent for the kelvin (thermodynamic temperature) dimension without range checking.

Parameters
eThe exponent in a range between -8 to 7, inclusive.

Definition at line 378 of file Unit.hpp.

◆ kg() [1/2]

int duds::data::Unit::kg ( ) const
inline

Returns the exponent for the kilogram (mass) dimension.

Definition at line 324 of file Unit.hpp.

◆ kg() [2/2]

void duds::data::Unit::kg ( int  e)
inline

Sets the exponent for the kilogram (mass) dimension without range checking.

Parameters
eThe exponent in a range between -8 to 7, inclusive.

Definition at line 472 of file Unit.hpp.

◆ kilogram() [1/2]

int duds::data::Unit::kilogram ( ) const
inline

Returns the exponent for the kilogram (mass) dimension.

Definition at line 258 of file Unit.hpp.

Referenced by duds::data::ExtendedUnit::kg(), duds::data::ExtendedUnit::kilogram(), operator*(), and operator/().

◆ kilogram() [2/2]

void duds::data::Unit::kilogram ( int  e)
inline

Sets the exponent for the ampere (current)kilogram (mass) dimension without range checking.

Parameters
eThe exponent in a range between -8 to 7, inclusive.

Definition at line 386 of file Unit.hpp.

◆ m() [1/2]

int duds::data::Unit::m ( ) const
inline

Returns the exponent for the meter (distance) dimension.

Definition at line 330 of file Unit.hpp.

◆ m() [2/2]

void duds::data::Unit::m ( int  e)
inline

Sets the exponent for the meter (distance) dimension without range checking.

Parameters
eThe exponent in a range between -8 to 7, inclusive.

Definition at line 480 of file Unit.hpp.

◆ meter() [1/2]

int duds::data::Unit::meter ( ) const
inline

Returns the exponent for the meter (distance) dimension.

Definition at line 264 of file Unit.hpp.

Referenced by duds::data::ExtendedUnit::m(), duds::data::ExtendedUnit::meter(), duds::data::ExtendedUnit::metre(), operator*(), and operator/().

◆ meter() [2/2]

void duds::data::Unit::meter ( int  e)
inline

Sets the exponent for the meter (distance) dimension without range checking.

Parameters
eThe exponent in a range between -8 to 7, inclusive.

Definition at line 394 of file Unit.hpp.

◆ metre() [1/2]

int duds::data::Unit::metre ( ) const
inline

Returns the exponent for the meter (distance) dimension.

Definition at line 300 of file Unit.hpp.

◆ metre() [2/2]

void duds::data::Unit::metre ( int  e)
inline

Sets the exponent for the meter (distance) dimension without range checking.

Parameters
eThe exponent in a range between -8 to 7, inclusive.

Definition at line 440 of file Unit.hpp.

◆ mol() [1/2]

int duds::data::Unit::mol ( ) const
inline

Returns the exponent for the mole (amount of substance) dimension.

Definition at line 336 of file Unit.hpp.

◆ mol() [2/2]

void duds::data::Unit::mol ( int  e)
inline

Sets the exponent for the mole (amount of substance) dimension without range checking.

Parameters
eThe exponent in a range between -8 to 7, inclusive.

Definition at line 488 of file Unit.hpp.

◆ mole() [1/2]

int duds::data::Unit::mole ( ) const
inline

Returns the exponent for the mole (amount of substance) dimension.

Definition at line 270 of file Unit.hpp.

Referenced by duds::data::ExtendedUnit::mol(), duds::data::ExtendedUnit::mole(), operator*(), and operator/().

◆ mole() [2/2]

void duds::data::Unit::mole ( int  e)
inline

Sets the exponent for the mole (amount of substance) dimension without range checking.

Parameters
eThe exponent in a range between -8 to 7, inclusive.

Definition at line 402 of file Unit.hpp.

◆ operator!=()

bool duds::data::Unit::operator!= ( const Unit U) const
inline

Unit objects are compared using the u member.

Definition at line 655 of file Unit.hpp.

◆ operator*()

const Unit duds::data::Unit::operator* ( const Unit U) const

Combines two units into a new unit.

Exceptions
UnitRangeErrorA resulting exponent is out of range.

Definition at line 109 of file Unit.cpp.

◆ operator*=()

Unit & duds::data::Unit::operator*= ( const Unit U)

Combines two units into a new unit.

Exceptions
UnitRangeErrorA resulting exponent is out of range. All work is done on a temporary so that if an exception is thrown only the temporary is modified.

Definition at line 143 of file Unit.cpp.

◆ operator/()

const Unit duds::data::Unit::operator/ ( const Unit U) const

Combines two units into a new unit.

Exceptions
UnitRangeErrorA resulting exponent is out of range.

Definition at line 126 of file Unit.cpp.

◆ operator/=()

Unit & duds::data::Unit::operator/= ( const Unit U)

Combines two units into a new unit.

Exceptions
UnitRangeErrorA resulting exponent is out of range. All work is done on a temporary so that if an exception is thrown only the temporary is modified.

Definition at line 151 of file Unit.cpp.

◆ operator<()

bool duds::data::Unit::operator< ( const Unit U) const
inline

Unit objects are compared using the u member.

Definition at line 625 of file Unit.hpp.

◆ operator<=()

bool duds::data::Unit::operator<= ( const Unit U) const
inline

Unit objects are compared using the u member.

Definition at line 637 of file Unit.hpp.

◆ operator==()

bool duds::data::Unit::operator== ( const Unit U) const
inline

Unit objects are compared using the u member.

Definition at line 649 of file Unit.hpp.

◆ operator>()

bool duds::data::Unit::operator> ( const Unit U) const
inline

Unit objects are compared using the u member.

Definition at line 631 of file Unit.hpp.

◆ operator>=()

bool duds::data::Unit::operator>= ( const Unit U) const
inline

Unit objects are compared using the u member.

Definition at line 643 of file Unit.hpp.

◆ rad() [1/2]

int duds::data::Unit::rad ( ) const
inline

Returns the exponent for radians (angle).

Definition at line 348 of file Unit.hpp.

◆ rad() [2/2]

void duds::data::Unit::rad ( int  e)
inline

Sets the exponent for radians (angle) without range checking.

Parameters
eThe exponent in a range between -2 to 1, inclusive.

Definition at line 503 of file Unit.hpp.

◆ radian() [1/2]

int duds::data::Unit::radian ( ) const
inline

Returns the exponent for radians (angle).

Definition at line 282 of file Unit.hpp.

Referenced by operator*(), operator/(), duds::data::ExtendedUnit::rad(), and duds::data::ExtendedUnit::radian().

◆ radian() [2/2]

void duds::data::Unit::radian ( int  e)
inline

Sets the exponent for radians (angle) without range checking.

Parameters
eThe exponent in a range between -2 to 1, inclusive.

Definition at line 417 of file Unit.hpp.

◆ s() [1/2]

int duds::data::Unit::s ( ) const
inline

Returns the exponent for the second (time) dimension.

Definition at line 342 of file Unit.hpp.

◆ s() [2/2]

void duds::data::Unit::s ( int  e)
inline

Sets the exponent for the second (time) dimension without range checking.

Parameters
eThe exponent in a range between -8 to 7, inclusive.

Definition at line 496 of file Unit.hpp.

◆ second() [1/2]

int duds::data::Unit::second ( ) const
inline

Returns the exponent for the second (time) dimension.

Definition at line 276 of file Unit.hpp.

Referenced by operator*(), operator/(), duds::data::ExtendedUnit::s(), and duds::data::ExtendedUnit::second().

◆ second() [2/2]

void duds::data::Unit::second ( int  e)
inline

Sets the exponent for the second (time) dimension without range checking.

Parameters
eThe exponent in a range between -8 to 7, inclusive.

Definition at line 410 of file Unit.hpp.

◆ serialize()

template<class A >
void duds::data::Unit::serialize ( A a,
const unsigned  int 
)
inlineprivate

Serialize the unit data.

Warning
The archive (type A) must handle endianness, or be endian agnostic. Some do, like text formats. Not sure about others.

Definition at line 193 of file Unit.hpp.

◆ setAmp()

void duds::data::Unit::setAmp ( int  e)
inline

Sets the exponent for the ampere (current) dimension.

Parameters
eThe exponent in a range between -8 to 7, inclusive.
Exceptions
UnitRangeErrorThe exponent e is out of range.

Definition at line 572 of file Unit.hpp.

◆ setAmpere()

void duds::data::Unit::setAmpere ( int  e)

Sets the exponent for the ampere (current) dimension.

Parameters
eThe exponent in a range between -8 to 7, inclusive.
Exceptions
UnitRangeErrorThe exponent e is out of range.

Definition at line 15 of file Unit.cpp.

Referenced by operator*(), operator/(), duds::data::ExtendedUnit::setAmp(), duds::data::ExtendedUnit::setAmpere(), and Unit().

◆ setCandela()

void duds::data::Unit::setCandela ( int  e)

Sets the exponent for the candela (luminous intensity) dimension.

Parameters
eThe exponent in a range between -8 to 7, inclusive.
Exceptions
UnitRangeErrorThe exponent e is out of range.

Definition at line 24 of file Unit.cpp.

Referenced by operator*(), operator/(), duds::data::ExtendedUnit::setCandela(), and Unit().

◆ setKelvin()

void duds::data::Unit::setKelvin ( int  e)

Sets the exponent for the kelvin (thermodynamic temperature) dimension.

Parameters
eThe exponent in a range between -8 to 7, inclusive.
Exceptions
UnitRangeErrorThe exponent e is out of range.

Definition at line 33 of file Unit.cpp.

Referenced by operator*(), operator/(), duds::data::ExtendedUnit::setKelvin(), and Unit().

◆ setKilogram()

void duds::data::Unit::setKilogram ( int  e)

Sets the exponent for the kilogram (mass) dimension.

Parameters
eThe exponent in a range between -8 to 7, inclusive.
Exceptions
UnitRangeErrorThe exponent e is out of range.

Definition at line 42 of file Unit.cpp.

Referenced by operator*(), operator/(), duds::data::ExtendedUnit::setKilogram(), and Unit().

◆ setMeter()

void duds::data::Unit::setMeter ( int  e)

Sets the exponent for the meter (distance) dimension.

Parameters
eThe exponent in a range between -8 to 7, inclusive.
Exceptions
UnitRangeErrorThe exponent e is out of range.

Definition at line 51 of file Unit.cpp.

Referenced by operator*(), operator/(), duds::data::ExtendedUnit::setMeter(), duds::data::ExtendedUnit::setMetre(), and Unit().

◆ setMetre()

void duds::data::Unit::setMetre ( int  e)
inline

Sets the exponent for the meter (distance) dimension.

Parameters
eThe exponent in a range between -8 to 7, inclusive.
Exceptions
UnitRangeErrorThe exponent e is out of range.

Definition at line 580 of file Unit.hpp.

◆ setMole()

void duds::data::Unit::setMole ( int  e)

Sets the exponent for the mole (amount of substance) dimension.

Parameters
eThe exponent in a range between -8 to 7, inclusive.
Exceptions
UnitRangeErrorThe exponent e is out of range.

Definition at line 60 of file Unit.cpp.

Referenced by operator*(), operator/(), duds::data::ExtendedUnit::setMole(), and Unit().

◆ setRadian()

void duds::data::Unit::setRadian ( int  e)

Sets the exponent for radians (angle).

Parameters
eThe exponent in a range between -2 to 1, inclusive.
Exceptions
UnitRangeErrorThe exponent e is out of range.

Definition at line 78 of file Unit.cpp.

Referenced by operator*(), operator/(), duds::data::ExtendedUnit::setRadian(), and Unit().

◆ setSecond()

void duds::data::Unit::setSecond ( int  e)

Sets the exponent for the second (time) dimension.

Parameters
eThe exponent in a range between -8 to 7, inclusive.
Exceptions
UnitRangeErrorThe exponent e is out of range.

Definition at line 69 of file Unit.cpp.

Referenced by operator*(), operator/(), duds::data::ExtendedUnit::setSecond(), and Unit().

◆ setSteradian()

void duds::data::Unit::setSteradian ( int  e)

Sets the exponent for steradians (solid angle).

Parameters
eThe exponent in a range between -2 to 1, inclusive.
Exceptions
UnitRangeErrorThe exponent e is out of range.

Definition at line 87 of file Unit.cpp.

Referenced by operator*(), operator/(), duds::data::ExtendedUnit::setSteradian(), and Unit().

◆ sr() [1/2]

int duds::data::Unit::sr ( ) const
inline

Returns the exponent for steradians (solid angle).

Definition at line 354 of file Unit.hpp.

◆ sr() [2/2]

void duds::data::Unit::sr ( int  e)
inline

Sets the exponent for steradians (solid angle) without range checking.

Parameters
eThe exponent in a range between -2 to 1, inclusive.

Definition at line 510 of file Unit.hpp.

◆ steradian() [1/2]

int duds::data::Unit::steradian ( ) const
inline

Returns the exponent for steradians (solid angle).

Definition at line 288 of file Unit.hpp.

Referenced by operator*(), operator/(), duds::data::ExtendedUnit::sr(), and duds::data::ExtendedUnit::steradian().

◆ steradian() [2/2]

void duds::data::Unit::steradian ( int  e)
inline

Sets the exponent for steradians (solid angle) without range checking.

Parameters
eThe exponent in a range between -2 to 1, inclusive.

Definition at line 424 of file Unit.hpp.

◆ unitless()

bool duds::data::Unit::unitless ( ) const
inline

Returns true if the Unit represents no units.

This is normal for some values, such as ratios.

Definition at line 587 of file Unit.hpp.

Referenced by duds::data::ExtendedUnit::unitless().

◆ value()

std::int32_t duds::data::Unit::value ( ) const
inline

Returns the internal exponent fields.

Definition at line 200 of file Unit.hpp.

Referenced by duds::data::ExtendedUnit::operator*=(), operator*=(), duds::data::ExtendedUnit::operator/=(), and operator/=().

Friends And Related Function Documentation

◆ boost::serialization::access

friend class boost::serialization::access
friend

Serialization support.

Definition at line 186 of file Unit.hpp.

Member Data Documentation

◆ u

std::int32_t duds::data::Unit::u
private

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