|
DUDS
|
Distributed Update of Data from Something
|
redo: Use floats for scale and offset. More...
#include <ExtendedUnit.hpp>
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 Unit & | base () 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... | |
| ExtendedUnit & | operator*= (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... | |
| ExtendedUnit & | operator/= (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... | |
| ExtendedUnit & | operator= (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 |
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.
|
inlineprivate |
An simple internal constructor that takes the values of it members.
Definition at line 93 of file ExtendedUnit.hpp.
|
default |
Makes an uninitialized ExtendedUnit.
Referenced by ExtendedUnit(), operator*(), and operator/().
|
default |
Makes a copy.
|
inline |
Makes an ExtendedUnit that is equivalent to the given base Unit.
| u | The base unit. |
Definition at line 107 of file ExtendedUnit.hpp.
|
inline |
Constructs an ExtendedUnit with the given values.
| O | The offset type; must be either float or double. In most cases, the compiler should deduce this type. |
| u | The initial Unit value. |
| o | The initial offset value. |
| s | The initial scalar value. |
| UnitRangeError | Either the scalar or offset value is beyond the bounds of the internal storage. |
Definition at line 120 of file ExtendedUnit.hpp.
|
inline |
Returns the exponent for the ampere (current) dimension.
Definition at line 228 of file ExtendedUnit.hpp.
|
inline |
Sets the exponent for the ampere (current) dimension without range checking.
| e | The exponent in a range between -8 to 7, inclusive. |
Definition at line 370 of file ExtendedUnit.hpp.
|
inline |
Returns the exponent for the ampere (current) dimension.
Definition at line 216 of file ExtendedUnit.hpp.
|
inline |
Sets the exponent for the ampere (current) dimension without range checking.
| e | The exponent in a range between -8 to 7, inclusive. |
Definition at line 354 of file ExtendedUnit.hpp.
|
inline |
Returns the exponent for the ampere (current) dimension.
Definition at line 162 of file ExtendedUnit.hpp.
|
inline |
Sets the exponent for the ampere (current) dimension without range checking.
| e | The exponent in a range between -8 to 7, inclusive. |
Definition at line 284 of file ExtendedUnit.hpp.
|
inline |
Returns the base unit as a Unit object.
Definition at line 156 of file ExtendedUnit.hpp.
|
private |
Referenced by load().
| 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().
|
inline |
Returns the exponent for the candela (luminous intensity) dimension.
Definition at line 168 of file ExtendedUnit.hpp.
|
inline |
Sets the exponent for the candela (luminous intensity) dimension without range checking.
| e | The exponent in a range between -8 to 7, inclusive. |
Definition at line 292 of file ExtendedUnit.hpp.
|
inline |
Returns the exponent for the candela (luminous intensity) dimension.
Definition at line 234 of file ExtendedUnit.hpp.
|
inline |
Sets the exponent for the candela (luminous intensity) dimension without range checking.
| e | The exponent in a range between -8 to 7, inclusive. |
Definition at line 378 of file ExtendedUnit.hpp.
|
inline |
Returns the exponent for the kelvin (thermodynamic temperature) dimension.
Definition at line 240 of file ExtendedUnit.hpp.
|
inline |
Sets the exponent for the kelvin (thermodynamic temperature) dimension without range checking.
| e | The exponent in a range between -8 to 7, inclusive. |
Definition at line 386 of file ExtendedUnit.hpp.
|
inline |
Returns the exponent for the kelvin (thermodynamic temperature) dimension.
Definition at line 174 of file ExtendedUnit.hpp.
|
inline |
Sets the exponent for the kelvin (thermodynamic temperature) dimension without range checking.
| e | The exponent in a range between -8 to 7, inclusive. |
Definition at line 300 of file ExtendedUnit.hpp.
|
inline |
Returns the exponent for the kilogram (mass) dimension.
Definition at line 246 of file ExtendedUnit.hpp.
|
inline |
Sets the exponent for the kilogram (mass) dimension without range checking.
| e | The exponent in a range between -8 to 7, inclusive. |
Definition at line 394 of file ExtendedUnit.hpp.
|
inline |
Returns the exponent for the kilogram (mass) dimension.
Definition at line 180 of file ExtendedUnit.hpp.
|
inline |
Sets the exponent for the ampere (current)kilogram (mass) dimension without range checking.
| e | The exponent in a range between -8 to 7, inclusive. |
Definition at line 308 of file ExtendedUnit.hpp.
|
inlineprivate |
Definition at line 73 of file ExtendedUnit.hpp.
|
inline |
Returns the exponent for the meter (distance) dimension.
Definition at line 252 of file ExtendedUnit.hpp.
|
inline |
Sets the exponent for the meter (distance) dimension without range checking.
| e | The exponent in a range between -8 to 7, inclusive. |
Definition at line 402 of file ExtendedUnit.hpp.
|
inline |
Returns the exponent for the meter (distance) dimension.
Definition at line 186 of file ExtendedUnit.hpp.
|
inline |
Sets the exponent for the meter (distance) dimension without range checking.
| e | The exponent in a range between -8 to 7, inclusive. |
Definition at line 316 of file ExtendedUnit.hpp.
|
inline |
Returns the exponent for the meter (distance) dimension.
Definition at line 222 of file ExtendedUnit.hpp.
|
inline |
Sets the exponent for the meter (distance) dimension without range checking.
| e | The exponent in a range between -8 to 7, inclusive. |
Definition at line 362 of file ExtendedUnit.hpp.
|
inline |
Returns the exponent for the mole (amount of substance) dimension.
Definition at line 258 of file ExtendedUnit.hpp.
|
inline |
Sets the exponent for the mole (amount of substance) dimension without range checking.
| e | The exponent in a range between -8 to 7, inclusive. |
Definition at line 410 of file ExtendedUnit.hpp.
|
inline |
Returns the exponent for the mole (amount of substance) dimension.
Definition at line 192 of file ExtendedUnit.hpp.
|
inline |
Sets the exponent for the mole (amount of substance) dimension without range checking.
| e | The exponent in a range between -8 to 7, inclusive. |
Definition at line 324 of file ExtendedUnit.hpp.
| void duds::data::ExtendedUnit::offset | ( | float | o | ) |
Change the offset.
| o | The new offset. Is must not be subnormal, infinite, or NaN. |
| UnitRangeError | The offset value is beyond the bounds of the internal storage. |
Definition at line 14 of file ExtendedUnit.cpp.
| void duds::data::ExtendedUnit::offset | ( | double | o | ) |
Change the offset.
| o | The new offset. Is must not be subnormal, infinite, or NaN. |
| UnitRangeError | The offset value is beyond the bounds of the internal storage. |
Definition at line 30 of file ExtendedUnit.cpp.
| double duds::data::ExtendedUnit::offset | ( | ) | const |
Query the offset as a double.
Definition at line 41 of file ExtendedUnit.cpp.
Referenced by ExtendedUnit().
| float duds::data::ExtendedUnit::offsetf | ( | ) | const |
Query the offset as a float.
Definition at line 25 of file ExtendedUnit.cpp.
Referenced by ExtendedUnit().
|
inline |
Unit objects are compared using the u member.
Definition at line 593 of file ExtendedUnit.hpp.
| const ExtendedUnit duds::data::ExtendedUnit::operator* | ( | const Unit & | U | ) | const |
Combines two units into a new unit.
| UnitRangeError | A resulting exponent is out of range. |
Definition at line 47 of file ExtendedUnit.cpp.
Referenced by unitless().
| ExtendedUnit & duds::data::ExtendedUnit::operator*= | ( | const Unit & | U | ) |
Combines two units into a new unit.
| UnitRangeError | A 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().
| const ExtendedUnit duds::data::ExtendedUnit::operator/ | ( | const Unit & | U | ) | const |
Combines two units into a new unit.
| UnitRangeError | A resulting exponent is out of range. |
Definition at line 52 of file ExtendedUnit.cpp.
Referenced by unitless().
| ExtendedUnit & duds::data::ExtendedUnit::operator/= | ( | const Unit & | U | ) |
Combines two units into a new unit.
| UnitRangeError | A 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().
|
inline |
Unit objects are compared using the u member.
Definition at line 563 of file ExtendedUnit.hpp.
|
inline |
Unit objects are compared using the u member.
Definition at line 575 of file ExtendedUnit.hpp.
| 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().
|
inline |
Unit objects are compared using the u member.
Definition at line 587 of file ExtendedUnit.hpp.
|
inline |
Unit objects are compared using the u member.
Definition at line 569 of file ExtendedUnit.hpp.
|
inline |
Unit objects are compared using the u member.
Definition at line 581 of file ExtendedUnit.hpp.
|
inline |
Returns the exponent for radians (angle).
Definition at line 270 of file ExtendedUnit.hpp.
|
inline |
Sets the exponent for radians (angle) without range checking.
| e | The exponent in a range between -2 to 1, inclusive. |
Definition at line 425 of file ExtendedUnit.hpp.
|
inline |
Returns the exponent for radians (angle).
Definition at line 204 of file ExtendedUnit.hpp.
|
inline |
Sets the exponent for radians (angle) without range checking.
| e | The exponent in a range between -2 to 1, inclusive. |
Definition at line 339 of file ExtendedUnit.hpp.
|
inline |
Returns the exponent for the second (time) dimension.
Definition at line 264 of file ExtendedUnit.hpp.
|
inline |
Sets the exponent for the second (time) dimension without range checking.
| e | The exponent in a range between -8 to 7, inclusive. |
Definition at line 418 of file ExtendedUnit.hpp.
|
inlineprivate |
Definition at line 64 of file ExtendedUnit.hpp.
|
inline |
Returns the exponent for the second (time) dimension.
Definition at line 198 of file ExtendedUnit.hpp.
Referenced by s().
|
inline |
Sets the exponent for the second (time) dimension without range checking.
| e | The exponent in a range between -8 to 7, inclusive. |
Definition at line 332 of file ExtendedUnit.hpp.
|
inline |
Sets the exponent for the ampere (current) dimension.
| e | The exponent in a range between -8 to 7, inclusive. |
| UnitRangeError | The exponent e is out of range. |
Definition at line 512 of file ExtendedUnit.hpp.
|
inline |
Sets the exponent for the ampere (current) dimension.
| e | The exponent in a range between -8 to 7, inclusive. |
| UnitRangeError | The exponent e is out of range. |
Definition at line 440 of file ExtendedUnit.hpp.
|
inline |
Sets the exponent for the candela (luminous intensity) dimension.
| e | The exponent in a range between -8 to 7, inclusive. |
| UnitRangeError | The exponent e is out of range. |
Definition at line 448 of file ExtendedUnit.hpp.
|
inline |
Sets the exponent for the kelvin (thermodynamic temperature) dimension.
| e | The exponent in a range between -8 to 7, inclusive. |
| UnitRangeError | The exponent e is out of range. |
Definition at line 456 of file ExtendedUnit.hpp.
|
inline |
Sets the exponent for the kilogram (mass) dimension.
| e | The exponent in a range between -8 to 7, inclusive. |
| UnitRangeError | The exponent e is out of range. |
Definition at line 464 of file ExtendedUnit.hpp.
|
inline |
Sets the exponent for the meter (distance) dimension.
| e | The exponent in a range between -8 to 7, inclusive. |
| UnitRangeError | The exponent e is out of range. |
Definition at line 472 of file ExtendedUnit.hpp.
|
inline |
Sets the exponent for the meter (distance) dimension.
| e | The exponent in a range between -8 to 7, inclusive. |
| UnitRangeError | The exponent e is out of range. |
Definition at line 520 of file ExtendedUnit.hpp.
|
inline |
Sets the exponent for the mole (amount of substance) dimension.
| e | The exponent in a range between -8 to 7, inclusive. |
| UnitRangeError | The exponent e is out of range. |
Definition at line 480 of file ExtendedUnit.hpp.
|
inline |
Sets the exponent for radians (angle).
| e | The exponent in a range between -2 to 1, inclusive. |
| UnitRangeError | The exponent e is out of range. |
Definition at line 496 of file ExtendedUnit.hpp.
|
inline |
Sets the exponent for the second (time) dimension.
| e | The exponent in a range between -8 to 7, inclusive. |
| UnitRangeError | The exponent e is out of range. |
Definition at line 488 of file ExtendedUnit.hpp.
|
inline |
Sets the exponent for steradians (solid angle).
| e | The exponent in a range between -2 to 1, inclusive. |
| UnitRangeError | The exponent e is out of range. |
Definition at line 504 of file ExtendedUnit.hpp.
|
inline |
Returns the exponent for steradians (solid angle).
Definition at line 276 of file ExtendedUnit.hpp.
|
inline |
Sets the exponent for steradians (solid angle) without range checking.
| e | The exponent in a range between -2 to 1, inclusive. |
Definition at line 432 of file ExtendedUnit.hpp.
|
inline |
Returns the exponent for steradians (solid angle).
Definition at line 210 of file ExtendedUnit.hpp.
|
inline |
Sets the exponent for steradians (solid angle) without range checking.
| e | The exponent in a range between -2 to 1, inclusive. |
Definition at line 346 of file ExtendedUnit.hpp.
|
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.
|
friend |
Definition at line 62 of file ExtendedUnit.hpp.
| union { ... } |
| int duds::data::ExtendedUnit::exp |
| unsigned int duds::data::ExtendedUnit::mant |
| 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.
| 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>=().
| int duds::data::ExtendedUnit::sign |
|
private |
Definition at line 27 of file ExtendedUnit.hpp.
Referenced by base(), operator!=(), operator*(), operator*=(), operator/(), operator/=(), operator<(), operator<=(), operator=(), operator==(), operator>(), and operator>=().