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