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