casacore
UnitName.h
Go to the documentation of this file.
1//# UnitName.h: defines a tagged unit definition
2//# Copyright (C) 1994,1995,1996,1997,1998,1999,2000,2001
3//# Associated Universities, Inc. Washington DC, USA.
4//#
5//# This library is free software; you can redistribute it and/or modify it
6//# under the terms of the GNU Library General Public License as published by
7//# the Free Software Foundation; either version 2 of the License, or (at your
8//# option) any later version.
9//#
10//# This library is distributed in the hope that it will be useful, but WITHOUT
11//# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12//# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13//# License for more details.
14//#
15//# You should have received a copy of the GNU Library General Public License
16//# along with this library; if not, write to the Free Software Foundation,
17//# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18//#
19//# Correspondence concerning AIPS++ should be addressed as follows:
20//# Internet email: aips2-request@nrao.edu.
21//# Postal address: AIPS++ Project Office
22//# National Radio Astronomy Observatory
23//# 520 Edgemont Road
24//# Charlottesville, VA 22903-2475 USA
25//#
26//# $Id$
27
28#ifndef CASA_UNITNAME_H
29#define CASA_UNITNAME_H
30
31
32//# Includes
33#include <casacore/casa/aips.h>
34#include <casacore/casa/BasicSL/String.h>
35#include <casacore/casa/Quanta/Unit.h>
36#include <casacore/casa/Quanta/UnitVal.h>
37#include <casacore/casa/iosfwd.h>
38
39namespace casacore { //# NAMESPACE CASACORE - BEGIN
40
41// <summary>
42// handles physical units
43// </summary>
44
45// <use visibility=export>
46
47// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="tUnit">
48//
49// <prerequisite>
50// You should have at least a preliminary understanding of these classes:
51// <li> <linkto class=Unit>Unit</linkto>
52// </prerequisite>
53//
54// <etymology>
55// The class name derives from the basic Unit and the Name giving possibilities
56// of this class to a newly defined unit tag.
57// </etymology>
58//
59// <synopsis>
60// Physical units are strings consisting of one or more names of known
61// basic units, separated by '.' or ' ' (for multiplication) or '/' (for
62// division). Each name can optionally be preceded by a standard decimal
63// prefix, and/or followed by an (optionally signed) exponent.
64//
65// Example:
66// km/s/(Mpc.s)2 is identical to km.s-1.Mpc-2.s-2
67//
68// See the <linkto class="Unit">Unit</linkto> class for more details.
69//
70// The UnitName class defines new basic, tagged units. If, e.g., for one
71// reason or another you want, in addition to the standard defined SI and
72// customary units, to define a unit with a name 'KPH' to stand for the
73// composite SI unit 'km/hr', it can be done by creating a UnitName, and
74// mapping it to the UnitMap lists.
75// <note role=tip> The UnitMap::putUser can also be used without creating a UnitName
76// first
77// </note>
78// <srcblock>
79// UnitName myKPH( "KPH", UnitVal(3.6,"km/ks")); // note ks = kilosecond
80// UnitMap::putUser(myKPH);
81// </srcblock>
82//
83// <h3> Constructing a tagged unit definition </h3>
84// The following constructors are available:
85// <ol>
86// <li> UnitName() create unnamed value 1.
87// <li> UnitName(const UnitName&) copy constructor
88// <li> UnitName("tag", UnitVal, "full name")
89// </ol>
90//
91// An assignment (copy semantics) is available.
92//
93//
94// <h3> Obtaining information about tagged unit </h3>
95// The following information can be obatined from a UnitName:
96// <ol>
97// <li> UnitVal getVal() const will return the unit definition value
98// <li> String getName() const will return the unit name
99// </ol>
100//
101//
102// </synopsis>
103//
104// <example>
105// To obtain the definition of a Jy, you could:
106// <srcblock>
107// // Define a UnitVal unit definition
108// UnitVal mydef;
109// // And fill it with the appropiate definition
110// mydef = (UnitMap::getUnit("Jy"))->getVal();
111// </srcblock>
112// </example>
113//
114//# // <motivation>
115//# // </motivation>
116
117class UnitName {
118//# friends
119// Output the unit tag, description and its definition
120 friend ostream& operator<< (ostream &os, const UnitName &name);
121
122public:
123//# Constructors
124// Default constructor
126
127// Copy constructor
128 UnitName(const UnitName &other);
129
130// Construct from different parts
131// <group>
132 UnitName(const String &nameTag, const UnitVal &kind,
133 const String &fullName = String());
134 UnitName(const Unit &unit, const String &fullName = String());
135// </group>
136
137
138// Destructor
140
141//# Operators
142// Assigment (copy semantics)
144
145//# General member functions
146// Get definition value of the unit
147 const UnitVal &getVal() const
148 { return basicKind; }
149
150// Get the name tag of the defined unit
151 const String &getName() const
152 { return basicTag; }
153
154// Get the full name of the defined unit
155 const String &getFullName() const
156 { return basicName; }
157
158private:
159//# Data members
160// Value of defined unit
162
163// Name tag of unit
165
166// Full name and description of unit
168
169};
170
171//# Inline Implementations
172
173
174} //# NAMESPACE CASACORE - END
175
176#endif
String: the storage and methods of handling collections of characters.
Definition: String.h:225
UnitVal basicKind
Value of defined unit.
Definition: UnitName.h:161
const String & getName() const
Get the name tag of the defined unit.
Definition: UnitName.h:151
UnitName(const String &nameTag, const UnitVal &kind, const String &fullName=String())
Construct from different parts.
UnitName & operator=(const UnitName &other)
Assigment (copy semantics)
UnitName(const UnitName &other)
Copy constructor.
String basicName
Full name and description of unit.
Definition: UnitName.h:167
String basicTag
Name tag of unit.
Definition: UnitName.h:164
friend ostream & operator<<(ostream &os, const UnitName &name)
Output the unit tag, description and its definition.
const String & getFullName() const
Get the full name of the defined unit.
Definition: UnitName.h:155
UnitName()
Default constructor.
~UnitName()
Destructor.
const UnitVal & getVal() const
Get definition value of the unit.
Definition: UnitName.h:147
UnitName(const Unit &unit, const String &fullName=String())
this file contains all the compiler specific defines
Definition: mainpage.dox:28