MI - Fimex
Public Member Functions | Static Public Member Functions | Friends | List of all members
MetNoFimex::Units Class Reference

#include <fimex/Units.h>

Public Member Functions

 Units ()
 
 Units (const Units &rhs)
 
Unitsoperator= (const Units &rhs)
 
virtual ~Units ()
 
void convert (const std::string &from, const std::string &to, double &slope, double &offset)
 
boost::shared_ptr< UnitsConvertergetConverter (const std::string &from, const std::string &to)
 
bool areConvertible (const std::string &unit1, const std::string &unit2) const
 test if two units are convertible to each others More...
 
bool isTime (const std::string &timeUnit) const
 test if unit is a time More...
 

Static Public Member Functions

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

Friends

class TimeUnit
 

Detailed Description

The class Units describes a units-system, not a single unit. Different units can be compared and converted if comparable within the system.

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

bool MetNoFimex::Units::areConvertible ( const std::string unit1,
const std::string unit2 
) const

test if two units are convertible to each others

Parameters
unit1first unit
unit2second unit
void MetNoFimex::Units::convert ( const std::string from,
const std::string to,
double &  slope,
double &  offset 
)

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

Parameters
fromunit
tounit
slopereturn value of the slope
offsetreturn value of the offset
Exceptions
UnitException
Warning
The slope and offset are only useful when the units are linearly convertible.
boost::shared_ptr<UnitsConverter> MetNoFimex::Units::getConverter ( const std::string from,
const std::string to 
)

Get a UnitsConverter which translates from 'from' unit to 'to' unit.

Parameters
from
to
Returns
a UnitsConverter object
Exceptions
UnitException
bool MetNoFimex::Units::isTime ( const std::string timeUnit) const

test if unit is a time

Parameters
timeUnit
Units& MetNoFimex::Units::operator= ( const Units rhs)
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
forceunload 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.

Friends And Related Function Documentation

friend class TimeUnit
friend

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