casacore
Loading...
Searching...
No Matches
MConvertBase.h
Go to the documentation of this file.
1//# MConvertBase.h: Conversion of Measures Base
2//# Copyright (C) 1995,1996,1997,1999,2000,2001
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_MCONVERTBASE_H
27#define MEASURES_MCONVERTBASE_H
28
29//# Includes
30#include <casacore/casa/aips.h>
31#include <casacore/casa/iosfwd.h>
32
33namespace casacore { //# NAMESPACE CASACORE - BEGIN
34
35//# Forward Declarations
36class Unit;
37class MeasValue;
38class Measure;
39class MRBase;
40
41//# Typedefs
42
43//# Constants
44
45// <summary> Conversion of Measures Base</summary>
46
47// <use visibility=local>
48
49// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="tMeasure" demos="">
50// </reviewed>
51
52// <prerequisite>
53// <li> <linkto class=Measure>Measure</linkto> class
54// <li> <linkto class=MeasRef>MeasRef</linkto> class
55// <li> <linkto class=Quantum>Quantum</linkto> class
56// </prerequisite>
57//
58// <etymology>
59// </etymology>
60//
61// <synopsis>
62// MConvertBase can convert a Measure to the same type of Measure in a
63// different reference frame. The MConvertBase is a templated class, but
64// has typedefs for the allowed conversions, like <src>MEpoch::Convert.</src><br>
65// The basic operation is to create a MConvertBase with either of:
66// <ul>
67// <li> MEpoch::Convert(MEpoch, MEpoch::Ref), where the
68// <linkto class=MEpoch>MEpoch</linkto> is a template for subsequent
69// conversions, i.e. it will remember the value and
70// the input reference frame. And the
71// <linkto class=MeasRef>MeasRef</linkto> is the output reference class.
72// <li> MEpoch::Convert(MEpoch) with a subsequent setOut(MEpoch::Ref)
73// <li> MEpoch::Convert(MEpoch::Ref in, MEpoch::Ref out) is a template for
74// conversions from the input reference to the output reference. The
75// 'template' model used is the default value for the Measure, with
76// no units.
77// <li> MEpoch::Convert(Unit, MEpoch::Ref in, MEpoch::Ref out) is a
78// template for
79// conversions from the input reference to the output reference. The
80// 'template' model used is the default value for the Measure, with
81// the default units as specified.
82// <li> MEpoch::Convert() with a setModel(MEpoch) and setOut().
83// </ul>
84// An empty MeasRef indicates no conversion <br>.
85// The constructor, and set functions, analyse the 'template' Measure and the
86// output reference frame, and construct a pointer (in practice a list
87// of pointers to bypass the necessity of creating too many conversion
88// functions) to a conversion routine. Functionals will maybe used in
89// a later version in stead of a vector of function pointers. During the
90// implementation process, I have, for a variety of reasons, changed the
91// list of function pointers to a list of numbers, with the Measure having
92// just a <src>doConvert()</src> function containing an appropiate
93// switch statement. <br>
94// Actual conversions are done with the () operator, which produces a new
95// MEpoch (or other Measure).<br>
96// Possible arguments are (MVEpoch is used here generic, and indicates the
97// internal format of a Measure; possibly, to make sure distinction between
98// values with and without units is possible, even simple Measures will
99// have their own internal class format, e.g. MVDouble. This will also aid
100// in the possibility that I am still pursuing to have a fully dynamic
101// conversion possibility. However, to be able to use pointers to functions
102// in any reasonable way for all possible input and output types, a
103// multi-level approach is necessary, with all possible datatypes derived
104// from some MeasValue.):
105// <ul>
106// <li> (MEpoch, MEpoch::Ref): will create a new conversion method, and use
107// it to produce the result of converting the MEpoch to the specified
108// frame
109// <li> (MEpoch): will create a new conversion method from the
110// MEpoch to the MeasRef belonging to the MConvertBase
111// <li> (Quantity): will use the conversion chain deduced from the
112// MEpoch model in the definition of MConvertBase, and will convert the
113// Quantity
114// <li> (Quantum<Vector<Double> >) as previous
115// <li> (Double): will use the units (if present) as specified in the
116// MConvertBase object to construct the internal value
117// to be converted
118// <li> (Vector<Double> >): as previous
119// </ul>
120// Float versions will be produced if necessary.<br>
121// The conversion analyser expects that all Measure classes have a set
122// of routines to do the actual analysing and conversion.<br>
123// If the standard conversion is not sufficient, additional methods can be
124// added at the end of the list with the <src>addMethod()</src> member
125// function, or at the beginning of the list with <src>insertMethod()</src>.
126// The whole list can be cleared with <src>clearMethod()</src>.<br>
127// To ease the specification of the Method, each Measure has a typedef
128// (e.g. MEpoch_ConvType) specifying the Method type.
129// </synopsis>
130//
131// <example>
132// See <linkto class=Measure>Measure</linkto> for an example
133// </example>
134//
135// <motivation>
136// Conversion of Measures will in general be done on a series of values.
137// Separating the analysis of the calculations necessary for the conversion
138// from the actual conversion could speed up the process.
139// </motivation>
140//
141// <todo asof="1996/02/22">
142// </todo>
143
145
146public:
147
148 //# Friends
149
150 //# Constructors
151
152 //# Destructor
153 virtual ~MConvertBase();
154
155 //# Operators
156
157 //# General Member Functions
158 // Set a new model for the conversion
159 virtual void setModel(const Measure &val) = 0;
160 // Set a new model value only
161 virtual void set(const MeasValue &val) = 0;
162 // Set a new model unit only
163 virtual void set(const Unit &inunit) = 0;
164 // Add a method (Note: uInt should be an enum from the appropiate Measure)
165 virtual void addMethod(uInt method) = 0;
166 // Add a FrameTypes used (as specified in MeasFrame::FrameTypes)
167 virtual void addFrameType(uInt tp) = 0;
168 // Get number of methods
169 virtual Int nMethod() const = 0;
170 // Get method
171 virtual uInt getMethod(uInt which) const = 0;
172 // Print a conversion engine
173 virtual void print(ostream &os) const = 0;
174
175private:
176 //# Data
177
178 //# Member functions
179
180};
181
182//# Global functions
183// <summary> Global functions </summary>
184// <group name=Output>
185// Output decalration
186ostream &operator<<( ostream &os, const MConvertBase &mc);
187// </group>
189
190} //# NAMESPACE CASACORE - END
191
192#endif
virtual void set(const Unit &inunit)=0
Set a new model unit only.
virtual void set(const MeasValue &val)=0
Set a new model value only.
virtual void addFrameType(uInt tp)=0
Add a FrameTypes used (as specified in MeasFrame::FrameTypes)
virtual void print(ostream &os) const =0
Print a conversion engine.
virtual void addMethod(uInt method)=0
Add a method (Note: uInt should be an enum from the appropiate Measure)
virtual uInt getMethod(uInt which) const =0
Get method.
virtual void setModel(const Measure &val)=0
Set a new model for the conversion.
virtual Int nMethod() const =0
Get number of methods.
this file contains all the compiler specific defines
Definition mainpage.dox:28
ostream & operator<<(ostream &os, const IComplex &)
Show on ostream.
unsigned int uInt
Definition aipstype.h:49
int Int
Definition aipstype.h:48
ostream & operator<<(ostream &os, const MConvertBase &mc)
Output decalration.