UnitName.h
Classes
- UnitName -- handles physical units (full description)
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
Review Status
- Reviewed By:
- UNKNOWN
- Date Reviewed:
- before2004/08/25
- Programs:
- Tests:
Prerequisite
You should have at least a preliminary understanding of these classes:
- Unit
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.
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:
- UnitName() create unnamed value 1.
- UnitName(const UnitName&) copy constructor
- 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:
- UnitVal getVal() const will return the unit definition value
- 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
- Some inlining (did not work first go)
Member Description
friend ostream& operator<< (ostream &os, const UnitName &name)
Output the unit tag, description and its definition
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)
Destructor
UnitName &operator=(const UnitName &other)
Assigment (copy semantics)
Get definition value of the unit
Get the name tag of the defined unit