MeasConvert.h

Classes

MeasConvert -- Conversion of Measures (full description)

template<class M> class MeasConvert : public MConvertBase

Interface

Public Members
MeasConvert()
MeasConvert(const MeasConvert<M> &other)
MeasConvert<M> &operator=(const MeasConvert<M> &other)
MeasConvert(const M &ep)
MeasConvert(const M &ep, const typename M::Ref &mr)
MeasConvert(const Measure &ep, const typename M::Ref &mr)
MeasConvert(const M &ep, typename M::Types mr)
MeasConvert(const Measure &ep, typename M::Types mr)
MeasConvert(const typename M::Ref &mrin, const typename M::Ref &mr)
MeasConvert(const typename M::Ref &mrin, typename M::Types mr)
MeasConvert(typename M::Types mrin, const typename M::Ref &mr)
MeasConvert(typename M::Types mrin, typename M::Types mr)
MeasConvert(const Unit &inunit, const typename M::Ref &mrin, const typename M::Ref &mr)
MeasConvert(const Unit &inunit, const typename M::Ref &mrin, typename M::Types mr)
MeasConvert(const Unit &inunit, typename M::Types mrin, const typename M::Ref &mr)
MeasConvert(const Unit &inunit, typename M::Types mrin, typename M::Types mr)
~MeasConvert()
const M &operator()()
const M &operator()(Double val)
const M &operator()(const Vector<Double> &val)
const M &operator()(const Quantum<Double> &val)
const M &operator()(const Quantum<Quantum<Double> > &val)
const M &operator()(const typename M::MVType &val)
const M &operator()(const MeasVal *val)
const M &operator()(const M &val)
const M &operator()(const M &val, const typename M::Ref &mr)
const M &operator()(const M &val, typename M::Types mr)
const M &operator()(const typename M::Ref &mr)
const M &operator()(typename M::Types mr)
virtual void setModel(const Measure &val)
void setOut(const typename M::Ref &mr)
void setOut(typename M::Types mr)
void set(const M &val, const typename M::Ref &mr)
void set(const M &val, typename M::Types mr)
virtual void set(const MeasValue &val)
virtual void set(const Unit &inunit)
virtual void addMethod(uInt method)
virtual void addFrameType(uInt tp)
virtual Int nMethod() const
virtual uInt getMethod(uInt which) const
Bool isNOP()
virtual void print(ostream &os) const
Private Members
void init()
void copy(const MeasConvert<M> &other)
void clear()
void create()
const typename M::MVType &convert()
const typename M::MVType &convert(const typename M::MVType &val)

Description

Review Status

Reviewed By:
UNKNOWN
Date Reviewed:
before2004/08/25
Programs:
Tests:

Prerequisite

Etymology

Synopsis

MeasConvert can convert a Measure to the same type of Measure in a different reference frame. The MeasConvert is a templated class, but has typedefs, which are strongly recommended to be used, for the allowed conversions, like MEpoch::Convert.
The basic operation is to create a MeasConvert with either of: An empty MeasRef argument indicates no conversion will be attempted
. The constructor, and set functions, analyse the 'template' Measure and the output reference frame, and construct a pointer (in practice a list of pointers to bypass the necessity of creating too many conversion functions) to a conversion routine.

An isNOP() function is available to test if the created conversion engine is empty.

Actual conversions are done with the () operator, which produces a new MEpoch (or other appropiate Measure).
Possible arguments are (MVEpoch is used here generic, and indicates the internal format of a Measure; possibly, to make sure distinction between values with and without units possible, even simple Measures will have their own internal class format, e.g. MVDouble. The possible arguments to the () conversion operator are (again Epoch is used for the generic Measure):

Float versions will be produced if necessary.
The conversion analyser expects that all Measure classes have a set of routines to do the actual analysing and conversion. (see MCBase class for how this is done in practice).
If the standard conversion is not sufficient, additional methods can be added at the end of the list with the addMethod() member function (for real pros).

Example

See Measure for an example

Motivation

Conversion of Measures will in general be done on a series of values. Separating the analysis of the calculations necessary for the conversion from the actual conversion could speed up the process.

To Do

Member Description

MeasConvert()

Tip In the following constructors and other functions, all MeasRef can be replaced with simple Measure::TYPE where no offsets or frames are needed in the reference.
Construct an empty MeasConvert. It is not usable, unless a setModel, and probably a setOut has been done.

MeasConvert(const MeasConvert<M> &other)

Copy constructor

MeasConvert<M> &operator=(const MeasConvert<M> &other)

Copy assignment

MeasConvert(const M &ep)
MeasConvert(const M &ep, const typename M::Ref &mr)
MeasConvert(const Measure &ep, const typename M::Ref &mr)
MeasConvert(const M &ep, typename M::Types mr)
MeasConvert(const Measure &ep, typename M::Types mr)
MeasConvert(const typename M::Ref &mrin, const typename M::Ref &mr)
MeasConvert(const typename M::Ref &mrin, typename M::Types mr)
MeasConvert(typename M::Types mrin, const typename M::Ref &mr)
MeasConvert(typename M::Types mrin, typename M::Types mr)
MeasConvert(const Unit &inunit, const typename M::Ref &mrin, const typename M::Ref &mr)
MeasConvert(const Unit &inunit, const typename M::Ref &mrin, typename M::Types mr)
MeasConvert(const Unit &inunit, typename M::Types mrin, const typename M::Ref &mr)
MeasConvert(const Unit &inunit, typename M::Types mrin, typename M::Types mr)

Construct a conversion for the specified Measure and reference

~MeasConvert()

const M &operator()()

The actual conversion operations

Convert model Measure to output frame

const M &operator()(Double val)
const M &operator()(const Vector<Double> &val)
const M &operator()(const Quantum<Double> &val)
const M &operator()(const Quantum<Quantum<Double> > &val)
const M &operator()(const typename M::MVType &val)
const M &operator()(const MeasVal *val)
const M &operator()(const M &val)
const M &operator()(const M &val, const typename M::Ref &mr)
const M &operator()(const M &val, typename M::Types mr)
const M &operator()(const typename M::Ref &mr)
const M &operator()(typename M::Types mr)

The actual conversion operations

virtual void setModel(const Measure &val)

Set a new model for the conversion

void setOut(const typename M::Ref &mr)
void setOut(typename M::Types mr)

Set a new output reference

void set(const M &val, const typename M::Ref &mr)
void set(const M &val, typename M::Types mr)

Set a new model and reference

virtual void set(const MeasValue &val)

Set a new model value only

virtual void set(const Unit &inunit)

Set a new model unit only

virtual void addMethod(uInt method)

Add a method (Note: uInt should be an enum from the appropiate Measure)

virtual void addFrameType(uInt tp)

Add the frame type (Note: tp should be an MeasFrame::FrameType)

virtual Int nMethod() const

Get number of methods

virtual uInt getMethod(uInt which) const

Get method

Bool isNOP()

Is the conversion engine empty?

virtual void print(ostream &os) const

Print conversion engine

void init()

Initialise pointers

void copy(const MeasConvert<M> &other)

Copy a MeasConvert

void clear()

Clear self

void create()

Create the conversion routine chain

const typename M::MVType &convert()
const typename M::MVType &convert(const typename M::MVType &val)

Convert a value