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