casacore
MCFrequency.h
Go to the documentation of this file.
1 //# MCFrequency.h: MFrequency conversion routines
2 //# Copyright (C) 1995,1996,1997,1998,1999,2000,2002,2003
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 //#
27 //# $Id$
28 
29 #ifndef MEASURES_MCFREQUENCY_H
30 #define MEASURES_MCFREQUENCY_H
31 
32 //# Includes
33 #include <casacore/casa/aips.h>
34 #include <casacore/measures/Measures/MeasBase.h>
35 #include <casacore/measures/Measures/MeasRef.h>
36 #include <casacore/measures/Measures/MCBase.h>
37 #include <casacore/measures/Measures/MConvertBase.h>
38 #include <casacore/measures/Measures/MFrequency.h>
39 #include <casacore/casa/OS/Mutex.h>
40 
41 namespace casacore { //# NAMESPACE CASACORE - BEGIN
42 
43 //# Forward Declarations
44 class MCFrequency;
45 class MDoppler;
46 class MVPosition;
47 class MVDirection;
48 class Aberration;
49 class String;
50 
51 //# Typedefs
52 
53 // <summary> MFrequency conversion routines </summary>
54 
55 // <use visibility=local>
56 
57 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="tMeasure" demos="">
58 // </reviewed>
59 
60 // <prerequisite>
61 // <li> <linkto class=Measure>Measure</linkto> class
62 // <li> <linkto class=MCBase>MCBase</linkto> base class
63 // <li> <linkto class=MConvertBase>overall conversion</linkto> class
64 // </prerequisite>
65 //
66 // <etymology>
67 // Measure, Convert and Frequency
68 // </etymology>
69 //
70 // <synopsis>
71 // Contains state machinery and caching for actual conversions
72 // </synopsis>
73 //
74 // <example>
75 // Get the Doppler shift for an oberved HI frequency of 1380 MHz
76 // <srcblock>
77 // #include <casacore/measures/Measures.h>
78 // #include <casacore/measures/Measures/MDoppler.h>
79 // #include <casacore/measures/Measures/MFrequency.h>
80 // cout << "Redshift for 1380 MHz: " <<
81 // MDoppler::Convert( MFrequency( Quantity(1380., "MHz"),
82 // MFrequency::TOPO).toDoppler(QC::HI),
83 // MDoppler::Z)() << endl;
84 // </srcblock>
85 // </example>
86 //
87 // <motivation>
88 // </motivation>
89 //
90 // <todo asof="2003/03/03">
91 // </todo>
92 
93 class MCFrequency : public MCBase {
94 
95 public:
96  //# Friends
97  // Conversion of data
98  friend class MeasConvert<MFrequency>;
99 
100  //# Constructors
101  // Default constructor
102  MCFrequency();
103 
104  //# Destructor
105  ~MCFrequency();
106 
107  //# Member functions
108  // Show the state of the conversion engine (mainly for debugging purposes)
109  static String showState();
110 
111 private:
112  //# Enumerations
113  // The list of actual routines provided.
114  // <note role=warning> Each <src>AA_BB</src> in the list points to routine
115  // that can be used in the FromTo list in the getConvert routine.
116  // In addition the type to which each is converted should be in the
117  // ToRef array, again in the proper order. </note>
118  enum Routes {
136 
137  //# Typedefs
138 
139  //# Operators
140 
141  //# General Member Functions
142 
143  //# Enumerations
144 
145  //# Cached Data
150 
151  //# State machine data
152  // Transition list
153  static uInt ToRef_p[N_Routes][3];
154  // Transition matrix
156  // Mutex for thread-safety.
158 
159  // Fill the global state in a thread-safe way.
160  static void fillState()
161  { theirMutexedInit.exec(); }
162 
163  //# Constructors
164  // Copy constructor (not implemented)
165  MCFrequency(const MCFrequency &other);
166  // Assignment (not implemented)
167  MCFrequency &operator=(const MCFrequency &other);
168 
169  //# Member functions
170  // Create conversion function pointer
171  virtual void getConvert(MConvertBase &mc,
172  const MRBase &inref,
173  const MRBase &outref);
174 
175  // Create help structures for Measure conversion routines
176  virtual void initConvert(uInt which, MConvertBase &mc);
177 
178  // Delete the pointers used in the MeasConvert help structure cache
179  virtual void clearConvert();
180 
181  // Routine to convert frequency from one reference frame to another
182  virtual void doConvert(MeasValue &in,
183  MRBase &inref,
184  MRBase &outref,
185  const MConvertBase &mc);
186  // Conversion routine to cater for inheritance question
187  void doConvert(MVFrequency &in,
188  MRBase &inref,
189  MRBase &outref,
190  const MConvertBase &mc);
191 
192 private:
193  // Fill the global state in a thread-safe way.
194  static void doFillState (void*);
195 };
196 
197 
198 } //# NAMESPACE CASACORE - END
199 
200 #endif
virtual void clearConvert()
Delete the pointers used in the MeasConvert help structure cache.
Conversion of Measures.
Definition: MBaseline.h:44
Routes
Each derived class should have a list of routines to be called:
Definition: MCBase.h:134
Base for Reference frame for physical measures.
Definition: MRBase.h:103
Internal value for MFrequency.
Definition: MVFrequency.h:97
MVPosition * MVPOS1
Definition: MCFrequency.h:146
Base for specific measure conversions.
Definition: MCBase.h:119
virtual void doConvert(MeasValue &in, MRBase &inref, MRBase &outref, const MConvertBase &mc)
Routine to convert frequency from one reference frame to another.
Thread-safe initialization of global variables.
Definition: Mutex.h:161
Aberration * ABERTO
Definition: MCFrequency.h:149
virtual void initConvert(uInt which, MConvertBase &mc)
Create help structures for Measure conversion routines.
A Measure: wave characteristics.
Definition: MFrequency.h:161
virtual void getConvert(MConvertBase &mc, const MRBase &inref, const MRBase &outref)
Create conversion function pointer.
static uInt FromTo_p[MFrequency::N_Types][MFrequency::N_Types]
Transition matrix.
Definition: MCFrequency.h:155
Aberration * ABERFROM
Definition: MCFrequency.h:148
Base class for values in a Measure.
Definition: MeasValue.h:107
static uInt ToRef_p[N_Routes][3]
Transition list.
Definition: MCFrequency.h:153
MVDirection * MVDIR1
Definition: MCFrequency.h:147
static void doFillState(void *)
Fill the global state in a thread-safe way.
MCFrequency & operator=(const MCFrequency &other)
Assignment (not implemented)
A 3D vector in space.
Definition: MVPosition.h:113
static void fillState()
Fill the global state in a thread-safe way.
Definition: MCFrequency.h:160
void exec()
Execute the initialization function if not done yet.
Definition: Mutex.h:171
Aberration class and calculations.
Definition: Aberration.h:109
MCFrequency()
Default constructor.
MFrequency conversion routines.
Definition: MCFrequency.h:93
String: the storage and methods of handling collections of characters.
Definition: String.h:223
Vector of three direction cosines.
Definition: MVDirection.h:106
static MutexedInit theirMutexedInit
Mutex for thread-safety.
Definition: MCFrequency.h:157
this file contains all the compiler specific defines
Definition: mainpage.dox:28
unsigned int uInt
Definition: aipstype.h:51
Conversion of Measures Base.
Definition: MConvertBase.h:147
static String showState()
Show the state of the conversion engine (mainly for debugging purposes)