casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
MConvertBase.h
Go to the documentation of this file.
00001 //# MConvertBase.h: Conversion of Measures Base
00002 //# Copyright (C) 1995,1996,1997,1999,2000,2001
00003 //# Associated Universities, Inc. Washington DC, USA.
00004 //#
00005 //# This library is free software; you can redistribute it and/or modify it
00006 //# under the terms of the GNU Library General Public License as published by
00007 //# the Free Software Foundation; either version 2 of the License, or (at your
00008 //# option) any later version.
00009 //#
00010 //# This library is distributed in the hope that it will be useful, but WITHOUT
00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00013 //# License for more details.
00014 //#
00015 //# You should have received a copy of the GNU Library General Public License
00016 //# along with this library; if not, write to the Free Software Foundation,
00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00018 //#
00019 //# Correspondence concerning AIPS++ should be addressed as follows:
00020 //#        Internet email: aips2-request@nrao.edu.
00021 //#        Postal address: AIPS++ Project Office
00022 //#                        National Radio Astronomy Observatory
00023 //#                        520 Edgemont Road
00024 //#                        Charlottesville, VA 22903-2475 USA
00025 //#
00026 //#
00027 //# $Id: MConvertBase.h 18093 2004-11-30 17:51:10Z ddebonis $
00028 
00029 #ifndef MEASURES_MCONVERTBASE_H
00030 #define MEASURES_MCONVERTBASE_H
00031 
00032 //# Includes
00033 #include <casa/aips.h>
00034 #include <casa/iosfwd.h>
00035 
00036 namespace casa { //# NAMESPACE CASA - BEGIN
00037 
00038 //# Forward Declarations
00039 class Unit;
00040 class MeasValue;
00041 class Measure;
00042 class MRBase;
00043 
00044 //# Typedefs
00045 
00046 //# Constants
00047 
00048 // <summary> Conversion of Measures Base</summary>
00049 
00050 // <use visibility=local>
00051 
00052 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="tMeasure" demos="">
00053 // </reviewed>
00054 
00055 // <prerequisite>
00056 //   <li> <linkto class=Measure>Measure</linkto> class 
00057 //   <li> <linkto class=MeasRef>MeasRef</linkto> class 
00058 //   <li> <linkto class=Quantum>Quantum</linkto> class 
00059 // </prerequisite>
00060 //
00061 // <etymology>
00062 // </etymology>
00063 //
00064 // <synopsis>
00065 // MConvertBase can convert a Measure to the same type of Measure in a
00066 // different reference frame. The MConvertBase is a templated class, but
00067 // has typedefs for the allowed conversions, like <src>MEpoch::Convert.</src><br>
00068 // The basic operation is to create a MConvertBase with either of:
00069 // <ul>
00070 //   <li> MEpoch::Convert(MEpoch, MEpoch::Ref), where the 
00071 //      <linkto class=MEpoch>MEpoch</linkto> is a template for subsequent
00072 //      conversions, i.e. it will remember the value and 
00073 //      the input reference frame. And the 
00074 //      <linkto class=MeasRef>MeasRef</linkto> is the output reference class.
00075 //   <li> MEpoch::Convert(MEpoch) with a subsequent setOut(MEpoch::Ref)
00076 //   <li> MEpoch::Convert(MEpoch::Ref in, MEpoch::Ref out) is a template for
00077 //       conversions from the input reference to the output reference. The
00078 //      'template' model used is the default value for the Measure, with
00079 //      no units. 
00080 //   <li> MEpoch::Convert(Unit, MEpoch::Ref in, MEpoch::Ref out) is a
00081 //       template for
00082 //       conversions from the input reference to the output reference. The
00083 //      'template' model used is the default value for the Measure, with
00084 //      the default units as specified.
00085 //   <li> MEpoch::Convert() with a setModel(MEpoch) and setOut().
00086 // </ul>
00087 // An empty MeasRef indicates no conversion <br>.
00088 // The constructor, and set functions, analyse the 'template' Measure and the
00089 // output reference frame, and construct a pointer (in practice a list
00090 // of pointers to bypass the necessity of creating too many conversion
00091 // functions) to a conversion routine. Functionals will maybe used in
00092 // a later version in stead of a vector of function pointers. During the
00093 // implementation process, I have, for a variety of reasons, changed the
00094 // list of function pointers to a list of numbers, with the Measure having
00095 // just a <src>doConvert()</src> function containing an appropiate
00096 // switch statement. <br>
00097 // Actual conversions are done with the () operator, which produces a new
00098 // MEpoch (or other Measure).<br>
00099 // Possible arguments are (MVEpoch is used here generic, and indicates the
00100 // internal format of a Measure; possibly, to make sure distinction between
00101 // values with and without units is possible, even simple Measures will
00102 // have their own internal class format, e.g. MVDouble. This will also aid
00103 // in the possibility that I am still pursuing to have a fully dynamic 
00104 // conversion possibility. However, to be able to use pointers to functions
00105 // in any reasonable way for all possible input and output types, a
00106 // multi-level approach is necessary, with all possible datatypes derived
00107 // from some MeasValue.):
00108 // <ul>
00109 //   <li> (MEpoch, MEpoch::Ref): will create a new conversion method, and use 
00110 //      it to produce the result of converting the MEpoch to the specified
00111 //      frame
00112 //    <li> (MEpoch): will create a new conversion method from the
00113 //      MEpoch to the MeasRef belonging to the MConvertBase
00114 //    <li> (Quantity): will use the conversion chain deduced from the
00115 //      MEpoch model in the definition of MConvertBase, and will convert the
00116 //      Quantity
00117 //    <li> (Quantum<Vector<Double> >) as previous
00118 //    <li> (Double): will use the units (if present) as specified in the
00119 //              MConvertBase object to construct the internal value
00120 //               to be converted
00121 //    <li> (Vector<Double> >): as previous
00122 // </ul>
00123 // Float versions will be produced if necessary.<br>
00124 // The conversion analyser expects that all Measure classes have a set
00125 // of routines to do the actual analysing and conversion.<br>
00126 // If the standard conversion is not sufficient, additional methods can be
00127 // added at the end of the list with the <src>addMethod()</src> member
00128 // function, or at the beginning of the list with <src>insertMethod()</src>.
00129 // The whole list can be cleared with <src>clearMethod()</src>.<br>
00130 // To ease the specification of the Method, each Measure has a typedef
00131 // (e.g. MEpoch_ConvType) specifying the Method type.
00132 // </synopsis>
00133 //
00134 // <example>
00135 // See <linkto class=Measure>Measure</linkto> for an example
00136 // </example>
00137 //
00138 // <motivation>
00139 // Conversion of Measures will in general be done on a series of values.
00140 // Separating the analysis of the calculations necessary for the conversion
00141 // from the actual conversion could speed up the process.
00142 // </motivation>
00143 //
00144 // <todo asof="1996/02/22">
00145 // </todo>
00146 
00147 class MConvertBase {
00148 
00149 public:
00150   
00151   //# Friends
00152   
00153   //# Constructors
00154   
00155   //# Destructor
00156   virtual ~MConvertBase();
00157   
00158   //# Operators
00159   
00160   //# General Member Functions
00161   // Set a new model for the conversion
00162   virtual void setModel(const Measure &val) = 0;
00163   // Set a new model value only
00164   virtual void set(const MeasValue &val) = 0;
00165   // Set a new model unit only
00166   virtual void set(const Unit &inunit) = 0;
00167   // Add a method (Note: uInt should be an enum from the appropiate Measure)
00168   virtual void addMethod(uInt method) = 0;
00169   // Add a FrameTypes used (as specified in MeasFrame::FrameTypes)
00170   virtual void addFrameType(uInt tp) = 0;
00171   // Get number of methods
00172   virtual Int nMethod() const = 0;
00173   // Get method
00174   virtual uInt getMethod(uInt which) const = 0;
00175   // Print a conversion engine
00176   virtual void print(ostream &os) const = 0;
00177   
00178 private:
00179   //# Data
00180   
00181   //# Member functions
00182 
00183 };
00184 
00185 //# Global functions
00186 // <summary> Global functions </summary>
00187 // <group name=Output>
00188 // Output decalration
00189 ostream &operator<<( ostream &os, const MConvertBase &mc);
00190 // </group>
00191 
00192 
00193 } //# NAMESPACE CASA - END
00194 
00195 #endif