Main Page   Modules   Class Hierarchy   Compound List   File List   Compound Members  

Unit Class Reference

Represent a specific scale of measurement for a DimensionGroup. More...

Collaboration diagram for Unit:

Collaboration graph
[legend]
List of all members.

Public Methods

 Unit ( const char* name, const char* abbr, double scale, DimensionGroup* dgrp )
 ~Unit ()
void avoid ( const bool& state )
bool avoid ()
void prefix ( const bool& state )
bool prefix ()
void one ( const bool& state )
bool one ()
void offset ( double val )
bool offsetPolicy ()
double offsetValue ()
void plural ( const char* name )
void plural ( int type )
int pluralPolicy ()
char* pluralForm ()
char* name ()
char* abbr ()
DimensionGroupdgrp ()
Unit* next ()
double scale ()
bool operator== (Unit other)

Static Public Methods

Unit* dimensionless ()
Unit* find ( const char* )
Unit* findByFullName ( const char* )
bool initialize ( const char* init=0 )
Unit* first ()

Protected Attributes

char* m_name
char* m_abbr
double m_scale
double m_offsetVal
bool m_offsetPolicy
DimensionGroupm_dgrp
bool m_avoid
bool m_one
bool m_prefix
int m_pluralPolicy
char* m_pluralName
Unit* m_next

Static Protected Attributes

Unit* s_allUnits = 0
Unit* s_dimensionless = 0

Friends

class  UnitConfParserState

Detailed Description

Represent a specific scale of measurement for a DimensionGroup.

The Unit class represents a set of scales along each Dimension in the DimensionGroup that it belongs to. For instance, the Dimensions mass (M), length (L), and time (t) can be grouped into the DimensionGroup named "force" as M L t^-2. However, that's not enough information to specify how to go measure a force! In addition to the dimensions, we must know the relative scale along each axis. Force could be measured in Newtons or pounds-force. In the case of the Unit named Newton, the scales along the axes are kilograms, meters, and seconds.


Constructor & Destructor Documentation

Unit::Unit ( const char * name,
const char * abbr,
double scale,
DimensionGroup * dgrp )
 

Constructor

Unit::~Unit ( )
 

Destructor


Member Function Documentation

bool Unit::avoid ( ) [inline]
 

Return whether this unit should be avoided in output.

void Unit::avoid ( const bool & state ) [inline]
 

Indicate that this unit should be avoided in output.

Unit * Unit::dimensionless ( ) [static]
 

Return the Unit that has no dimension

Unit * Unit::find ( const char * unit_abbr ) [static]
 

Find a unit in the list of all units, given a text string containing the abbreviation of a unit.

Unit * Unit::findByFullName ( const char * unit_name ) [static]
 

Find a unit in the list of all units, given a text string containing the name or plural form of a unit.

Unit * Unit::first ( ) [static]
 

Return the first unit in a list of all units.

bool Unit::initialize ( const char * config = 0 ) [static]
 

Initialize all dimensions and units from a file. The argument is the file to use for the initialization. You may pass NULL for the config file and the library will search the compiled defaults: if /share/citrus/units.xml is present, that file is used. Otherwise, we check ~/.citrus/units.xml. On success, the routine returns true.

Eventually this should use exceptions instead of return vals.

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

Test for equality. Only abbrieviation match is required for equality.

double Unit::scale ( ) [inline]
 

Return the scale factor between this unit and the Citrus default for this DimensionGroup


Member Data Documentation

char * Unit::m_abbr [protected]
 

The abbreviation for the unit (e.g. the N in "25 [N]")

bool Unit::m_avoid [protected]
 

This unit is obsolete.

DimensionGroup * Unit::m_dgrp [protected]
 

The dimension group this is an "instance" of.

char * Unit::m_name [protected]
 

The name of the unit

Unit * Unit::m_next [protected]
 

The next unit in a list of all units.

bool Unit::m_offsetPolicy [protected]
 

This unit uses the offset member.

double Unit::m_offsetVal [protected]
 

The offset factor to the native units. The offset is applied before the scale factor when converting to native units and after the scale factor when converting from native units.

bool Unit::m_one [protected]
 

This unit is equivalent to one(1).

char * Unit::m_pluralName [protected]
 

The text of the plural form if it is a special form.

int Unit::m_pluralPolicy [protected]
 

This unit has no/a special plural form.

bool Unit::m_prefix [protected]
 

This unit accepts/prints prefixes.

double Unit::m_scale [protected]
 

The scale factor to the native units.

Unit * Unit::s_allUnits = 0 [static, protected]
 

The first entry in the list of all units

Unit * Unit::s_dimensionless = 0 [static, protected]
 

Pointer to unit representing no dimension (scale without units, such as rad)


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