casa  5.7.0-16
 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>
36 
37 namespace casacore { //# NAMESPACE CASACORE - BEGIN
38 
39 //# Forward Declarations
40 template <class Qtype> class Quantum;
41 template <class T> class Vector;
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  // Assert that we are the correct MeasValue type
151  // <thrown>
152  // <li> AipsError if wrong MeasValue type
153  // </thrown>
154  // Each Measure should have:
155  // <src> static void assure(const MeasValue &in); </src>
156  // Get the type (== Register(M*)) of derived MeasValue
157  // <group>
158  virtual uInt type() const = 0;
159  // </group>
160  // Print a MeasValue
161  virtual void print(ostream &os) const = 0;
162 
163  // Clone a MeasValue
164  virtual MeasValue *clone() const = 0;
165 
166  // Get the internal value as a <src>Vector<Double></src>.
167  // Note that the vector could
168  // be empty, or not be a true representation (different data sizes e.g.)
169  virtual Vector<Double> getVector() const = 0;
170 
171  // Get the internal value as a <src>Vector<Quantity></src>. Usable in
172  // records. The getXRecordValue() gets additional information for records.
173  // The getTMRecordValue() gets the record values as deemed appropriate for
174  // the TableMeasures.
175  // Note that the Vectors could be empty.
176  // <group>
177  virtual Vector<Quantum<Double> > getRecordValue() const = 0;
178  virtual Vector<Quantum<Double> > getXRecordValue() const;
179  virtual Vector<Quantum<Double> > getTMRecordValue() const;
180  // </group>
181  // Set the internal value from a Vector of values (obtained in principle
182  // with a getVector()). It will be assumed that the Vector is correctly
183  // formatted. If Vector is too long, the remainder will be discarded.
184  // If Vector is too short, action will depend on the individual classes,
185  // but in general act the same way as a constructor with a short Vector.
186  virtual void putVector(const Vector<Double> &in) = 0;
187 
188  // Set the internal value if correct values and dimensions
189  virtual Bool putValue(const Vector<Quantum<Double> > &in) = 0;
190 
191  // Some of the Measure values used need the occasional adjustments to proper
192  // values. Examples are MVDirection (direction cosines) which have to be
193  // normalised to a length of 1 and MEpoch (time) which have to have its
194  // precision maintained. For others it is an effctive no-operation.
195  // <group>
196  // Adjust value
197  virtual void adjust();
198  // Adjust value and return a normalisation value
199  virtual void adjust(Double &val);
200  // Re-adjust, i.e. undo a previous adjust, with value
201  virtual void readjust(Double val);
202  // </group>
203 private:
204 };
205 
206 //# Global functions
207 // <summary> Global functions </summary>
208 // <group name=Output>
209 // Output declaration
210 ostream &operator<<(ostream &os, const MeasValue &meas);
211 // </group>
212 
213 
214 } //# NAMESPACE CASACORE - END
215 
216 #endif
virtual void readjust(Double val)
Re-adjust, i.e.
std::vector< double > Vector
Definition: ds9context.h:24
virtual uInt type() const =0
Assert that we are the correct MeasValue type.
virtual Vector< Double > getVector() const =0
Get the internal value as a Vector&lt;Double&gt;.
ostream & operator<<(ostream &os, const std::pair< T, U > &p)
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
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.
unsigned int uInt
Definition: aipstype.h:51
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42