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