casacore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Attributes | Friends | List of all members
casacore::UnitName Class Reference

handles physical units More...

#include <UnitName.h>

Public Member Functions

 UnitName ()
 Default constructor. More...
 
 UnitName (const UnitName &other)
 Copy constructor. More...
 
 UnitName (const String &nameTag, const UnitVal &kind, const String &fullName=String())
 Construct from different parts. More...
 
 UnitName (const Unit &unit, const String &fullName=String())
 
 ~UnitName ()
 Destructor. More...
 
UnitNameoperator= (const UnitName &other)
 Assigment (copy semantics) More...
 
const UnitValgetVal () const
 Get definition value of the unit. More...
 
const StringgetName () const
 Get the name tag of the defined unit. More...
 
const StringgetFullName () const
 Get the full name of the defined unit. More...
 

Private Attributes

UnitVal basicKind
 Value of defined unit. More...
 
String basicTag
 Name tag of unit. More...
 
String basicName
 Full name and description of unit. More...
 

Friends

ostream & operator<< (ostream &os, const UnitName &name)
 Output the unit tag, description and its definition. More...
 

Detailed Description

handles physical units

Intended use:

Public interface

Review Status

Reviewed By:
UNKNOWN
Date Reviewed:
before2004/08/25
Test programs:
tUnit

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/hr', 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")); // note ks = kilosecond

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();

Definition at line 117 of file UnitName.h.

Constructor & Destructor Documentation

casacore::UnitName::UnitName ( )

Default constructor.

casacore::UnitName::UnitName ( const UnitName other)

Copy constructor.

casacore::UnitName::UnitName ( const String nameTag,
const UnitVal kind,
const String fullName = String() 
)

Construct from different parts.

casacore::UnitName::UnitName ( const Unit unit,
const String fullName = String() 
)
casacore::UnitName::~UnitName ( )

Destructor.

Member Function Documentation

const String& casacore::UnitName::getFullName ( ) const
inline

Get the full name of the defined unit.

Definition at line 155 of file UnitName.h.

References basicName.

const String& casacore::UnitName::getName ( ) const
inline

Get the name tag of the defined unit.

Definition at line 151 of file UnitName.h.

References basicTag.

const UnitVal& casacore::UnitName::getVal ( ) const
inline

Get definition value of the unit.

Definition at line 147 of file UnitName.h.

References basicKind.

UnitName& casacore::UnitName::operator= ( const UnitName other)

Assigment (copy semantics)

Friends And Related Function Documentation

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

Output the unit tag, description and its definition.

Member Data Documentation

UnitVal casacore::UnitName::basicKind
private

Value of defined unit.

Definition at line 161 of file UnitName.h.

Referenced by getVal().

String casacore::UnitName::basicName
private

Full name and description of unit.

Definition at line 167 of file UnitName.h.

Referenced by getFullName().

String casacore::UnitName::basicTag
private

Name tag of unit.

Definition at line 164 of file UnitName.h.

Referenced by getName().


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