#include "Quantity.hpp"
Public Member Functions | |
Quantity (const UnitSystem &system=UnitSystem::Mixed) | |
Quantity (double value, const UnitSystem &system=UnitSystem::Mixed) | |
Quantity (double value, const Unit &units) | |
Quantity (const Quantity &q) | |
Quantity & | operator= (const Quantity &q) |
virtual | ~Quantity () |
double | value () const |
void | setValue (double newValue) |
Unit | units () const |
UnitSystem | system () const |
bool | isTemperature () const |
std::vector< std::string > | baseUnits () const |
int | baseUnitExponent (const std::string &baseUnit) const |
void | setBaseUnitExponent (const std::string &baseUnit, int exponent) |
std::string | standardUnitsString (bool withScale=true) const |
std::string | prettyUnitsString (bool withScale=true) const |
void | setPrettyUnitsString (const std::string &str) |
Scale | scale () const |
bool | setScale (int scaleExponent) |
bool | setScale (const std::string &scaleAbbreviation) |
bool | isAbsolute () const |
bool | isRelative () const |
void | setAsAbsolute () |
void | setAsRelative () |
void | lbmToLbf () |
void | lbfToLbm () |
Quantity & | operator+= (const Quantity &rQuantity) |
Quantity & | operator-= (const Quantity &rQuantity) |
Quantity & | operator*= (const Quantity &rQuantity) |
Quantity & | operator/= (const Quantity &rQuantity) |
Quantity & | operator*= (double d) |
Quantity & | operator/= (double d) |
Quantity & | pow (int expNum, int expDenom=1) |
Protected Attributes | |
Unit | m_units |
double | m_value |
Friends | |
std::ostream & | operator<< (std::ostream &os, const Quantity &q) |
Related Functions | |
std::ostream & | operator<< (std::ostream &os, const Quantity &q) |
typedef boost::optional< Quantity > | OptionalQuantity |
typedef std::vector< Quantity > | QuantityVector |
Quantity class defines value, unit pairs.
Units are set at construction and are modified by arithmetic operations. The constructors and assignment operator ensure that this class behaves as "plain old data" (POD) by cloning any units information (to avoid multiple objects pointing to the exact same unit data).
|
explicit |
|
explicit |
openstudio::Quantity::Quantity | ( | double | value, |
const Unit & | units | ||
) |
openstudio::Quantity::Quantity | ( | const Quantity & | q | ) |
|
inlinevirtual |
int openstudio::Quantity::baseUnitExponent | ( | const std::string & | baseUnit | ) | const |
Base unit exponent getter.
Returns 0 if baseUnit not present.
std::vector<std::string> openstudio::Quantity::baseUnits | ( | ) | const |
Vector of base units available to the Quantity.
bool openstudio::Quantity::isAbsolute | ( | ) | const |
Throws if !units().optionalCast<TemperatureUnit>().
bool openstudio::Quantity::isRelative | ( | ) | const |
Throws if !units().optionalCast<TemperatureUnit>().
bool openstudio::Quantity::isTemperature | ( | ) | const |
Returns true if units().optionalCast<TemperatureUnit>().
void openstudio::Quantity::lbfToLbm | ( | ) |
Conversions for pounds mass to pounds force.
These functions will throw if !units().optionalCast<IPUnit>().
void openstudio::Quantity::lbmToLbf | ( | ) |
Conversions for pounds mass to pounds force.
These functions will throw if !units().optionalCast<IPUnit>().
Multiply and assign operator.
Throws if Quantity is a particular system and rQuantity is not the same system.
Quantity& openstudio::Quantity::operator*= | ( | double | d | ) |
Multiply by double.
No impact to units or scale. Does not throw.
Add and assign operator.
Throws if units are not equal.
Subtract and assign operator.
Throws if units are not equal.
Divide and assign operator.
Throws if Quantity is a particular system and rQuantity is not the same system.
Quantity& openstudio::Quantity::operator/= | ( | double | d | ) |
Divide by double.
No impact to units or scale. Does not throw.
Raise Quantity to a rational power.
Throws openstudio::Exception if expDenom is not a common divisor for all baseUnit and scale exponents. Returned scale exponent may differ from expectation based on initialization of openstudio::ScaleFactory, see Scale operators declared in ScaleFactory.hpp.
std::string openstudio::Quantity::prettyUnitsString | ( | bool | withScale = true | ) | const |
Pretty string for this quantity's units.
For instance N = kg*m/s^2.
void openstudio::Quantity::setAsAbsolute | ( | ) |
Set temperature as absolute.
Throws if !units().optionalCast<TemperatureUnit>().
void openstudio::Quantity::setAsRelative | ( | ) |
Set temperature as relative.
Throws if !units().optionalCast<TemperatureUnit>().
void openstudio::Quantity::setBaseUnitExponent | ( | const std::string & | baseUnit, |
int | exponent | ||
) |
void openstudio::Quantity::setPrettyUnitsString | ( | const std::string & | str | ) |
Sets the prettystring for this Quantity's m_units.
openstudio::Unit attempts to keep up with prettyStrings, but makes no promises. Precondition: isCompoundUnit(str). Otherwise throws.
bool openstudio::Quantity::setScale | ( | int | scaleExponent | ) |
Sets the scale to the one registered in ScaleFactory for 10^scaleExponent.
bool openstudio::Quantity::setScale | ( | const std::string & | scaleAbbreviation | ) |
Sets the scale to the one registered in ScaleFactory under scaleAbbreviation.
void openstudio::Quantity::setValue | ( | double | newValue | ) |
Value setter.
std::string openstudio::Quantity::standardUnitsString | ( | bool | withScale = true | ) | const |
Units in string form.
LaTeX mathematical formatting–_ for subscripting, ^ for superscripting. Curly braces {} are used for grouping.
UnitSystem openstudio::Quantity::system | ( | ) | const |
double openstudio::Quantity::value | ( | ) | const |
|
friend |
|
related |
|
related |
|
related |
|
protected |
|
protected |