Units< M, L, T, K, I > Class Template Reference

Unit Checking/tracking Class. More...

#include <units.h>

Collaboration diagram for Units< M, L, T, K, I >:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 Units ()
 Units (const Units &u)
 Units (const Measurement &m)
 operator Measurement () const
const Unitsoperator= (const Units &u)
Units operator* (const double d) const
Units operator/ (const double d) const
const Unitsoperator*= (const double d)
const Unitsoperator/= (const double d)
Units operator+ (const Units &u) const
Units operator- (const Units &u) const
Unitsoperator+= (const Units &u)
Unitsoperator-= (const Units &u)
Units operator- () const
bool operator== (const Units &u) const
 Equality.
bool operator!= (const Units &u) const
 Inequality.
bool operator< (const Units &u) const
 Less-than.
bool operator<= (const Units &u) const
 Less-or-equal.
bool operator> (const Units &u) const
 Greater-than.
bool operator>= (const Units &u) const
 Greater-or-equal.
 operator double () const
double getRawValue () const
template<int m, int l, int t, int k, int i>
Units< M-m, L-l, T-t, K-k, I-i > operator/ (const Units< m, l, t, k, i > &u2) const
 Division.
template<int n>
Units< M *n, L *n, T *n, K *n,
I *n > 
ipow () const
 Integer Powers.
template<>
 operator double () const

Static Public Member Functions

static Units sqrt (const Units< 2 *M, 2 *L, 2 *T, 2 *K, 2 *I > u)
 Square root (not such nice syntax).


Detailed Description

template<int M, int L = 0, int T = 0, int K = 0, int I = 0>
class Units< M, L, T, K, I >

Unit Checking/tracking Class.

Purpose: Template class to create a 'Units' data type.

Original Author: Christopher Rettig ( rettigcd@bigfoot.com ) (This is not the original version)

Dev platform:

Tested on:

Todo:
Get the units stuff working with a specific units-tracking flag. Should be possible to say that all pressures should be output in MPa, all temperatures be output in C, etc etc.
See also:
http://www.embedded.com/shared/printableArticle.jhtml?articleID=9900094
http://www.embedded.com/code/2001code.htm
http://www.experts-exchange.com/Programming/Programming_Languages/Cplusplus/Q_21215508.html
http://www.experts-exchange.com/Programming/Programming_Languages/Cplusplus/Q_21199495.html
Examples:

/home/john/freesteam/b13curve.h, /home/john/freesteam/b23curve.h, and /home/john/freesteam/satcurve.h.


Constructor & Destructor Documentation

template<int M, int L = 0, int T = 0, int K = 0, int I = 0>
Units< M, L, T, K, I >::Units (  )  [inline]

template<int M, int L = 0, int T = 0, int K = 0, int I = 0>
Units< M, L, T, K, I >::Units ( const Units< M, L, T, K, I > &  u  )  [inline]

template<int M, int L, int T, int K, int I>
Units< M, L, T, K, I >::Units ( const Measurement m  )  [inline]


Member Function Documentation

template<int M, int L, int T, int K, int I>
Units< M, L, T, K, I >::operator Measurement (  )  const [inline]

template<int M, int L = 0, int T = 0, int K = 0, int I = 0>
const Units& Units< M, L, T, K, I >::operator= ( const Units< M, L, T, K, I > &  u  )  [inline]

template<int M, int L = 0, int T = 0, int K = 0, int I = 0>
Units Units< M, L, T, K, I >::operator* ( const double  d  )  const [inline]

template<int M, int L = 0, int T = 0, int K = 0, int I = 0>
Units Units< M, L, T, K, I >::operator/ ( const double  d  )  const [inline]

template<int M, int L = 0, int T = 0, int K = 0, int I = 0>
const Units& Units< M, L, T, K, I >::operator*= ( const double  d  )  [inline]

template<int M, int L = 0, int T = 0, int K = 0, int I = 0>
const Units& Units< M, L, T, K, I >::operator/= ( const double  d  )  [inline]

template<int M, int L = 0, int T = 0, int K = 0, int I = 0>
Units Units< M, L, T, K, I >::operator+ ( const Units< M, L, T, K, I > &  u  )  const [inline]

template<int M, int L = 0, int T = 0, int K = 0, int I = 0>
Units Units< M, L, T, K, I >::operator- ( const Units< M, L, T, K, I > &  u  )  const [inline]

template<int M, int L = 0, int T = 0, int K = 0, int I = 0>
Units& Units< M, L, T, K, I >::operator+= ( const Units< M, L, T, K, I > &  u  )  [inline]

template<int M, int L = 0, int T = 0, int K = 0, int I = 0>
Units& Units< M, L, T, K, I >::operator-= ( const Units< M, L, T, K, I > &  u  )  [inline]

template<int M, int L = 0, int T = 0, int K = 0, int I = 0>
Units Units< M, L, T, K, I >::operator- (  )  const [inline]

template<int M, int L = 0, int T = 0, int K = 0, int I = 0>
bool Units< M, L, T, K, I >::operator== ( const Units< M, L, T, K, I > &  u  )  const [inline]

Equality.

template<int M, int L = 0, int T = 0, int K = 0, int I = 0>
bool Units< M, L, T, K, I >::operator!= ( const Units< M, L, T, K, I > &  u  )  const [inline]

Inequality.

template<int M, int L = 0, int T = 0, int K = 0, int I = 0>
bool Units< M, L, T, K, I >::operator< ( const Units< M, L, T, K, I > &  u  )  const [inline]

Less-than.

template<int M, int L = 0, int T = 0, int K = 0, int I = 0>
bool Units< M, L, T, K, I >::operator<= ( const Units< M, L, T, K, I > &  u  )  const [inline]

Less-or-equal.

template<int M, int L = 0, int T = 0, int K = 0, int I = 0>
bool Units< M, L, T, K, I >::operator> ( const Units< M, L, T, K, I > &  u  )  const [inline]

Greater-than.

template<int M, int L = 0, int T = 0, int K = 0, int I = 0>
bool Units< M, L, T, K, I >::operator>= ( const Units< M, L, T, K, I > &  u  )  const [inline]

Greater-or-equal.

template<int M, int L = 0, int T = 0, int K = 0, int I = 0>
Units< M, L, T, K, I >::operator double (  )  const [inline]

template<int M, int L = 0, int T = 0, int K = 0, int I = 0>
double Units< M, L, T, K, I >::getRawValue (  )  const [inline]

template<int M, int L = 0, int T = 0, int K = 0, int I = 0>
template<int m, int l, int t, int k, int i>
Units<M-m,L-l,T-t,K-k,I-i> Units< M, L, T, K, I >::operator/ ( const Units< m, l, t, k, i > &  u2  )  const [inline]

Division.

SWIG can't handle the following, so this lot can't be wrapped easily, alas :-(

template<int M, int L = 0, int T = 0, int K = 0, int I = 0>
template<int n>
Units<M*n,L*n,T*n,K*n,I*n> Units< M, L, T, K, I >::ipow (  )  const [inline]

Integer Powers.

Usage should be something like...

                           Temperature T = 300. * Kelvin;
                           HeatFlux Q = SIGMA_C * ( T.pow<4>() - (300.*Kelvin).pow<4>())

template<int M, int L = 0, int T = 0, int K = 0, int I = 0>
static Units Units< M, L, T, K, I >::sqrt ( const Units< 2 *M, 2 *L, 2 *T, 2 *K, 2 *I >  u  )  [inline, static]

Square root (not such nice syntax).

Usage like this:

                                Area ha = (100. * metre)*(100. * metre);
                                Length side = Length::sqrt(ha);

template<>
Units< 0, 0, 0, 0, 0 >::operator double (  )  const [inline]

Only defined for dimensionless values!


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

Generated on Tue Feb 10 18:37:37 2009 for freesteam by  doxygen 1.5.6