CARMA C++
|
The ConformableQuantity class can represent any quantity that can be expressed in many units. More...
#include <carma/services/ConformableQuantity.h>
Public Member Functions | |
ConformableQuantity (double value, const std::string &units) | |
Construct an ConformableQuantity given a value and units. More... | |
virtual double | convert (const std::string &convertTo) const |
Converts this quantity to any conformable units. More... | |
virtual std::string | getUnits () const |
double | getValue () const |
virtual const ConformableQuantity | operator+ (const ConformableQuantity &quantity) const |
Add two ConformableQuantities. More... | |
virtual ConformableQuantity & | operator+= (const ConformableQuantity &quantity) |
Add ConformableQuantity to itself. More... | |
virtual const ConformableQuantity | operator- (const ConformableQuantity &quantity) const |
Subtract two ConformableQuantities. More... | |
virtual ConformableQuantity & | operator-= (const ConformableQuantity &quantity) |
Subtract ConformableQuantity from itself. More... | |
virtual void | reset (double value, const std::string &units) |
Reset method to change value and/or units. More... | |
virtual | ~ConformableQuantity () |
Destructor. More... | |
Protected Attributes | |
Units | u_ |
Used for converting between units. More... | |
The ConformableQuantity class can represent any quantity that can be expressed in many units.
It is meant to be subclassed to represent specific physical quantities like angle and distance. It uses the carma::services::Units class internally to handle conversion of any angular unit to any other angular unit. Binary operations + and - are supported, as is the stream operation <<.
Definition at line 34 of file ConformableQuantity.h.
|
explicit |
Construct an ConformableQuantity given a value and units.
value | The value of this quantity |
units | The units of the value. |
|
virtual |
Destructor.
|
virtual |
Converts this quantity to any conformable units.
This method is virtual in case subclasses need to munge the input variable for conformability. (e.g. HourAngle)
convertTo | A string representing the units to convert to. |
ConformabilityException |
Reimplemented in carma::services::HourAngle.
|
virtual |
Reimplemented in carma::services::HourAngle.
double carma::services::ConformableQuantity::getValue | ( | ) | const |
Definition at line 66 of file ConformableQuantity.h.
|
virtual |
Add two ConformableQuantities.
ConformabilityException |
|
virtual |
Add ConformableQuantity to itself.
ConformabilityException |
|
virtual |
Subtract two ConformableQuantities.
ConformabilityException |
|
virtual |
Subtract ConformableQuantity from itself.
ConformabilityException |
|
virtual |
Reset method to change value and/or units.
This method is needed meant so that HourAngle can reassign "hours" to be "circle (hours/day)" so that Units will work transparently. note: no longer protected since lack of default constructor and unit specification insures conformability
value | The value of this quantity |
units | The units of the value. |
Reimplemented in carma::services::HourAngle, and carma::services::Temperature.
|
protected |
Used for converting between units.
Definition at line 128 of file ConformableQuantity.h.