Main Page   Modules   Class Hierarchy   Compound List   File List   Compound Members  

DimensionGroup Class Reference

Collaboration diagram for DimensionGroup:

Collaboration graph
[legend]
List of all members.

Public Methods

 DimensionGroup ( const char* name = 0 )
 DimensionGroup ( const char* name, vector<DimensionPower> dims )
 ~DimensionGroup ()
void setDimensions ( vector<DimensionPower> dims )
DimensionGroup* next () const
void name ( const char* )
char* name () const
bool operator== (const vector<DimensionPower>& pwr)
bool operator== (DimensionGroup other)
vector<DimensionPower>::const_iterator dpwrBegin () const
vector<DimensionPower>::const_iterator dpwrEnd () const
list<Unit*>::const_iterator unitBegin () const
list<Unit*>::const_iterator unitEnd () const
vector<DimensionPower>::iterator dpwrBegin ()
vector<DimensionPower>::iterator dpwrEnd ()
list<Unit*>::iterator unitBegin ()
list<Unit*>::iterator unitEnd ()

Static Public Methods

DimensionGroup* find ( const char* dgrp_name )
DimensionGroup* find ( const vector< DimensionPower>& dpwr )
const DimensionGroup* first ()

Protected Methods

void p_add ( Unit* )
void p_remove ( Unit* )

Protected Attributes

vector<DimensionPowerm_dims
list<Unit*> m_children
char* m_name
DimensionGroup* m_next

Static Protected Attributes

DimensionGroup* theDimensionGroups = 0

Friends

class  Unit
class  Quantity

Detailed Description

The DimensionGroup is a fraction of basic dimensions to powers (stored as a vector of DimensionPowers) that represent a unit, be it basic (such as mass) or complex (such as pressure). The DimensionGroup contains pointers to all the Unit objects that are members of that DimensionGroup. For example, the dimension group for "force" would point to "Newton [N]" and "pound-fource [lbf]".

Note that because there isn't any canonical form of the DimensionPowers representing a DimensionGroup, you can define multiple DimensionGroups that are equivalent. This may be changed later.

The constructor should be able to parse statements like "N m" to get "M^(1) L^(2) t^(-2)". In particular, spaces or "*" are equivalent to multiplication and "^" is exponentiation. There is no division (just use exponentiation and multiplication instead). There is no addition or subtraction, as that would not make sense.

Another interesting application of DimensionGroups is the representation of Dimensionless Parameters (like the Reynold's Number).

Also, wouldn't it be neat to be able to store any type (i.e., int, double, rational, ...) of number as a conversion factor between units? You could do this with templates so that you could declare something like Unit<double> velocity and also make up an exact arithmetic package and do something like Unit<ExactNumber> velocity, so that m/s would always be exactly converted to whatever other units you want.


Constructor & Destructor Documentation

DimensionGroup::DimensionGroup ( const char * name = 0 )
 

Create an "empty" dimension group.

Parameters:
name   the name of the group (i.e., "acceleration").

DimensionGroup::DimensionGroup ( const char * name,
vector< DimensionPower > dims )
 

Create a dimension group.

Parameters:
name   the name of the group (i.e., "acceleration").
dims   the dimensions of the group (i.e., "L t^-2").

A DimensionPower is a base dimension and its exponent. The vector of DimensionPower entries specifies which "axes" the group is measured along.

DimensionGroup::~DimensionGroup ( )
 

Destroy a dimension group. Should not normally occur in an application.


Member Function Documentation

vector< DimensionPower >::iterator DimensionGroup::dpwrBegin ( ) [inline]
 

Return the starting iterator for the defining DimensionPowers

vector< DimensionPower >::const_iterator DimensionGroup::dpwrBegin ( ) const [inline]
 

Return the starting iterator for the defining DimensionPowers

vector< DimensionPower >::iterator DimensionGroup::dpwrEnd ( ) [inline]
 

Return the ending iterator for the defining DimensionPowers

vector< DimensionPower >::const_iterator DimensionGroup::dpwrEnd ( ) const [inline]
 

Return the ending iterator for the defining DimensionPowers

DimensionGroup * DimensionGroup::find ( const vector< DimensionPower >& dpwr ) [static]
 

Find a DimensionGroup that matches the given vector of DimensionPowers

DimensionGroup * DimensionGroup::find ( const char * dgrp_name ) [static]
 

Find, in the list of all DimensionGroups, one matching the given name

const DimensionGroup * DimensionGroup::first ( ) [inline, static]
 

Return the first dimension group in the list of all dimension groups

char * DimensionGroup::name ( ) const [inline]
 

Return the name of the dimension group

void DimensionGroup::name ( const char * name )
 

Set the name of this group

DimensionGroup * DimensionGroup::next ( ) const [inline]
 

The next dimension group in a list of all of dimension groups

bool DimensionGroup::operator== ( DimensionGroup other ) [inline]
 

Test for equality. Only the names need match for equality.

bool DimensionGroup::operator== ( const vector< DimensionPower >& pwr )
 

See if a list of Dimension and power tuples matches this group.

void DimensionGroup::p_add ( Unit * unit ) [protected]
 

Add a unit to this group.

Add a unit that has this group's dimensions to the list of all such units that is maintained by the group.

void DimensionGroup::p_remove ( Unit * unit ) [protected]
 

Remove a unit from this group.

Parameters:
unit   the unit to be removed Remove a unit from this group's list of units. This should only be called by the unit's destructor.

void DimensionGroup::setDimensions ( vector< DimensionPower > dims )
 

Set the dimensions of this group

See also:
DimensionGroup::DimensionGroup( const char* name, const vector<DimensionPower> dims )

list< Unit *>::iterator DimensionGroup::unitBegin ( ) [inline]
 

Return the starting iterator for the associated Units

list< Unit *>::const_iterator DimensionGroup::unitBegin ( ) const [inline]
 

Return the starting iterator for the associated Units

list< Unit *>::iterator DimensionGroup::unitEnd ( ) [inline]
 

Return the ending iterator for the associated Units

list< Unit *>::const_iterator DimensionGroup::unitEnd ( ) const [inline]
 

Return the ending iterator for the associated Units


Member Data Documentation

list< Unit *> DimensionGroup::m_children [protected]
 

The set of all Unit objects that have dimensions matching this group

vector< DimensionPower > DimensionGroup::m_dims [protected]
 

The set of (Dimension, exponent) tuples representing this group

char * DimensionGroup::m_name [protected]
 

The name of this group

DimensionGroup * DimensionGroup::m_next [protected]
 

The next dimension group in a list of all dimension groups

DimensionGroup * DimensionGroup::theDimensionGroups = 0 [static, protected]
 

A list of all dimension groups used for searching and matching.


The documentation for this class was generated from the following files:
Citrus C++ Reference Manual  20010520