# MI - Fimex: MetNoFimex::Units Class Reference

# MetNoFimex::Units Class Reference

`#include <Units.h>`

List of all members.

## Public Member Functions

| Units ()
| Units (const Units &rhs)
Units & | operator= (const Units &rhs)
virtual | ~Units ()
void | convert (const std::string &from, const std::string &to, double &slope, double &offset) throw (UnitException)
bool | areConvertible (const std::string &unit1, const std::string &unit2) const throw (UnitException)
| test if two units are convertible to each others
bool | isTime (const std::string &timeUnit) const throw (UnitException)

## Static Public Member Functions

static bool | unload (bool force=false) throw (UnitException)

## Constructor & Destructor Documentation

MetNoFimex::Units::Units | ( |  | ) |

initialization of unit handling, i.e. parsing of unit file etc if required the unit file is installation-dependent on the underlying units-package (udunits or udunits2) and can be controlled through UDUNITS_PATH environment

MetNoFimex::Units::Units | ( | const Units & | rhs | ) |

virtual MetNoFimex::Units::~Units | ( |  | ) | `[virtual]`

## Member Function Documentation

Units& MetNoFimex::Units::operator= | ( | const Units & | rhs | ) |

void MetNoFimex::Units::convert | ( | const std::string & | from,
|  | const std::string & | to,
|  | double & | slope,
|  | double & | offset |
| ) |  |  | throw (UnitException)

calculate the linear unit conversion: newVal (in to unit) = oldVal (in from unit) * slope + offset

Parameters:

  | from | unit
  | to | unit
  | slope | return value of the slope
  | offset | return value of the offset

bool MetNoFimex::Units::areConvertible | ( | const std::string & | unit1,
|  | const std::string & | unit2 |
| ) |  |  | const throw (UnitException)

test if two units are convertible to each others

Parameters:

  | unit1 | first unit
  | unit2 | second unit

bool MetNoFimex::Units::isTime | ( | const std::string & | timeUnit | ) | const throw (UnitException)

static bool MetNoFimex::Units::unload | ( | bool | force = `false` | ) | throw (UnitException)`[static]`

Units initialize themselve on first using the default unix-file path and keep the internal datastructure until the end of the program, or this function is used.

Parameters:

  | force | unload units-setup, even if some objects exist, defaults to false

Returns:
  true if unloaded, false if there are still some objects using the internal data-structure.

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

- include/fimex/Units.h