CARMA C++
carma::services::Units Class Reference

This class is based on the GNU units library. More...

#include <carma/services/Units.h>

Public Member Functions

double centi () const
 times one hundredth More...
 
double convert (const char *convertFrom, const char *convertTo) const
 Convert value and units to new units. More...
 
double convert (const std::string &convertFrom, const std::string &convertTo) const
 
double convert (double value, const char *convertFrom, const char *convertTo) const
 Convert a value from one unit to another conformablie unit. More...
 
double convert (double value, const std::string &convertFrom, const std::string &convertTo) const
 
double deca () const
 times ten More...
 
double deci () const
 times one tenth More...
 
double giga () const
 times one billion More...
 
double hecto () const
 times one hundred More...
 
double kilo () const
 times one thousand More...
 
double mega () const
 times one million More...
 
double micro () const
 times one million More...
 
double milli () const
 times one thousandth More...
 
double nano () const
 times one billionth More...
 
template<typename T >
int numericLimit ()
 
double pico () const
 times one trillionth More...
 
double tera () const
 times one trillion More...
 
 Units ()
 Constructor. More...
 
virtual ~Units ()
 Destructor. More...
 

Detailed Description

This class is based on the GNU units library.

See Also
http://www.cam.cornell.edu/~adrian/units.html

Definition at line 46 of file Units.h.

Constructor & Destructor Documentation

carma::services::Units::Units ( )

Constructor.

virtual carma::services::Units::~Units ( )
virtual

Destructor.

Member Function Documentation

double carma::services::Units::centi ( ) const

times one hundredth

Definition at line 126 of file Units.h.

double carma::services::Units::convert ( const char *  convertFrom,
const char *  convertTo 
) const

Convert value and units to new units.

This method will convert a value and units to a value in any conformable units. If no value is given, the value is understood to be unity. convert("radian","degree") // convert 1 radian to degrees
convert("2*pi radians","degrees")
convert("5 jansky","W/m^2 Hz")
convert("miles","quarts") // throws ConformabilityException
Note the unit type understands plurals, so that "radians" is the same as "radian". (However "rad" would mean the radiation dosage unit!)

Parameters
convertFromcurrent unit type (and possibly a value)
convertTounit type desired
Returns
value of conversion in new units
Exceptions
ConformabilityExceptionif the convertFrom and convertTo units are not conformable (e.g. meters to joules).
See Also
GNU units man pages
double carma::services::Units::convert ( double  value,
const char *  convertFrom,
const char *  convertTo 
) const

Convert a value from one unit to another conformablie unit.

Parameters
valueThe value of current unit type
convertFromThe current unit type
convertToThe unit type desired
Returns
value of conversion in new units
Exceptions
ConformabilityExceptionif the convertFrom and convertTo units are not conformable (e.g. meters to joules).
double carma::services::Units::deca ( ) const

times ten

Definition at line 120 of file Units.h.

double carma::services::Units::deci ( ) const

times one tenth

Definition at line 123 of file Units.h.

double carma::services::Units::giga ( ) const

times one billion

Definition at line 108 of file Units.h.

double carma::services::Units::hecto ( ) const

times one hundred

Definition at line 117 of file Units.h.

double carma::services::Units::kilo ( ) const

times one thousand

Definition at line 114 of file Units.h.

double carma::services::Units::mega ( ) const

times one million

Definition at line 111 of file Units.h.

double carma::services::Units::micro ( ) const

times one million

Definition at line 132 of file Units.h.

double carma::services::Units::milli ( ) const

times one thousandth

Definition at line 129 of file Units.h.

double carma::services::Units::nano ( ) const

times one billionth

Definition at line 135 of file Units.h.

double carma::services::Units::pico ( ) const

times one trillionth

Definition at line 138 of file Units.h.

double carma::services::Units::tera ( ) const

times one trillion

Definition at line 105 of file Units.h.


The documentation for this class was generated from the following file: