casacore
Loading...
Searching...
No Matches
MCBase.h
Go to the documentation of this file.
1//# MCBase.h: Base for specific measure conversions
2//# Copyright (C) 1995,1996,1997,1998
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: casa-feedback@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#ifndef MEASURES_MCBASE_H
27#define MEASURES_MCBASE_H
28
29//# Includes
30#include <casacore/casa/aips.h>
31
32namespace casacore { //# NAMESPACE CASACORE - BEGIN
33
34//# Forward Declarations
35class MeasValue;
36class MCBase;
37class MRBase;
38class MConvertBase;
39class String;
40
41//# Typedefs
42
43// <summary> Base for specific measure conversions </summary>
44
45// <use visibility=local>
46
47// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="tMeasure" demos="">
48// </reviewed>
49
50// <prerequisite>
51// <li> <linkto class=Measure>Measure</linkto> class
52// <li> <linkto class=MConvertBase>MConvertBase</linkto>: conversion engine
53// </prerequisite>
54//
55// <etymology>
56// Measure, Conversion and Base
57// </etymology>
58//
59// <synopsis>
60// MCBase forms the base for the individual state machines doing actual
61// conversions between frames. (see e.g. <linkto class=MCEpoch>MCEpoch</linkto>)
62//
63// It also has a static routine to calculate the state transition table based
64// on a list of transitions. The makeState() method find the shortest route
65// (weighted if necessary) for a given list of state transitions.
66//
67// The user of the Measure classes has no direct interaction with this class.
68// </synopsis>
69//
70// <example>
71// Convert (with all steps explicit) a UTC to an IAT time.
72// <srcblock>
73// #include <casacore/measures/Measures.h>
74// #include <casacore/measures/Measures/MCEpoch.h>
75// cout << "TAI for UTC = MJD(50237.29): " <<
76// MEpoch::Convert(MEpoch(MVEpoch(Quantity(50237.29, "d")),
77// MEpoch::Ref(MEpoch::UTC)),
78// MEpoch::Ref(MEpoch::TAI))() <<
79// endl;
80// </srcblock>
81// To get a static state transition matrix:
82// <srcblock>
83// static Bool made = False; // set not yet done
84// enum types { // states
85// A=0, B, C, D, E, ntyp };
86// enum routes { // routes
87// A_B, B_C, B_D, C_D, C_E,
88// D_C, C_B, B_A, D_B, E_C, nrout };
89// static uInt list [nrout][3] = { // description. The third number
90// {A, B, 0}, // is a penalty hop to weight
91// {B, C, 0}, // against using this route
92// {B, D, 0},
93// {C, D, 0},
94// {C, E, 0},
95// {D, C, 0},
96// {C, B, 0},
97// {B, A, 0},
98// {D, B, 0},
99// {E, C, 0} };
100// static uInt state[ntyp][ntyp]; // the resultant transition matrix
101// // diagonal == nrout
102// // Make the state machine
103// MCBase::makeState(state[0], ntyp, nrout, routes);
104// made = True;
105// </srcblock>
106// </example>
107//
108// <motivation>
109// To have specific conversion bases
110// </motivation>
111//
112// <todo asof="1998/09/21">
113// <li> Nothing I know
114// </todo>
115
116class MCBase {
117
118public:
119
120 //# Typedefs
121
122 //# Constructors
123
124 //# Destructor
125 virtual ~MCBase();
126
127 //# Operators
128
129 //# Enumerations
130 // Each derived class should have a list of routines to be called:
133
134 //# Member functions
135 // All these functions are called by Measure::Convert classes only
136 // <group>
137 // Create conversion state machine list
138 virtual void getConvert(MConvertBase &mc,
139 const MRBase &inref,
140 const MRBase &outref) = 0;
141
142 // Create help structures for Measure conversion routines
143 virtual void initConvert(uInt which, MConvertBase &mc) = 0;
144
145 // Delete the pointers used in the MeasConvert help structure cache
146 virtual void clearConvert() = 0;
147
148 // Routine to convert a Measure from one reference frame to another
149 virtual void doConvert(MeasValue &in,
150 MRBase &inref,
151 MRBase &outref,
152 const MConvertBase &mc) = 0;
153 // </group>
154
155protected:
156 // The following routines create a state transition matrix from a list
157 // of all defined transitions. It uses the following information:
158 // <ul>
159 // <li> nrout: the number of transitions; numbered 0, ...
160 // <li> ntyp: the number of states
161 // <li> list: a [nrout][3] list of input and output transition type of
162 // transition and a penalty hop number (<100)
163 // <li> state: a [ntyp][ntyp] transition matrix with diagonal elements set
164 // to nrout.
165 // </ul>
166 // <group>
167 // Routine to make the transition table if necessary
168 static void makeState(uInt *state,
169 const uInt ntyp, const uInt nrout,
170 const uInt list[][3]);
171 // Return a fromatted String with matrix information (based on < 100 types)
172 static String showState(uInt *state,
173 const uInt ntyp, const uInt nrout,
174 const uInt list[][3]);
175private:
176 // Routine to find the shortest route between two points
177 static Bool findState(uInt &len, uInt *state, uInt *mcnt, Bool &okall,
178 Bool *visit, const uInt *tcnt, const uInt *tree,
179 const uInt &in, const uInt &out,
180 const uInt ntyp, const uInt nrout,
181 const uInt list[][3]);
182 // </group>
183
184};
185
186
187} //# NAMESPACE CASACORE - END
188
189#endif
virtual void clearConvert()=0
Delete the pointers used in the MeasConvert help structure cache.
virtual ~MCBase()
virtual void getConvert(MConvertBase &mc, const MRBase &inref, const MRBase &outref)=0
All these functions are called by Measure::Convert classes only.
Routes
Each derived class should have a list of routines to be called:
Definition MCBase.h:131
static Bool findState(uInt &len, uInt *state, uInt *mcnt, Bool &okall, Bool *visit, const uInt *tcnt, const uInt *tree, const uInt &in, const uInt &out, const uInt ntyp, const uInt nrout, const uInt list[][3])
Routine to find the shortest route between two points
virtual void initConvert(uInt which, MConvertBase &mc)=0
Create help structures for Measure conversion routines.
virtual void doConvert(MeasValue &in, MRBase &inref, MRBase &outref, const MConvertBase &mc)=0
Routine to convert a Measure from one reference frame to another.
static String showState(uInt *state, const uInt ntyp, const uInt nrout, const uInt list[][3])
Return a fromatted String with matrix information (based on < 100 types)
static void makeState(uInt *state, const uInt ntyp, const uInt nrout, const uInt list[][3])
The following routines create a state transition matrix from a list of all defined transitions.
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:49
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40