UnitName.h

Classes

UnitName -- handles physical units (full description)

class UnitName

Interface

friend ostream& operator<< (ostream &os, const UnitName &name)
Public Members
UnitName()
UnitName(const UnitName &other)
UnitName(const String &tag, const UnitVal &kind, const String &name = EmptyString)
UnitName(const Unit &tag, const String &name = EmptyString)
~UnitName()
UnitName &operator=(const UnitName &other)
const UnitVal &getVal() const
const String &getName() const

Description

Review Status

Reviewed By:
UNKNOWN
Date Reviewed:
before2004/08/25
Programs:
Tests:

Prerequisite

Etymology

The class name derives from the basic Unit and the Name giving possibilities of this class to a newly defined unit tag.

Synopsis

Physical units are strings consisting of one or more names of known basic units, separated by '.' or ' ' (for multiplication) or '/' (for division). Each name can optionally be preceded by a standard decimal prefix, and/or followed by an (optionally signed) exponent.

Example: km/s/(Mpc.s)2 is identical to km.s-1.Mpc-2.s-2

See the Unit class for more details.

The UnitName class defines new basic, tagged units. If, e.g., for one reason or another you want, in addition to the standard defined SI and customary units, to define a unit with a name 'KPH' to stand for the composite SI unit 'km/s', it can be done by creating a UnitName, and mapping it to the UnitMap lists.

Tip The UnitMap::putUser can also be used without creating a UnitName first
    UnitName myKPH( "KPH", UnitVal(3.6,"km/ks"));
    UnitMap::putUser(myKPH);
    

Constructing a tagged unit definition

The following constructors are available:
  1. UnitName() create unnamed value 1.
  2. UnitName(const UnitName&) copy constructor
  3. UnitName("tag", UnitVal, "full name")

An assignment (copy semantics) is available.

Obtaining information about tagged unit

The following information can be obatined from a UnitName:
  1. UnitVal getVal() const will return the unit definition value
  2. String getName() const will return the unit name

Example

To obtain the definition of a Jy, you could:
    // Define a UnitVal unit definition
    UnitVal mydef;
    // And fill it with the appropiate definition
    mydef = (UnitMap::getUnit("Jy"))->getVal();
    

To Do

Member Description

friend ostream& operator<< (ostream &os, const UnitName &name)

Output the unit tag, description and its definition

UnitName()

Default constructor

UnitName(const UnitName &other)

Copy constructor

UnitName(const String &tag, const UnitVal &kind, const String &name = EmptyString)

Construct from different parts

UnitName(const Unit &tag, const String &name = EmptyString)

~UnitName()

Destructor

UnitName &operator=(const UnitName &other)

Assigment (copy semantics)

const UnitVal &getVal() const

Get definition value of the unit

const String &getName() const

Get the name tag of the defined unit