casa
$Rev:20696$
|
00001 //# QBase.h: base class for Quantum 00002 //# Copyright (C) 1994,1995,1996,1998,1999 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: QBase.h 20993 2010-11-08 13:36:32Z gervandiepen $ 00027 00028 #ifndef CASA_QBASE_H 00029 #define CASA_QBASE_H 00030 00031 00032 //# Includes 00033 #include <casa/aips.h> 00034 #include <casa/Quanta/Unit.h> 00035 00036 namespace casa { //# NAMESPACE CASA - BEGIN 00037 00038 //# Forward Declarations 00039 00040 //# Typedefs 00041 00042 // 00043 // <summary> 00044 // Base for Quantities (i.e. dimensioned values) 00045 // </summary> 00046 00047 // <use visibility=local> 00048 00049 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="tQuantum"> 00050 // 00051 // <prerequisite> 00052 // <li> <linkto class=Unit>Unit</linkto> 00053 // </prerequisite> 00054 // 00055 // <etymology> 00056 // QBase is the base class for <linkto class=Quantum>Quantum</linkto>. 00057 // </etymology> 00058 // 00059 // <synopsis> 00060 // Quantities are values with a unit. Their basic specification can be one of 00061 // two forms: 00062 // <srcblock> 00063 // Quantity( Double value, String unit); // or: Unit unit 00064 // Quantum<Type> ( Type value, String unit) // or: Unit unit 00065 // </srcblock> 00066 // See <linkto class=Quantum>Quantum</linkto> for details. 00067 // </synopsis> 00068 // 00069 // <motivation> 00070 // To provide the possibilty of mixing units from different 00071 // <src>Quantum<T1></src>, <src>Quantum<T2></src> 00072 // </motivation> 00073 // 00074 // <todo asof="941123"> 00075 // <li> Some inlining (did not work first go) 00076 // </todo> 00077 00078 class QBase { 00079 //# Friends 00080 00081 public: 00082 //# Constructors 00083 // Default constructor, generates "" 00084 QBase(); 00085 // Copy constructor 00086 QBase(const QBase &other); 00087 // Construct dimensioned QBase (e.g. 'km/Mpc') 00088 // <thrown> 00089 // <li> AipsError if non-matching unit dimensions 00090 // </thrown> 00091 // <group> 00092 QBase(const Unit &s); 00093 // </group> 00094 00095 // Destructor 00096 virtual ~QBase(); 00097 00098 //# Operators 00099 // Assignment (copy) 00100 QBase &operator=(const QBase &other); 00101 00102 //# Member functions 00103 // Get units of QBase 00104 // <group name="get"> 00105 // Return the string representation of the current units attached to QBase 00106 const String &getUnit() const; 00107 // </group> 00108 00109 // Re-specify parts of a QBase 00110 // <group name="set"> 00111 // Set new unit, without changing value 00112 void setUnit(const Unit &s); 00113 // Set new unit, copied from specified QBase, without changing value 00114 void setUnit(const QBase &other); 00115 // </group> 00116 00117 // Check for conformal matching units (e.g. dam and Mpc) 00118 // <group name="check"> 00119 // Using specified units 00120 Bool isConform(const Unit &s) const; 00121 // Using units specified in QBase 00122 Bool isConform(const QBase &other) const; 00123 // </group> 00124 00125 // Get a copy of Quantum 00126 virtual QBase *clone() const = 0; 00127 // Get the unit attached to the Quantum (use getUnit() if only interested in 00128 // the String part of the unit) 00129 virtual const Unit &getFullUnit() const = 0; 00130 // Print a Quantum 00131 virtual void print(ostream &os) const = 0; 00132 // Get the type of derived Quantum (using QuantumType). 00133 // All should have: 00134 // static uInt myType(); 00135 virtual uInt type() const = 0; 00136 00137 protected: 00138 //# Data members 00139 Unit qUnit; 00140 }; 00141 00142 //# Inline Implementations 00143 00144 //# Global functions 00145 // <summary> Global functions </summary> 00146 // <group name=Output> 00147 // Output declaration 00148 ostream &operator<<(ostream &os, const QBase &meas); 00149 // </group> 00150 00151 00152 } //# NAMESPACE CASA - END 00153 00154 #endif