casacore
Loading...
Searching...
No Matches
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: casa-feedback@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#ifndef CASA_UNITNAME_H
27#define CASA_UNITNAME_H
28
29
30//# Includes
31#include <casacore/casa/aips.h>
32#include <casacore/casa/BasicSL/String.h>
33#include <casacore/casa/Quanta/Unit.h>
34#include <casacore/casa/Quanta/UnitVal.h>
35#include <casacore/casa/iosfwd.h>
36
37namespace casacore { //# NAMESPACE CASACORE - BEGIN
38
39// <summary>
40// handles physical units
41// </summary>
42
43// <use visibility=export>
44
45// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="tUnit">
46//
47// <prerequisite>
48// You should have at least a preliminary understanding of these classes:
49// <li> <linkto class=Unit>Unit</linkto>
50// </prerequisite>
51//
52// <etymology>
53// The class name derives from the basic Unit and the Name giving possibilities
54// of this class to a newly defined unit tag.
55// </etymology>
56//
57// <synopsis>
58// Physical units are strings consisting of one or more names of known
59// basic units, separated by '.' or ' ' (for multiplication) or '/' (for
60// division). Each name can optionally be preceded by a standard decimal
61// prefix, and/or followed by an (optionally signed) exponent.
62//
63// Example:
64// km/s/(Mpc.s)2 is identical to km.s-1.Mpc-2.s-2
65//
66// See the <linkto class="Unit">Unit</linkto> class for more details.
67//
68// The UnitName class defines new basic, tagged units. If, e.g., for one
69// reason or another you want, in addition to the standard defined SI and
70// customary units, to define a unit with a name 'KPH' to stand for the
71// composite SI unit 'km/hr', it can be done by creating a UnitName, and
72// mapping it to the UnitMap lists.
73// <note role=tip> The UnitMap::putUser can also be used without creating a UnitName
74// first
75// </note>
76// <srcblock>
77// UnitName myKPH( "KPH", UnitVal(3.6,"km/ks")); // note ks = kilosecond
78// UnitMap::putUser(myKPH);
79// </srcblock>
80//
81// <h3> Constructing a tagged unit definition </h3>
82// The following constructors are available:
83// <ol>
84// <li> UnitName() create unnamed value 1.
85// <li> UnitName(const UnitName&) copy constructor
86// <li> UnitName("tag", UnitVal, "full name")
87// </ol>
88//
89// An assignment (copy semantics) is available.
90//
91//
92// <h3> Obtaining information about tagged unit </h3>
93// The following information can be obatined from a UnitName:
94// <ol>
95// <li> UnitVal getVal() const will return the unit definition value
96// <li> String getName() const will return the unit name
97// </ol>
98//
99//
100// </synopsis>
101//
102// <example>
103// To obtain the definition of a Jy, you could:
104// <srcblock>
105// // Define a UnitVal unit definition
106// UnitVal mydef;
107// // And fill it with the appropiate definition
108// mydef = (UnitMap::getUnit("Jy"))->getVal();
109// </srcblock>
110// </example>
111//
112//# // <motivation>
113//# // </motivation>
114
115class UnitName {
116//# friends
117// Output the unit tag, description and its definition
118 friend ostream& operator<< (ostream &os, const UnitName &name);
119
120public:
121//# Constructors
122// Default constructor
124
125// Copy constructor
126 UnitName(const UnitName &other);
127
128// Construct from different parts
129// <group>
130 UnitName(const String &nameTag, const UnitVal &kind,
131 const String &fullName = String());
132 UnitName(const Unit &unit, const String &fullName = String());
133// </group>
134
135
136// Destructor
138
139//# Operators
140// Assigment (copy semantics)
142
143//# General member functions
144// Get definition value of the unit
145 const UnitVal &getVal() const
146 { return basicKind; }
147
148// Get the name tag of the defined unit
149 const String &getName() const
150 { return basicTag; }
151
152// Get the full name of the defined unit
153 const String &getFullName() const
154 { return basicName; }
155
156private:
157//# Data members
158// Value of defined unit
160
161// Name tag of unit
163
164// Full name and description of unit
166
167};
168
169//# Inline Implementations
170
171
172} //# NAMESPACE CASACORE - END
173
174#endif
String: the storage and methods of handling collections of characters.
Definition String.h:223
UnitVal basicKind
Value of defined unit.
Definition UnitName.h:159
const String & getName() const
Get the name tag of the defined unit.
Definition UnitName.h:149
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:165
String basicTag
Name tag of unit.
Definition UnitName.h:162
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:153
UnitName()
Default constructor.
~UnitName()
Destructor.
const UnitVal & getVal() const
Get definition value of the unit.
Definition UnitName.h:145
UnitName(const Unit &unit, const String &fullName=String())
this file contains all the compiler specific defines
Definition mainpage.dox:28