casa
$Rev:20696$
|
00001 //# MeasRef.h: Reference frame for physical measures 00002 //# Copyright (C) 1995,1996,1997,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 //# 00027 //# $Id: MeasRef.h 21285 2012-11-14 15:36:59Z gervandiepen $ 00028 00029 #ifndef MEASURES_MEASREF_H 00030 #define MEASURES_MEASREF_H 00031 00032 //# Includes 00033 #include <casa/aips.h> 00034 #include <measures/Measures/MRBase.h> 00035 #include <measures/Measures/MeasFrame.h> 00036 #include <casa/iosfwd.h> 00037 00038 namespace casa { //# NAMESPACE CASA - BEGIN 00039 00040 //# Forward Declarations 00041 class String; 00042 template <class Ms> class MeasRef; 00043 00044 // <summary> Reference frame for physical measures </summary> 00045 00046 // <use visibility=export> 00047 00048 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="tMeasure" demos=""> 00049 // </reviewed> 00050 00051 // <prerequisite> 00052 // <li> <linkto class=MRBase>MRBase</linkto>: the MeasRef base class 00053 // <li> <linkto class=Quantum>Quantum</linkto> class 00054 // <li> <linkto class=Measure>Measure</linkto> class 00055 // </prerequisite> 00056 // 00057 // <etymology> 00058 // From Measure and Reference frame 00059 // </etymology> 00060 // 00061 // <synopsis> 00062 // MeasRef specifies the reference frame for a physical quantity 00063 // specified by one of the derived <linkto class=Measure>Measure</linkto> 00064 // classes (e.g. <linkto class=MEpoch>MEpoch</linkto>). It is derived from 00065 // <linkto class=MRBase>MRBase</linkto>, which describes the class. 00066 // 00067 // MeasRef containres are created using the <src>Measure::Ref</src> class 00068 // (e.g. <src>MDirection::Ref</src>). 00069 // </synopsis> 00070 // 00071 // <example> 00072 // See <linkto class=Measure>Measure</linkto> for an example 00073 // </example> 00074 // 00075 // <motivation> 00076 // To gather all reference frame information in the one class. 00077 // </motivation> 00078 // 00079 // <todo asof="1997/04/15"> 00080 // </todo> 00081 00082 template<class Ms> class MeasRef : public MRBase { 00083 00084 public: 00085 00086 //# Friends 00087 00088 //# Constructors 00089 // Construct an empty MeasRef. I.e. it will have a standard, 00090 // <em>default</em>, type; no offsets and Frame. 00091 MeasRef(); 00092 // Copy constructor 00093 MeasRef(const MeasRef<Ms> &other); 00094 // Copy assignment 00095 MeasRef &operator=(const MeasRef<Ms> &other); 00096 // Construct a reference with specified type, offset and Frame 00097 // <group> 00098 // <note role=caution> The following should really be (and should 00099 // still be called as), but 00100 // compiler does not accept it, due to incomplete definition when 00101 // called in MeasBase: </note> 00102 // <src> MeasRef(Ms::Types tp); </src> 00103 // Furthermore, default arguments are not supported with templated classes: 00104 explicit MeasRef(const uInt tp); 00105 MeasRef(const uInt tp, const Ms &ep); 00106 MeasRef(const uInt tp, const MeasFrame &mf); 00107 MeasRef(const uInt tp, const MeasFrame &mf, const Ms &ep); 00108 // </group> 00109 00110 //# Destructor 00111 ~MeasRef(); 00112 00113 //# Operators 00114 // Check if same MeasRef 00115 Bool operator==(const MeasRef<Ms> &other) const; 00116 // Check if unequal MeasRef 00117 Bool operator!=(const MeasRef<Ms> &other) const; 00118 00119 //# General Member Functions 00120 // Check if empty reference 00121 virtual Bool empty() const; 00122 // Check the type of Measure the reference can be used for 00123 // <group> 00124 static const String &showMe(); 00125 // </group> 00126 // Return the type of the reference 00127 // <note role=caution> the following should really be 00128 // (and should be interpreted as), but 00129 // cannot create a virtual function:</note> 00130 // <src> Ms::Types getType();</src> 00131 virtual uInt getType() const; 00132 // Return the frame of reference 00133 virtual MeasFrame &getFrame(); 00134 // Return the first frame which has specified information. Checking is done in 00135 // argument order. 00136 // <thrown> 00137 // <li> AipsError if neither reference has a frame or the proper type 00138 // </thrown> 00139 // <group> 00140 static const MeasFrame &framePosition(MRBase &ref1, 00141 MRBase &ref2); 00142 static const MeasFrame &frameEpoch(MRBase &ref1, 00143 MRBase &ref2); 00144 static const MeasFrame &frameDirection(MRBase &ref1, 00145 MRBase &ref2); 00146 static const MeasFrame &frameRadialVelocity(MRBase &ref1, 00147 MRBase &ref2); 00148 static const MeasFrame &frameComet(MRBase &ref1, 00149 MRBase &ref2); 00150 // </group> 00151 // Return the offset (or 0) 00152 virtual const Measure* offset() const; 00153 // Set the type 00154 // <thrown> 00155 // <li> AipsError if wrong Measure 00156 // </thrown> 00157 // <note role=caution> the following should really be 00158 // (and should be called as), but 00159 // compiler does not accept it, since a virtual function:</note> 00160 // <src> void set(Ms::Types tp);</src> 00161 // <group> 00162 virtual void setType(uInt tp); 00163 virtual void set(uInt tp); 00164 // </group> 00165 // Set a new offset 00166 void set(const Ms &ep); 00167 // Set a new offset (for internal use only) 00168 void set(const Measure &ep); 00169 // Set a new frame 00170 virtual void set(const MeasFrame &mf); 00171 00172 // Print a Measure 00173 virtual void print(ostream &os) const; 00174 00175 private: 00176 00177 // Representation class 00178 class RefRep { 00179 public: 00180 // Constructor 00181 // <note role=warning> Next one must be in-line for (some?) compilers </note> 00182 RefRep() : type(Ms::DEFAULT), offmp(0), frame() {} 00183 // Destructor 00184 // <note role=warning> Next one must be in-line for (some?) compilers </note> 00185 ~RefRep() {delete offmp;} 00186 // The actual data 00187 // <group> 00188 // Type of reference 00189 typename Ms::Types type; 00190 // Pointer to main Measure, defining an offset 00191 Measure *offmp; 00192 // Reference frame 00193 MeasFrame frame; 00194 // </group> 00195 }; 00196 00197 //# Data 00198 CountedPtr<RefRep> rep_p; 00199 00200 //# Member functions 00201 // Create an instance of MeasRef 00202 void create(); 00203 00204 // Copy an instance 00205 MeasRef copy(); 00206 }; 00207 00208 00209 } //# NAMESPACE CASA - END 00210 00211 #ifndef CASACORE_NO_AUTO_TEMPLATES 00212 #include <measures/Measures/MeasRef.tcc> 00213 #endif //# CASACORE_NO_AUTO_TEMPLATES 00214 #endif