casacore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MeasValue.h
Go to the documentation of this file.
1 //# MeasValue.h: Base class for values in a Measure
2 //# Copyright (C) 1996,1997,1998,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 CASA_MEASVALUE_H
30 #define CASA_MEASVALUE_H
31 
32 
33 //# Includes
34 #include <casacore/casa/aips.h>
35 #include <casacore/casa/iosfwd.h>
37 
38 namespace casacore { //# NAMESPACE CASACORE - BEGIN
39 
40 //# Forward Declarations
41 template <class Qtype> class Quantum;
42 
43 // <summary>
44 // Base class for values in a Measure
45 // </summary>
46 
47 // <use visibility=export>
48 
49 // <reviewed reviewer="tcornwel" date="1996/02/22" tests="tMeasMath" demos="">
50 // </reviewed>
51 
52 // <prerequisite>
53 // <li> <linkto class=Measure>Measure</linkto> class
54 // </prerequisite>
55 //
56 // <etymology>
57 // </etymology>
58 //
59 // <synopsis>
60 // MeasValue forms the abstract base class for the values of quantities within
61 // a reference frame. Examples of derived classes are:
62 // <ul>
63 // <li> <linkto class=MVEpoch>MVEpoch</linkto>: a moment in time
64 // <li> <linkto class=MVDirection>MVDirection</linkto>: a direction in space
65 // <li> <linkto class=MVPosition>MVPosition</linkto>: a position on Earth
66 // <li> <linkto class=MVFrequency>MVFrequency</linkto>
67 // <li> <linkto class=MVRadialVelocity>MVRadialVelocity</linkto>
68 // <li> <linkto class=MVDoppler>MVDoppler</linkto>
69 // </ul>
70 // MeasValue is the generic name for the more specific instances like, e.g.,
71 // <linkto class=MVEpoch>MVEpoch</linkto>, an instant in time.<br>
72 // MeasValues can in general be constructed from an appropiate value, or array
73 // of values.<br>
74 // The value can be expressed in the internally used units (e.g.
75 // days for time, a 3-vector for direction in space), as an array of internally
76 // used units, or as a <linkto class=Quantum>Quantum</linkto>: a value with
77 // appropiate units. <src>Vector<Quantum<type> ></src>
78 // and <src>Quantum<Vector<type> ></src> can
79 // also be used.
80 //
81 // The value of the <src>MeasValue</src> can be obtained by a variety of
82 // <src>get</src> functions, returning in general internal or <src>Quantum</src>
83 // values. Special formatting (like hh:mm:ss.t, dd.mm.ss.t, yy/mm/dd etc)
84 // are catered for in <em>conversion-type</em> classes like
85 // <linkto class=MVTime>MVTime</linkto>, <linkto class=MVAngle>MVAngle</linkto>
86 //
87 // Note that the class is a pure virtual class. No instances can be created,
88 // but it describes the minimum set of functions necessary in derived functions.
89 // <note role=warning> In the member description a number of <em>dummy</em> routines are
90 // present. They are the only way I have found to get <em>cxx2html</em> to
91 // get the belonging text properly presented.
92 // </note>
93 // </synopsis>
94 //
95 // <example>
96 // See individual MV and Measure classes
97 // </example>
98 //
99 // <motivation>
100 // To be able to specify a physical entity appropiate for the measured
101 // quantity.
102 // </motivation>
103 //
104 // <todo asof="1997/04/15">
105 // </todo>
106 
107 class MeasValue {
108 
109 public:
110  //# Enumerations
111 
112  //# Typedefs
113 
114  //# Friends
115  // Output a MeasValue
116  friend ostream &operator<<(ostream &os, const MeasValue &meas);
117 
118  //# Constructor
119  // Each derived class should have at least the following constructors:
120  // <srcblock>
121  // MV() // some default
122  // MV(Double) // some default or error if vector expected
123  // MV(Vector<Double>) // with check for array number of elements
124  // MV(Quantity)
125  // MV(Vector<Quantity>)
126  // MV(Quantum<Vector<Double> >
127  // </srcblock>
128  // Float (or other standard type) versions could be added if appropiate.
129  // Dummy for cxx2html
130  void dummy_constr() const {;};
131 
132  //# Destructor
133  // Destructor
134  virtual ~MeasValue();
135 
136  //# Operators
137  // The following operators should be present at least.
138  // <srcblock>
139  // MV &operator+=(const MV &meas);
140  // MV &operator-=(const MV &meas);
141  // Bool operator==(const MV &meas) const;
142  // Bool operator!=(const MV &meas) const;
143  // Bool near(const MV &meas, Double tol = 1e-13) const;
144  // Bool nearAbs(const MV &meas, Double tol = 1e-13) const;
145  // </srcblock>
146  // Dummy for cxx2html
147  void dummy_operator() const {;};
148 
149  //# General Member Functions
150  // Print a MeasValue
151  virtual void print(ostream &os) const = 0;
152 
153  // Clone a MeasValue
154  virtual MeasValue *clone() const = 0;
155 
156  // Get the internal value as a <src>Vector<Double></src>.
157  // Note that the vector could
158  // be empty, or not be a true representation (different data sizes e.g.)
159  virtual Vector<Double> getVector() const = 0;
160 
161  // Get the internal value as a <src>Vector<Quantity></src>. Usable in
162  // records. The getXRecordValue() gets additional information for records.
163  // The getTMRecordValue() gets the record values as deemed appropriate for
164  // the TableMeasures.
165  // Note that the Vectors could be empty.
166  // <group>
167  virtual Vector<Quantum<Double> > getRecordValue() const = 0;
168  virtual Vector<Quantum<Double> > getXRecordValue() const;
169  virtual Vector<Quantum<Double> > getTMRecordValue() const;
170  // </group>
171  // Set the internal value from a Vector of values (obtained in principle
172  // with a getVector()). It will be assumed that the Vector is correctly
173  // formatted. If Vector is too long, the remainder will be discarded.
174  // If Vector is too short, action will depend on the individual classes,
175  // but in general act the same way as a constructor with a short Vector.
176  virtual void putVector(const Vector<Double> &in) = 0;
177 
178  // Set the internal value if correct values and dimensions
179  virtual Bool putValue(const Vector<Quantum<Double> > &in) = 0;
180 
181  // Some of the Measure values used need the occasional adjustments to proper
182  // values. Examples are MVDirection (direction cosines) which have to be
183  // normalised to a length of 1 and MEpoch (time) which have to have its
184  // precision maintained. For others it is an effctive no-operation.
185  // <group>
186  // Adjust value
187  virtual void adjust();
188  // Adjust value and return a normalisation value
189  virtual void adjust(Double &val);
190  // Re-adjust, i.e. undo a previous adjust, with value
191  virtual void readjust(Double val);
192  // </group>
193 private:
194 };
195 
196 //# Global functions
197 // <summary> Global functions </summary>
198 // <group name=Output>
199 // Output declaration
200 ostream &operator<<(ostream &os, const MeasValue &meas);
201 // </group>
202 
203 
204 } //# NAMESPACE CASACORE - END
205 
206 #endif
virtual void readjust(Double val)
Re-adjust, i.e.
ostream & operator<<(ostream &os, const IComplex &)
Show on ostream.
virtual Vector< Double > getVector() const =0
Get the internal value as a Vector&lt;Double&gt;.
virtual Vector< Quantum< Double > > getTMRecordValue() const
virtual ~MeasValue()
Destructor.
virtual void putVector(const Vector< Double > &in)=0
Set the internal value from a Vector of values (obtained in principle with a getVector()).
virtual Vector< Quantum< Double > > getRecordValue() const =0
Get the internal value as a Vector&lt;Quantity&gt;.
Base class for values in a Measure.
Definition: MeasValue.h:107
virtual MeasValue * clone() const =0
Clone a MeasValue.
virtual Vector< Quantum< Double > > getXRecordValue() const
void dummy_operator() const
The following operators should be present at least.
Definition: MeasValue.h:147
double Double
Definition: aipstype.h:55
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
Quantities (i.e. dimensioned values)
Definition: MeasValue.h:41
void dummy_constr() const
Each derived class should have at least the following constructors:
Definition: MeasValue.h:130
virtual Bool putValue(const Vector< Quantum< Double > > &in)=0
Set the internal value if correct values and dimensions.
virtual void print(ostream &os) const =0
Print a MeasValue.
virtual void adjust()
Some of the Measure values used need the occasional adjustments to proper values. ...
friend ostream & operator<<(ostream &os, const MeasValue &meas)
Output a MeasValue.