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 #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
106 
107  //# Destructor
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  // Object to ensure safe multi-threaded lazy single initialization
150 
151  //# Member functions
152 
153  // Create conversion function pointer
154  virtual void getConvert(MConvertBase &mc,
155  const MRBase &inref,
156  const MRBase &outref);
157 
158  // Create help structures for Measure conversion routines
159  virtual void initConvert(uInt which, MConvertBase &mc);
160 
161  // Delete the pointers used in the MeasConvert help structure cache
162  virtual void clearConvert();
163 
164  // Routine to convert Doppler from one reference frame to another
165  virtual void doConvert(MeasValue &in,
166  MRBase &inref,
167  MRBase &outref,
168  const MConvertBase &mc);
169  // Conversion routine to cater for inheritance question
171  MRBase &inref,
172  MRBase &outref,
173  const MConvertBase &mc);
174 
175 private:
176  // Fill the global state. Called using theirInitOnce.
177  static void doFillState();
178 };
179 
180  /*
181 static class MCDoppler_initializer {
182  public:
183  MCDoppler_initializer( ) {
184  if ( ! initialized ) {
185  initialized = true;
186  MutexedInit init(MCDoppler::doFillState);
187  init.exec( );
188  }
189  }
190  private:
191  static bool initialized;
192 } _local_static_MCDoppler_init;
193  */
194 
195 } //# NAMESPACE CASACORE - END
196 
197 #endif
Wrapper around std::call_once.
Definition: Mutex.h:215
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:147
static void doFillState()
Fill the global state.
static CallOnce0 theirInitOnce
Object to ensure safe multi-threaded lazy single initialization.
Definition: MCDoppler.h:149
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:145
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:223
this file contains all the compiler specific defines
Definition: mainpage.dox:28
unsigned int uInt
Definition: aipstype.h:51