casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
UnitName.h
Go to the documentation of this file.
00001 //# UnitName.h: defines a tagged unit definition
00002 //# Copyright (C) 1994,1995,1996,1997,1998,1999,2000,2001
00003 //# Associated Universities, Inc. Washington DC, USA.
00004 //#
00005 //# This library is free software; you can redistribute it and/or modify it
00006 //# under the terms of the GNU Library General Public License as published by
00007 //# the Free Software Foundation; either version 2 of the License, or (at your
00008 //# option) any later version.
00009 //#
00010 //# This library is distributed in the hope that it will be useful, but WITHOUT
00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00013 //# License for more details.
00014 //#
00015 //# You should have received a copy of the GNU Library General Public License
00016 //# along with this library; if not, write to the Free Software Foundation,
00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00018 //#
00019 //# Correspondence concerning AIPS++ should be addressed as follows:
00020 //#        Internet email: aips2-request@nrao.edu.
00021 //#        Postal address: AIPS++ Project Office
00022 //#                        National Radio Astronomy Observatory
00023 //#                        520 Edgemont Road
00024 //#                        Charlottesville, VA 22903-2475 USA
00025 //#
00026 //# $Id: UnitName.h 20551 2009-03-25 00:11:33Z Malte.Marquarding $
00027 
00028 #ifndef CASA_UNITNAME_H
00029 #define CASA_UNITNAME_H
00030 
00031 
00032 //# Includes
00033 #include <casa/aips.h>
00034 #include <casa/BasicSL/String.h>
00035 #include <casa/Quanta/Unit.h>
00036 #include <casa/Quanta/UnitVal.h>
00037 #include <casa/iosfwd.h>
00038 
00039 namespace casa { //# NAMESPACE CASA - BEGIN
00040 
00041 //# Forward Declarations
00042 
00043 //# Constants
00044 // <note role=warning>
00045 // SUN compiler does not accept non-simple default arguments
00046 // </note>
00047 static const String EmptyString="";
00048 
00049 // <summary>
00050 // handles physical units
00051 // </summary>
00052 
00053 // <use visibility=export>
00054 
00055 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="tUnit">
00056 //
00057 // <prerequisite>
00058 // You should have at least a preliminary understanding of these classes:
00059 //   <li> <linkto class=Unit>Unit</linkto>
00060 // </prerequisite>
00061 //
00062 // <etymology>
00063 // The class name derives from the basic Unit and the Name giving possibilities
00064 // of this class to a newly defined unit tag.
00065 // </etymology>
00066 //
00067 // <synopsis>
00068 // Physical units are strings consisting of one or more names of known
00069 // basic units, separated by '.' or ' ' (for multiplication) or '/' (for
00070 // division). Each name can optionally be preceded by a standard decimal
00071 // prefix, and/or followed by an (optionally signed) exponent.
00072 //
00073 // Example:
00074 //      km/s/(Mpc.s)2  is identical to km.s-1.Mpc-2.s-2
00075 //
00076 // See the <linkto class="Unit">Unit</linkto> class for more details.
00077 //
00078 // The UnitName class defines new basic, tagged units. If, e.g., for one
00079 // reason or another you want, in addition to the standard defined SI and
00080 // customary units, to define a unit with a name 'KPH' to stand for the
00081 // composite SI unit 'km/s', it can be done by creating a UnitName, and
00082 // mapping it to the UnitMap lists.
00083 // <note role=tip> The UnitMap::putUser can also be used without creating a UnitName
00084 // first
00085 // </note>
00086 // <srcblock>
00087 // UnitName myKPH( "KPH", UnitVal(3.6,"km/ks"));
00088 // UnitMap::putUser(myKPH);
00089 // </srcblock>
00090 //
00091 //  <h3> Constructing a tagged unit definition </h3>
00092 // The following constructors are available:
00093 // <ol>
00094 //   <li> UnitName()                    create unnamed value 1.
00095 //   <li> UnitName(const UnitName&)     copy constructor
00096 //   <li> UnitName("tag", UnitVal, "full name")
00097 // </ol>
00098 //
00099 // An assignment (copy semantics) is available.
00100 // 
00101 //
00102 //  <h3> Obtaining information about tagged unit </h3>
00103 // The following information can be obatined from a UnitName:
00104 // <ol>
00105 //   <li> UnitVal getVal() const        will return the unit definition value
00106 //   <li> String  getName() const       will return the unit name
00107 // </ol>
00108 // 
00109 //
00110 // </synopsis>
00111 //
00112 // <example>
00113 // To obtain the definition of a Jy, you could:
00114 // <srcblock>
00115 // // Define a UnitVal unit definition
00116 // UnitVal mydef;
00117 // // And fill it with the appropiate definition
00118 // mydef = (UnitMap::getUnit("Jy"))->getVal();
00119 // </srcblock>
00120 // </example>
00121 //
00122 //# // <motivation>
00123 //# // </motivation>
00124 //
00125 // <todo asof="941110">
00126 //   <li> Some inlining (did not work first go)
00127 // </todo>
00128 
00129 class UnitName {
00130 //# friends
00131 // Output the unit tag, description and its definition
00132     friend ostream& operator<< (ostream &os, const UnitName &name);
00133 
00134 public:
00135 //# Constructors
00136 // Default constructor
00137     UnitName();
00138 
00139 // Copy constructor
00140     UnitName(const UnitName &other);
00141 
00142 // Construct from different parts
00143 // <group>
00144     UnitName(const String &tag, const UnitVal &kind,
00145               const String &name = EmptyString);
00146     UnitName(const Unit &tag, const String &name = EmptyString);
00147 // </group>
00148 
00149 
00150 // Destructor
00151     ~UnitName();
00152 
00153 //# Operators
00154 // Assigment (copy semantics)
00155     UnitName &operator=(const UnitName &other);
00156 
00157 //# General member functions
00158 // Get definition value of the unit
00159     const UnitVal &getVal() const;
00160 
00161 // Get the name tag of the defined unit
00162     const String &getName() const;
00163 
00164 private:
00165 //# Data members
00166 // Value of defined unit
00167     UnitVal basicKind;
00168 
00169 // Name tag of unit
00170     String basicTag;
00171 
00172 // Full name and description of unit
00173     String basicName;
00174 
00175 };
00176 
00177 //# Inline Implementations
00178 
00179 
00180 } //# NAMESPACE CASA - END
00181 
00182 #endif