#include "OSQuantityVector.hpp"
Public Member Functions | |
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) |
Unit | units () const |
UnitSystem | system () const |
Scale | scale () const |
std::vector< Quantity > | quantities () const |
std::vector< double > | values () const |
Quantity | getQuantity (unsigned i) const |
bool | empty () const |
unsigned | size () const |
bool | setScale (int scaleExponent) |
bool | setScale (const std::string &scaleAbbreviation) |
void | push_back (Quantity q) |
void | pop_back () |
void | resize (unsigned n, double value=0.0) |
void | clear () |
bool | isTemperature () const |
bool | isAbsolute () const |
bool | isRelative () const |
void | setAsAbsolute () |
void | setAsRelative () |
void | lbmToLbf () |
void | lbfToLbm () |
OSQuantityVector & | operator+= (OSQuantityVector rVector) |
OSQuantityVector & | operator+= (Quantity rQuantity) |
OSQuantityVector & | operator-= (OSQuantityVector rVector) |
OSQuantityVector & | operator-= (Quantity rQuantity) |
OSQuantityVector & | operator*= (const Quantity &rQuantity) |
OSQuantityVector & | operator/= (const Quantity &rQuantity) |
OSQuantityVector & | operator*= (double d) |
OSQuantityVector & | operator/= (double 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 | ( | int | scaleExponent | ) |
Sets the scale to the one registered in ScaleFactory for 10^scaleExponent.
bool openstudio::OSQuantityVector::setScale | ( | const std::string & | scaleAbbreviation | ) |
Sets the scale to the one registered in ScaleFactory under scaleAbbreviation.
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 |