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

redo: Use floats for scale and offset. More...

#include <ExtendedUnit.hpp>

Collaboration diagram for duds::data::ExtendedUnit:

Public Member Functions

 ExtendedUnit ()=default
 Makes an uninitialized ExtendedUnit. More...
 
 ExtendedUnit (const ExtendedUnit &)=default
 Makes a copy. More...
 
constexpr ExtendedUnit (Unit u)
 Makes an ExtendedUnit that is equivalent to the given base Unit. More...
 
template<typename O >
 ExtendedUnit (Unit u, O o, int s)
 Constructs an ExtendedUnit with the given values. 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...
 
const Unitbase () const
 Returns the base unit as a Unit object. More...
 
bool canConvertToUnit () const
 True if the unit represented by this object can also be represented by a Unit object. 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...
 
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...
 
void offset (float o)
 Change the offset. More...
 
void offset (double o)
 Change the offset. More...
 
double offset () const
 Query the offset as a double. More...
 
float offsetf () const
 Query the offset as a float. More...
 
bool operator!= (const ExtendedUnit &U) const
 Unit objects are compared using the u member. More...
 
const ExtendedUnit operator* (const Unit &U) const
 Combines two units into a new unit. More...
 
ExtendedUnitoperator*= (const Unit &U)
 Combines two units into a new unit. More...
 
const ExtendedUnit operator/ (const Unit &U) const
 Combines two units into a new unit. More...
 
ExtendedUnitoperator/= (const Unit &U)
 Combines two units into a new unit. More...
 
bool operator< (const ExtendedUnit &U) const
 Unit objects are compared using the u member. More...
 
bool operator<= (const ExtendedUnit &U) const
 Unit objects are compared using the u member. More...
 
ExtendedUnitoperator= (const Unit &U)
 Makes this extended unit equivalent to the given Unit object. More...
 
bool operator== (const ExtendedUnit &U) const
 Unit objects are compared using the u member. More...
 
bool operator> (const ExtendedUnit &U) const
 Unit objects are compared using the u member. More...
 
bool operator>= (const ExtendedUnit &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 object represents no units. More...
 

Private Member Functions

constexpr ExtendedUnit (Unit u, std::uint32_t s)
 An simple internal constructor that takes the values of it members. More...
 
 BOOST_SERIALIZATION_SPLIT_MEMBER ()
 
template<class A >
void load (A &a, const unsigned int)
 
template<class A >
void save (A &a, const unsigned int) const
 

Private Attributes

union {
   struct {
      int   exp: 7
 The exponent as a signed integer rather than unsigned with bias. More...
 
      unsigned int   mant: 20
 The mantissa, save for the impled leading bit. More...
 
      int   scale: 4
 A value used to represnt most SI prefixes. More...
 
      int   sign: 1
 The sign flag. More...
 
   } 
 
   std::uint32_t   scaloff
 A scaling and offset value packed into four bytes. More...
 
}; 
 
Unit unit
 

Friends

class boost::serialization::access
 

Detailed Description

redo: Use floats for scale and offset.

Use 32-bits for 10 3-bit and 1 2-bit additional unit flags (put relative humidity there?), and a Unit. Should be 16 bytes, 128-bits. Include in GenericValue.

Definition at line 26 of file ExtendedUnit.hpp.

Constructor & Destructor Documentation

◆ ExtendedUnit() [1/5]

constexpr duds::data::ExtendedUnit::ExtendedUnit ( Unit  u,
std::uint32_t  s 
)
inlineprivate

An simple internal constructor that takes the values of it members.

Todo:
Maybe make this public along with some macro to set s? Doing so would allow easy creation of constant ExtendedUnit objects, like the Units in Units.hpp. May have to specify the offset it pieces, though.

Definition at line 93 of file ExtendedUnit.hpp.

◆ ExtendedUnit() [2/5]

duds::data::ExtendedUnit::ExtendedUnit ( )
default

Makes an uninitialized ExtendedUnit.

Referenced by ExtendedUnit(), operator*(), and operator/().

◆ ExtendedUnit() [3/5]

duds::data::ExtendedUnit::ExtendedUnit ( const ExtendedUnit )
default

Makes a copy.

◆ ExtendedUnit() [4/5]

constexpr duds::data::ExtendedUnit::ExtendedUnit ( Unit  u)
inline

Makes an ExtendedUnit that is equivalent to the given base Unit.

Parameters
uThe base unit.

Definition at line 107 of file ExtendedUnit.hpp.

◆ ExtendedUnit() [5/5]

template<typename O >
duds::data::ExtendedUnit::ExtendedUnit ( Unit  u,
o,
int  s 
)
inline

Constructs an ExtendedUnit with the given values.

Template Parameters
OThe offset type; must be either float or double. In most cases, the compiler should deduce this type.
Parameters
uThe initial Unit value.
oThe initial offset value.
sThe initial scalar value.
Todo:
Document the offset and scalar better.
Exceptions
UnitRangeErrorEither the scalar or offset value is beyond the bounds of the internal storage.

Definition at line 120 of file ExtendedUnit.hpp.

Member Function Documentation

◆ A() [1/2]

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

Returns the exponent for the ampere (current) dimension.

Definition at line 228 of file ExtendedUnit.hpp.

◆ A() [2/2]

void duds::data::ExtendedUnit::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 370 of file ExtendedUnit.hpp.

◆ amp() [1/2]

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

Returns the exponent for the ampere (current) dimension.

Definition at line 216 of file ExtendedUnit.hpp.

◆ amp() [2/2]

void duds::data::ExtendedUnit::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 354 of file ExtendedUnit.hpp.

◆ ampere() [1/2]

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

Returns the exponent for the ampere (current) dimension.

Definition at line 162 of file ExtendedUnit.hpp.

◆ ampere() [2/2]

void duds::data::ExtendedUnit::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 284 of file ExtendedUnit.hpp.

◆ base()

const Unit& duds::data::ExtendedUnit::base ( ) const
inline

Returns the base unit as a Unit object.

Definition at line 156 of file ExtendedUnit.hpp.

◆ BOOST_SERIALIZATION_SPLIT_MEMBER()

duds::data::ExtendedUnit::BOOST_SERIALIZATION_SPLIT_MEMBER ( )
private

Referenced by load().

◆ canConvertToUnit()

bool duds::data::ExtendedUnit::canConvertToUnit ( ) const

True if the unit represented by this object can also be represented by a Unit object.

Referenced by ExtendedUnit().

◆ candela() [1/2]

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

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

Definition at line 168 of file ExtendedUnit.hpp.

◆ candela() [2/2]

void duds::data::ExtendedUnit::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 292 of file ExtendedUnit.hpp.

◆ cd() [1/2]

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

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

Definition at line 234 of file ExtendedUnit.hpp.

◆ cd() [2/2]

void duds::data::ExtendedUnit::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 378 of file ExtendedUnit.hpp.

◆ K() [1/2]

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

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

Definition at line 240 of file ExtendedUnit.hpp.

◆ K() [2/2]

void duds::data::ExtendedUnit::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 386 of file ExtendedUnit.hpp.

◆ kelvin() [1/2]

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

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

Definition at line 174 of file ExtendedUnit.hpp.

◆ kelvin() [2/2]

void duds::data::ExtendedUnit::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 300 of file ExtendedUnit.hpp.

◆ kg() [1/2]

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

Returns the exponent for the kilogram (mass) dimension.

Definition at line 246 of file ExtendedUnit.hpp.

◆ kg() [2/2]

void duds::data::ExtendedUnit::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 394 of file ExtendedUnit.hpp.

◆ kilogram() [1/2]

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

Returns the exponent for the kilogram (mass) dimension.

Definition at line 180 of file ExtendedUnit.hpp.

◆ kilogram() [2/2]

void duds::data::ExtendedUnit::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 308 of file ExtendedUnit.hpp.

◆ load()

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

Definition at line 73 of file ExtendedUnit.hpp.

◆ m() [1/2]

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

Returns the exponent for the meter (distance) dimension.

Definition at line 252 of file ExtendedUnit.hpp.

◆ m() [2/2]

void duds::data::ExtendedUnit::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 402 of file ExtendedUnit.hpp.

◆ meter() [1/2]

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

Returns the exponent for the meter (distance) dimension.

Definition at line 186 of file ExtendedUnit.hpp.

◆ meter() [2/2]

void duds::data::ExtendedUnit::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 316 of file ExtendedUnit.hpp.

◆ metre() [1/2]

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

Returns the exponent for the meter (distance) dimension.

Definition at line 222 of file ExtendedUnit.hpp.

◆ metre() [2/2]

void duds::data::ExtendedUnit::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 362 of file ExtendedUnit.hpp.

◆ mol() [1/2]

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

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

Definition at line 258 of file ExtendedUnit.hpp.

◆ mol() [2/2]

void duds::data::ExtendedUnit::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 410 of file ExtendedUnit.hpp.

◆ mole() [1/2]

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

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

Definition at line 192 of file ExtendedUnit.hpp.

◆ mole() [2/2]

void duds::data::ExtendedUnit::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 324 of file ExtendedUnit.hpp.

◆ offset() [1/3]

void duds::data::ExtendedUnit::offset ( float  o)

Change the offset.

Parameters
oThe new offset. Is must not be subnormal, infinite, or NaN.
Exceptions
UnitRangeErrorThe offset value is beyond the bounds of the internal storage.

Definition at line 14 of file ExtendedUnit.cpp.

◆ offset() [2/3]

void duds::data::ExtendedUnit::offset ( double  o)

Change the offset.

Parameters
oThe new offset. Is must not be subnormal, infinite, or NaN.
Exceptions
UnitRangeErrorThe offset value is beyond the bounds of the internal storage.

Definition at line 30 of file ExtendedUnit.cpp.

◆ offset() [3/3]

double duds::data::ExtendedUnit::offset ( ) const

Query the offset as a double.

Definition at line 41 of file ExtendedUnit.cpp.

Referenced by ExtendedUnit().

◆ offsetf()

float duds::data::ExtendedUnit::offsetf ( ) const

Query the offset as a float.

Definition at line 25 of file ExtendedUnit.cpp.

Referenced by ExtendedUnit().

◆ operator!=()

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

Unit objects are compared using the u member.

Definition at line 593 of file ExtendedUnit.hpp.

◆ operator*()

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

Combines two units into a new unit.

Exceptions
UnitRangeErrorA resulting exponent is out of range.

Definition at line 47 of file ExtendedUnit.cpp.

Referenced by unitless().

◆ operator*=()

ExtendedUnit & duds::data::ExtendedUnit::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 57 of file ExtendedUnit.cpp.

Referenced by unitless().

◆ operator/()

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

Combines two units into a new unit.

Exceptions
UnitRangeErrorA resulting exponent is out of range.

Definition at line 52 of file ExtendedUnit.cpp.

Referenced by unitless().

◆ operator/=()

ExtendedUnit & duds::data::ExtendedUnit::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 65 of file ExtendedUnit.cpp.

Referenced by unitless().

◆ operator<()

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

Unit objects are compared using the u member.

Definition at line 563 of file ExtendedUnit.hpp.

◆ operator<=()

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

Unit objects are compared using the u member.

Definition at line 575 of file ExtendedUnit.hpp.

◆ operator=()

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

Makes this extended unit equivalent to the given Unit object.

Definition at line 73 of file ExtendedUnit.cpp.

Referenced by unitless().

◆ operator==()

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

Unit objects are compared using the u member.

Definition at line 587 of file ExtendedUnit.hpp.

◆ operator>()

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

Unit objects are compared using the u member.

Definition at line 569 of file ExtendedUnit.hpp.

◆ operator>=()

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

Unit objects are compared using the u member.

Definition at line 581 of file ExtendedUnit.hpp.

◆ rad() [1/2]

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

Returns the exponent for radians (angle).

Definition at line 270 of file ExtendedUnit.hpp.

◆ rad() [2/2]

void duds::data::ExtendedUnit::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 425 of file ExtendedUnit.hpp.

◆ radian() [1/2]

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

Returns the exponent for radians (angle).

Definition at line 204 of file ExtendedUnit.hpp.

◆ radian() [2/2]

void duds::data::ExtendedUnit::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 339 of file ExtendedUnit.hpp.

◆ s() [1/2]

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

Returns the exponent for the second (time) dimension.

Definition at line 264 of file ExtendedUnit.hpp.

◆ s() [2/2]

void duds::data::ExtendedUnit::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 418 of file ExtendedUnit.hpp.

◆ save()

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

Definition at line 64 of file ExtendedUnit.hpp.

◆ second() [1/2]

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

Returns the exponent for the second (time) dimension.

Definition at line 198 of file ExtendedUnit.hpp.

Referenced by s().

◆ second() [2/2]

void duds::data::ExtendedUnit::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 332 of file ExtendedUnit.hpp.

◆ setAmp()

void duds::data::ExtendedUnit::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 512 of file ExtendedUnit.hpp.

◆ setAmpere()

void duds::data::ExtendedUnit::setAmpere ( 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 440 of file ExtendedUnit.hpp.

◆ setCandela()

void duds::data::ExtendedUnit::setCandela ( int  e)
inline

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 448 of file ExtendedUnit.hpp.

◆ setKelvin()

void duds::data::ExtendedUnit::setKelvin ( int  e)
inline

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 456 of file ExtendedUnit.hpp.

◆ setKilogram()

void duds::data::ExtendedUnit::setKilogram ( int  e)
inline

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 464 of file ExtendedUnit.hpp.

◆ setMeter()

void duds::data::ExtendedUnit::setMeter ( 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 472 of file ExtendedUnit.hpp.

◆ setMetre()

void duds::data::ExtendedUnit::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 520 of file ExtendedUnit.hpp.

◆ setMole()

void duds::data::ExtendedUnit::setMole ( int  e)
inline

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 480 of file ExtendedUnit.hpp.

◆ setRadian()

void duds::data::ExtendedUnit::setRadian ( int  e)
inline

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 496 of file ExtendedUnit.hpp.

◆ setSecond()

void duds::data::ExtendedUnit::setSecond ( int  e)
inline

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 488 of file ExtendedUnit.hpp.

◆ setSteradian()

void duds::data::ExtendedUnit::setSteradian ( int  e)
inline

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 504 of file ExtendedUnit.hpp.

◆ sr() [1/2]

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

Returns the exponent for steradians (solid angle).

Definition at line 276 of file ExtendedUnit.hpp.

◆ sr() [2/2]

void duds::data::ExtendedUnit::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 432 of file ExtendedUnit.hpp.

◆ steradian() [1/2]

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

Returns the exponent for steradians (solid angle).

Definition at line 210 of file ExtendedUnit.hpp.

◆ steradian() [2/2]

void duds::data::ExtendedUnit::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 346 of file ExtendedUnit.hpp.

◆ unitless()

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

Returns true if the object represents no units.

This is normal for some values, such as ratios.

Definition at line 527 of file ExtendedUnit.hpp.

Friends And Related Function Documentation

◆ boost::serialization::access

friend class boost::serialization::access
friend

Definition at line 62 of file ExtendedUnit.hpp.

Member Data Documentation

◆ @1

union { ... }

◆ exp

int duds::data::ExtendedUnit::exp

The exponent as a signed integer rather than unsigned with bias.

Definition at line 44 of file ExtendedUnit.hpp.

Referenced by load(), offset(), offsetf(), and save().

◆ mant

unsigned int duds::data::ExtendedUnit::mant

The mantissa, save for the impled leading bit.

Definition at line 40 of file ExtendedUnit.hpp.

Referenced by load(), offset(), offsetf(), and save().

◆ scale

int duds::data::ExtendedUnit::scale

A value used to represnt most SI prefixes.

The prefixes represent a scalar value. To produce this prefix scalar, multiply scale by three, then rasie ten to the power of the product. Kilograms has a prefix built into the base unit resulting in inconsistency. This scalar modifies kilo in kilograms. Thus, if unit is Kilogram, then a scale of -1 produces the unit gram.

Definition at line 58 of file ExtendedUnit.hpp.

Referenced by load(), and save().

◆ scaloff

std::uint32_t duds::data::ExtendedUnit::scaloff

A scaling and offset value packed into four bytes.

The scalar works for most of the metric prefixes. The offset works for 273.15. All this fits in the space of a single float. The offset needs more precision than a half (from IEEE 754).

Definition at line 35 of file ExtendedUnit.hpp.

Referenced by operator!=(), operator*(), operator/(), operator<(), operator<=(), operator=(), operator==(), operator>(), and operator>=().

◆ sign

int duds::data::ExtendedUnit::sign

The sign flag.

Definition at line 48 of file ExtendedUnit.hpp.

Referenced by load(), offset(), offsetf(), and save().

◆ unit

Unit duds::data::ExtendedUnit::unit
private

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