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

The Temperature class represents a temperature in any unit. More...

#include <carma/services/Temperature.h>

Inheritance diagram for carma::services::Temperature:
carma::services::ConformableQuantity

Public Member Functions

double celsius () const
 Convenience method that returns the value of this temperature in Celsius. More...
 
double fahrenheit () const
 Convenience method that returns the value of this temperature in fahrenheit. More...
 
double kelvin () const
 Convenience method that returns the value of this temperature in Kelvin. More...
 
const Temperature operator+ (const Temperature &t) const
 Add two Temperatures. More...
 
Temperatureoperator+= (const Temperature &t)
 Increment temperature. More...
 
const Temperature operator- (const Temperature &t) const
 Subtract two temperatures. More...
 
Temperatureoperator-= (const Temperature &t)
 Decrement temperature. More...
 
bool operator< (const Temperature &t) const
 Compare two temperatures. More...
 
bool operator> (const Temperature &t) const
 Compare two temperature. More...
 
void reset (double value, const std::string &units)
 Override parent method. More...
 
 Temperature (double value, const std::string &units)
 Construct a Temperature given a value and units. More...
 
virtual ~Temperature ()
 Destructor. More...
 
- Public Member Functions inherited from carma::services::ConformableQuantity
 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 ConformableQuantityoperator+= (const ConformableQuantity &quantity)
 Add ConformableQuantity to itself. More...
 
virtual const ConformableQuantity operator- (const ConformableQuantity &quantity) const
 Subtract two ConformableQuantities. More...
 
virtual ConformableQuantityoperator-= (const ConformableQuantity &quantity)
 Subtract ConformableQuantity from itself. More...
 
virtual ~ConformableQuantity ()
 Destructor. More...
 

Additional Inherited Members

- Protected Attributes inherited from carma::services::ConformableQuantity
Units u_
 Used for converting between units. More...
 

Detailed Description

The Temperature class represents a temperature in any unit.

It uses the Units class internally to handle conversion of any temperature unit to any other temperature unit. For example,
Temperature t1(32,"F")
Temperature t2(0,"C")
both t1 and t2 represent the same physical quantity. Binary operations + and - are supported, as is the stream operation <<.

See Also
carma::services::ConformableQuantity

Definition at line 39 of file Temperature.h.

Constructor & Destructor Documentation

carma::services::Temperature::Temperature ( double  value,
const std::string &  units 
)

Construct a Temperature given a value and units.

Parameters
valueThe value of this temperature
unitsThe units of the value.
Exceptions
carma::util::IllegalArgumentExceptionif the value is converts to less than 0 on the Kelvin scale.
virtual carma::services::Temperature::~Temperature ( )
virtual

Destructor.

Member Function Documentation

double carma::services::Temperature::celsius ( ) const

Convenience method that returns the value of this temperature in Celsius.

Returns
temperature value in Celsius
double carma::services::Temperature::fahrenheit ( ) const

Convenience method that returns the value of this temperature in fahrenheit.

Returns
temperature value in fahrenheit
double carma::services::Temperature::kelvin ( ) const

Convenience method that returns the value of this temperature in Kelvin.

Returns
temperature value in Kelvin
const Temperature carma::services::Temperature::operator+ ( const Temperature t) const

Add two Temperatures.

Returns
a temperature with Kelvin units that is
Exceptions
ConformabilityException
Temperature& carma::services::Temperature::operator+= ( const Temperature t)

Increment temperature.

Returns
incremented temperature
const Temperature carma::services::Temperature::operator- ( const Temperature t) const

Subtract two temperatures.

Returns
a temperature with kelvin units
Exceptions
ConformabilityException
Temperature& carma::services::Temperature::operator-= ( const Temperature t)

Decrement temperature.

Returns
decremented temperature
bool carma::services::Temperature::operator< ( const Temperature t) const

Compare two temperatures.

Returns
boolean saying whether lhs temperature is less than rhs temperature
Exceptions
ConformabilityException
bool carma::services::Temperature::operator> ( const Temperature t) const

Compare two temperature.

Returns
boolean saying whether lhs temperature is greater than rhs temperature
Exceptions
ConformabilityException
void carma::services::Temperature::reset ( double  value,
const std::string &  units 
)
virtual

Override parent method.

Parameters
valueThe value of this temperature
unitsThe units of the value.
Exceptions
carma::util::IllegalArgumentExceptionif the value is converts to less than 0 on the Kelvin scale.

Reimplemented from carma::services::ConformableQuantity.


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