#include <OSQuantityVector.hpp>
Public Member Functions | |
Constructors and Destructors | |
OSQuantityVector (const Unit &units=Unit()) | |
OSQuantityVector (const Unit &units, unsigned n, double value=0.0) | |
OSQuantityVector (const Unit &units, const std::vector< double > &values) | |
OSQuantityVector (const std::vector< Quantity > &values) | |
OSQuantityVector (const OSQuantityVector &other) | |
OSQuantityVector & | operator= (const OSQuantityVector &other) |
Getters and Queries | |
Unit | units () const |
Returns a clone of this object's units. | |
UnitSystem | system () const |
Scale | scale () const |
std::vector< Quantity > | quantities () const |
Creates a vector of separate quantities. | |
std::vector< double > | values () const |
Returns the underlying values of this OSQuantityVector. | |
Quantity | getQuantity (unsigned i) const |
bool | empty () const |
Return value is equivalent to values().empty(). | |
unsigned | size () const |
Return value is equivalent to values().size(). | |
Setters | |
bool | setScale (int scaleExponent) |
Sets the scale to the one registered in ScaleFactory for 10^scaleExponent. | |
bool | setScale (const std::string &scaleAbbreviation) |
Sets the scale to the one registered in ScaleFactory under scaleAbbreviation. | |
void | push_back (Quantity q) |
Pushes q onto this vector if possible, otherwise throws. | |
void | pop_back () |
Removes the last value in this OSQuantityVector. | |
void | resize (unsigned n, double value=0.0) |
Changes the size of this OSQuantityVector to n, using value to fill in any newly created elements as necessary. | |
void | clear () |
Empties all values out of this OSQuantityVector. | |
Temperature Methods | |
Quantities that have units of temperature need several extra functions to distinguish between absolute and relative measures. | |
bool | isTemperature () const |
Returns true if units().optionalCast<TemperatureUnit>(). | |
bool | isAbsolute () const |
Throws if !units().optionalCast<TemperatureUnit>(). | |
bool | isRelative () const |
Throws if !units().optionalCast<TemperatureUnit>(). | |
void | setAsAbsolute () |
Set temperature as absolute. | |
void | setAsRelative () |
Set temperature as relative. | |
IP Methods | |
void | lbmToLbf () |
Conversions for pounds mass to pounds force. | |
void | lbfToLbm () |
Conversions for pounds mass to pounds force. | |
Mathematical Operators | |
OSQuantityVector & | operator+= (OSQuantityVector rVector) |
Adds rVector to this vector, if possible. | |
OSQuantityVector & | operator+= (Quantity rQuantity) |
Adds rQuantity to this vector element-wise, if possible. | |
OSQuantityVector & | operator-= (OSQuantityVector rVector) |
Subtracts rVector from this vector, if possible. | |
OSQuantityVector & | operator-= (Quantity rQuantity) |
Subtracts rQuantity from this vector element-wise, if possible. | |
OSQuantityVector & | operator*= (const Quantity &rQuantity) |
Multiplies all values of this vector by rQuantity. | |
OSQuantityVector & | operator/= (const Quantity &rQuantity) |
Divides all values of this vector by rQuantity. | |
OSQuantityVector & | operator*= (double d) |
Multiplies all values of this vector by d. | |
OSQuantityVector & | operator/= (double d) |
Divides all values of this vector by d. | |
Represents a vector of quantities all with the same units.
Provides performance improvements over directly operating on std::vector<Quantity>. 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).
openstudio::OSQuantityVector::OSQuantityVector | ( | const Unit & | units, |
unsigned | n, | ||
double | value = 0.0 ) |
openstudio::OSQuantityVector::OSQuantityVector | ( | const Unit & | units, |
const std::vector< double > & | values ) |
|
explicit |
openstudio::OSQuantityVector::OSQuantityVector | ( | const OSQuantityVector & | other | ) |
void openstudio::OSQuantityVector::clear | ( | ) |
Empties all values out of this OSQuantityVector.
Quantity openstudio::OSQuantityVector::getQuantity | ( | unsigned | i | ) | const |
bool openstudio::OSQuantityVector::isAbsolute | ( | ) | const |
Throws if !units().optionalCast<TemperatureUnit>().
bool openstudio::OSQuantityVector::isRelative | ( | ) | const |
Throws if !units().optionalCast<TemperatureUnit>().
bool openstudio::OSQuantityVector::isTemperature | ( | ) | const |
Returns true if units().optionalCast<TemperatureUnit>().
void openstudio::OSQuantityVector::lbfToLbm | ( | ) |
Conversions for pounds mass to pounds force.
These functions will throw if !units().optionalCast<IPUnit>().
void openstudio::OSQuantityVector::lbmToLbf | ( | ) |
Conversions for pounds mass to pounds force.
These functions will throw if !units().optionalCast<IPUnit>().
OSQuantityVector & openstudio::OSQuantityVector::operator*= | ( | const Quantity & | rQuantity | ) |
Multiplies all values of this vector by rQuantity.
OSQuantityVector & openstudio::OSQuantityVector::operator*= | ( | double | d | ) |
Multiplies all values of this vector by d.
OSQuantityVector & openstudio::OSQuantityVector::operator+= | ( | OSQuantityVector | rVector | ) |
Adds rVector to this vector, if possible.
Throws if vectors are of different size or units are different.
OSQuantityVector & openstudio::OSQuantityVector::operator+= | ( | Quantity | rQuantity | ) |
Adds rQuantity to this vector element-wise, if possible.
Throws if units are different.
OSQuantityVector & openstudio::OSQuantityVector::operator-= | ( | OSQuantityVector | rVector | ) |
Subtracts rVector from this vector, if possible.
Throws if vectors are of different size or units are different.
OSQuantityVector & openstudio::OSQuantityVector::operator-= | ( | Quantity | rQuantity | ) |
Subtracts rQuantity from this vector element-wise, if possible.
Throws if units are different.
OSQuantityVector & openstudio::OSQuantityVector::operator/= | ( | const Quantity & | rQuantity | ) |
Divides all values of this vector by rQuantity.
OSQuantityVector & openstudio::OSQuantityVector::operator/= | ( | double | d | ) |
Divides all values of this vector by d.
OSQuantityVector & openstudio::OSQuantityVector::operator= | ( | const OSQuantityVector & | other | ) |
void openstudio::OSQuantityVector::pop_back | ( | ) |
Removes the last value in this OSQuantityVector.
void openstudio::OSQuantityVector::push_back | ( | Quantity | q | ) |
Pushes q onto this vector if possible, otherwise throws.
std::vector< Quantity > openstudio::OSQuantityVector::quantities | ( | ) | const |
Creates a vector of separate quantities.
Note that it is better to do mathematical operations and convert units using OSOptionalQuantity. Only use this method once the values and units of this OSOptionalQuantity are fixed.
void openstudio::OSQuantityVector::resize | ( | unsigned | n, |
double | value = 0.0 ) |
Changes the size of this OSQuantityVector to n, using value to fill in any newly created elements as necessary.
Scale openstudio::OSQuantityVector::scale | ( | ) | const |
void openstudio::OSQuantityVector::setAsAbsolute | ( | ) |
Set temperature as absolute.
Throws if !units().optionalCast<TemperatureUnit>().
void openstudio::OSQuantityVector::setAsRelative | ( | ) |
Set temperature as relative.
Throws if !units().optionalCast<TemperatureUnit>().
bool openstudio::OSQuantityVector::setScale | ( | const std::string & | scaleAbbreviation | ) |
Sets the scale to the one registered in ScaleFactory under scaleAbbreviation.
bool openstudio::OSQuantityVector::setScale | ( | int | scaleExponent | ) |
Sets the scale to the one registered in ScaleFactory for 10^scaleExponent.
unsigned openstudio::OSQuantityVector::size | ( | ) | const |
UnitSystem openstudio::OSQuantityVector::system | ( | ) | const |
Unit openstudio::OSQuantityVector::units | ( | ) | const |
Returns a clone of this object's units.
std::vector< double > openstudio::OSQuantityVector::values | ( | ) | const |
Returns the underlying values of this OSQuantityVector.
|
related |
Non-member function that uses just two calls to QuantityConverter to convert an entire OSQuantityVector.
|
related |
Non-member function that uses just two calls to QuantityConverter to convert an entire OSQuantityVector.
|
related |
|
related |
|
related |
|
related |
|
related |
|
related |
|
related |
|
related |
|
related |
|
related |
|
related |
|
related |
|
related |
|
related |
|
related |
|
related |