Main Page   Class Hierarchy   Compound List   Compound Members  

SCOREC_UnitSystem::UnitVariable Class Template Reference

#include <UnitVariable.h>

List of all members.

Public Methods

 UnitVariable (T val, const Unit &)
 Constructor. Pass in the value plus the Unit.

 UnitVariable (T val)
 Construct variable with no unit.

 UnitVariable (T val, const SIBaseUnit &)
 UnitVariable (T val, const SIBaseUnit &, const SIBaseUnit &)
 UnitVariable (T val, const SIBaseUnit &, const SIBaseUnit &, const SIBaseUnit &)
 UnitVariable (T val, const SIBaseUnit &, const SIBaseUnit &, const SIBaseUnit &, const SIBaseUnit &)
 UnitVariable (T val, const SIBaseUnit &, const SIBaseUnit &, const SIBaseUnit &, const SIBaseUnit &, const SIBaseUnit &)
 UnitVariable (T val, const SIBaseUnit &, const SIBaseUnit &, const SIBaseUnit &, const SIBaseUnit &, const SIBaseUnit &, const SIBaseUnit &)
 UnitVariable (T val, const SIBaseUnit &, const SIBaseUnit &, const SIBaseUnit &, const SIBaseUnit &, const SIBaseUnit &, const SIBaseUnit &, const SIBaseUnit &)
 UnitVariable (T val, const SIBaseUnit &, const SIBaseUnit &, const SIBaseUnit &, const SIBaseUnit &, const SIBaseUnit &, const SIBaseUnit &, const SIBaseUnit &, const SIBaseUnit &)
 UnitVariable (T val, const SIBaseUnit &, const SIBaseUnit &, const SIBaseUnit &, const SIBaseUnit &, const SIBaseUnit &, const SIBaseUnit &, const SIBaseUnit &, const SIBaseUnit &, const SIBaseUnit &)
virtual ~UnitVariable ()
getValue () const
 Return the value of the object stored. The value will be given in the SI Base Units without any prefix (m,kg,s,A,K,mol,cl).

double getConversionFactor (const SIBaseUnit &) const
 return a conversion factor that can be used to convert the value given by getValue() to the unit/s passed in as arguments. The function will throw an exception of type UnitConversionError if the units requested are incompatible with the units stored for the object.

double getConversionFactor (const SIBaseUnit &,const SIBaseUnit &) const
double getConversionFactor (const SIBaseUnit &,const SIBaseUnit &, const SIBaseUnit &) const
double getConversionFactor (const SIBaseUnit &,const SIBaseUnit &, const SIBaseUnit &,const SIBaseUnit &) const
double getConversionFactor (const SIBaseUnit &,const SIBaseUnit &, const SIBaseUnit &,const SIBaseUnit &, const SIBaseUnit &) const
double getConversionFactor (const SIBaseUnit &,const SIBaseUnit &, const SIBaseUnit &,const SIBaseUnit &, const SIBaseUnit &,const SIBaseUnit &) const
Unit getUnit () const
void DumpDiagnostics () const
 DumpDiagnostics() dumps the object's state to standard output.


Detailed Description

template<typename T> class SCOREC_UnitSystem::UnitVariable

A UnitVariable is an object that stores a variable plus the unit that is associated with it. Constructor accept the base value plus one or more SI Base Units (meter, kilogram, second, ampere, kelvin,mole and candela). e.g to construct a variable of 5 Newton simply say: UnitVariable<double> var(5.0,kg(1),m(1),sec(-2)) // 5 kg*m/sec^2 There are also derived Units available, i.e. we could also have created the 5 Newton by saying: UnitVariable<double> var(5.0,Newton(1)); // 5 N (for more information on the SI Base Units see the class SIBaseUnit. The type over which UnitVariable is templated needs to have a member function T &T::operator *=(double) defined. That operator is needed so that UnitVariable can convert the templated variable to the desired units. (That means that integral types (except for double) are not an option).

To be able to return a value in a different unit than the SI base unit the function double getConversionFactor(...) is defined. It will take as the argument a number of SIBaseUnits with prefixes and will then return the factor with which the values of the stored object need to be multiplied to obtain the results in the requested unit. Note that there is a template specialization for pointers.


The documentation for this class was generated from the following file:
Generated at Mon Jul 23 09:36:17 2001 for SCOREC_UnitSystem by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001