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