casacore
Loading...
Searching...
No Matches
MeasRef.h
Go to the documentation of this file.
1//# MeasRef.h: Reference frame for physical measures
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_MEASREF_H
30#define MEASURES_MEASREF_H
31
32//# Includes
33#include <casacore/casa/aips.h>
34#include <casacore/measures/Measures/MRBase.h>
35#include <casacore/measures/Measures/MeasFrame.h>
36#include <casacore/casa/iosfwd.h>
37#include <casacore/casa/Utilities/CountedPtr.h>
38
39namespace casacore { //# NAMESPACE CASACORE - BEGIN
40
41//# Forward Declarations
42class String;
43template <class Ms> class MeasRef;
44
45// <summary> Reference frame for physical measures </summary>
46
47// <use visibility=export>
48
49// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="tMeasure" demos="">
50// </reviewed>
51
52// <prerequisite>
53// <li> <linkto class=MRBase>MRBase</linkto>: the MeasRef base class
54// <li> <linkto class=Quantum>Quantum</linkto> class
55// <li> <linkto class=Measure>Measure</linkto> class
56// </prerequisite>
57//
58// <etymology>
59// From Measure and Reference frame
60// </etymology>
61//
62// <synopsis>
63// MeasRef specifies the reference frame for a physical quantity
64// specified by one of the derived <linkto class=Measure>Measure</linkto>
65// classes (e.g. <linkto class=MEpoch>MEpoch</linkto>). It is derived from
66// <linkto class=MRBase>MRBase</linkto>, which describes the class.
67//
68// MeasRef containres are created using the <src>Measure::Ref</src> class
69// (e.g. <src>MDirection::Ref</src>).
70// </synopsis>
71//
72// <example>
73// See <linkto class=Measure>Measure</linkto> for an example
74// </example>
75//
76// <motivation>
77// To gather all reference frame information in the one class.
78// </motivation>
79//
80// <todo asof="1997/04/15">
81// </todo>
82
83template<class Ms> class MeasRef : public MRBase {
84
85public:
86
87 //# Friends
88
89 //# Constructors
90 // Construct an empty MeasRef. I.e. it will have a standard,
91 // <em>default</em>, type; no offsets and Frame.
93 // Copy constructor
94 MeasRef(const MeasRef<Ms> &other);
95 // Copy assignment
97 // Construct a reference with specified type, offset and Frame
98 // <group>
99 // <note role=caution> The following should really be (and should
100 // still be called as), but
101 // compiler does not accept it, due to incomplete definition when
102 // called in MeasBase: </note>
103 // <src> MeasRef(Ms::Types tp); </src>
104 // Furthermore, default arguments are not supported with templated classes:
105 explicit MeasRef(const uInt tp);
106 MeasRef(const uInt tp, const Ms &ep);
107 MeasRef(const uInt tp, const MeasFrame &mf);
108 MeasRef(const uInt tp, const MeasFrame &mf, const Ms &ep);
109 // </group>
110
111 //# Destructor
113
114 //# Operators
115 // Check if same MeasRef
116 Bool operator==(const MeasRef<Ms> &other) const;
117 // Check if unequal MeasRef
118 Bool operator!=(const MeasRef<Ms> &other) const;
119
120 //# General Member Functions
121 // Check if empty reference
122 virtual Bool empty() const;
123 // Check the type of Measure the reference can be used for
124 // <group>
125 static const String &showMe();
126 // </group>
127 // Return the type of the reference
128 // <note role=caution> the following should really be
129 // (and should be interpreted as), but
130 // cannot create a virtual function:</note>
131 // <src> Ms::Types getType();</src>
132 virtual uInt getType() const;
133 // Return the frame of reference
134 virtual MeasFrame &getFrame();
135 // Return the first frame which has specified information. Checking is done in
136 // argument order.
137 // <thrown>
138 // <li> AipsError if neither reference has a frame or the proper type
139 // </thrown>
140 // <group>
141 static const MeasFrame &framePosition(MRBase &ref1,
142 MRBase &ref2);
143 static const MeasFrame &frameEpoch(MRBase &ref1,
144 MRBase &ref2);
145 static const MeasFrame &frameDirection(MRBase &ref1,
146 MRBase &ref2);
148 MRBase &ref2);
149 static const MeasFrame &frameComet(MRBase &ref1,
150 MRBase &ref2);
151 // </group>
152 // Return the offset (or 0)
153 virtual const Measure* offset() const;
154 // Set the type
155 // <thrown>
156 // <li> AipsError if wrong Measure
157 // </thrown>
158 // <note role=caution> the following should really be
159 // (and should be called as), but
160 // compiler does not accept it, since a virtual function:</note>
161 // <src> void set(Ms::Types tp);</src>
162 // <group>
163 virtual void setType(uInt tp);
164 virtual void set(uInt tp);
165 // </group>
166 // Set a new offset
167 void set(const Ms &ep);
168 // Set a new offset (for internal use only)
169 void set(const Measure &ep);
170 // Set a new frame
171 virtual void set(const MeasFrame &mf);
172
173 // Print a Measure
174 virtual void print(ostream &os) const;
175
176private:
177
178 // Representation class
179 class RefRep {
180 public:
181 // Constructor
182 // <note role=warning> Next one must be in-line for (some?) compilers </note>
183 RefRep() : type(Ms::DEFAULT), offmp(0), frame() {}
184 // Destructor
185 // <note role=warning> Next one must be in-line for (some?) compilers </note>
186 ~RefRep() {delete offmp;}
187 // The actual data
188 // <group>
189 // Type of reference
190 typename Ms::Types type;
191 // Pointer to main Measure, defining an offset
193 // Reference frame
195 // </group>
196 };
197
198 //# Data
200
201 //# Member functions
202 // Create an instance of MeasRef
203 void create();
204
205 // Copy an instance
207};
208
209
210} //# NAMESPACE CASACORE - END
211
212#ifndef CASACORE_NO_AUTO_TEMPLATES
213#include <casacore/measures/Measures/MeasRef.tcc>
214#endif //# CASACORE_NO_AUTO_TEMPLATES
215#endif
Referenced counted pointer for constant data.
Definition CountedPtr.h:81
Representation class.
Definition MeasRef.h:179
RefRep()
Constructor Warning: Next one must be in-line for (some?) compilers
Definition MeasRef.h:183
MeasFrame frame
Reference frame.
Definition MeasRef.h:194
~RefRep()
Destructor Warning: Next one must be in-line for (some?) compilers
Definition MeasRef.h:186
Measure * offmp
Pointer to main Measure, defining an offset.
Definition MeasRef.h:192
Ms::Types type
The actual data.
Definition MeasRef.h:190
static const MeasFrame & frameRadialVelocity(MRBase &ref1, MRBase &ref2)
void set(const Measure &ep)
Set a new offset (for internal use only)
MeasRef(const uInt tp, const Ms &ep)
MeasRef()
Construct an empty MeasRef.
static const MeasFrame & frameComet(MRBase &ref1, MRBase &ref2)
Bool operator!=(const MeasRef< Ms > &other) const
Check if unequal MeasRef.
static const MeasFrame & frameEpoch(MRBase &ref1, MRBase &ref2)
MeasRef(const uInt tp)
Construct a reference with specified type, offset and Frame.
virtual void print(ostream &os) const
Print a Measure.
static const MeasFrame & framePosition(MRBase &ref1, MRBase &ref2)
Return the first frame which has specified information.
void set(const Ms &ep)
Set a new offset.
virtual uInt getType() const
Return the type of the reference Caution: the following should really be (and should be interpreted ...
virtual void set(uInt tp)
static const MeasFrame & frameDirection(MRBase &ref1, MRBase &ref2)
MeasRef(const uInt tp, const MeasFrame &mf)
MeasRef copy()
Copy an instance.
CountedPtr< RefRep > rep_p
Definition MeasRef.h:199
MeasRef & operator=(const MeasRef< Ms > &other)
Copy assignment.
virtual void setType(uInt tp)
Set the type.
static const String & showMe()
Check the type of Measure the reference can be used for.
virtual Bool empty() const
Check if empty reference.
Bool operator==(const MeasRef< Ms > &other) const
Check if same MeasRef.
virtual const Measure * offset() const
Return the offset (or 0)
virtual void set(const MeasFrame &mf)
Set a new frame.
MeasRef(const MeasRef< Ms > &other)
Copy constructor.
virtual MeasFrame & getFrame()
Return the frame of reference.
void create()
Create an instance of MeasRef.
MeasRef(const uInt tp, const MeasFrame &mf, const Ms &ep)
String: the storage and methods of handling collections of characters.
Definition String.h:225
this file contains all the compiler specific defines
Definition mainpage.dox:28
unsigned int uInt
Definition aipstype.h:51
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:42