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>
41class MeasRef;
42
43// <summary> Reference frame for physical measures </summary>
44
45// <use visibility=export>
46
47// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="tMeasure" demos="">
48// </reviewed>
49
50// <prerequisite>
51// <li> <linkto class=MRBase>MRBase</linkto>: the MeasRef base class
52// <li> <linkto class=Quantum>Quantum</linkto> class
53// <li> <linkto class=Measure>Measure</linkto> class
54// </prerequisite>
55//
56// <etymology>
57// From Measure and Reference frame
58// </etymology>
59//
60// <synopsis>
61// MeasRef specifies the reference frame for a physical quantity
62// specified by one of the derived <linkto class=Measure>Measure</linkto>
63// classes (e.g. <linkto class=MEpoch>MEpoch</linkto>). It is derived from
64// <linkto class=MRBase>MRBase</linkto>, which describes the class.
65//
66// MeasRef containres are created using the <src>Measure::Ref</src> class
67// (e.g. <src>MDirection::Ref</src>).
68// </synopsis>
69//
70// <example>
71// See <linkto class=Measure>Measure</linkto> for an example
72// </example>
73//
74// <motivation>
75// To gather all reference frame information in the one class.
76// </motivation>
77//
78// <todo asof="1997/04/15">
79// </todo>
80
81template <class Ms>
82class MeasRef : public MRBase {
83 public:
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, MRBase &ref2);
139 static const MeasFrame &frameEpoch(MRBase &ref1, MRBase &ref2);
140 static const MeasFrame &frameDirection(MRBase &ref1, MRBase &ref2);
141 static const MeasFrame &frameRadialVelocity(MRBase &ref1, MRBase &ref2);
142 static const MeasFrame &frameComet(MRBase &ref1, MRBase &ref2);
143 // </group>
144 // Return the offset (or 0)
145 virtual const Measure *offset() const;
146 // Set the type
147 // <thrown>
148 // <li> AipsError if wrong Measure
149 // </thrown>
150 // <note role=caution> the following should really be
151 // (and should be called as), but
152 // compiler does not accept it, since a virtual function:</note>
153 // <src> void set(Ms::Types tp);</src>
154 // <group>
155 virtual void setType(uInt tp);
156 virtual void set(uInt tp);
157 // </group>
158 // Set a new offset
159 void set(const Ms &ep);
160 // Set a new offset (for internal use only)
161 void set(const Measure &ep);
162 // Set a new frame
163 virtual void set(const MeasFrame &mf);
164
165 // Print a Measure
166 virtual void print(ostream &os) const;
167
168 private:
169 // Representation class
170 class RefRep {
171 public:
172 // Constructor
173 // <note role=warning> Next one must be in-line for (some?) compilers </note>
174 RefRep() = default;
175 // The actual data
176 // <group>
177 // Type of reference
178 typename Ms::Types type = Ms::DEFAULT;
179 // Pointer to main Measure, defining an offset
180 std::unique_ptr<Measure> offmp;
181 // Reference frame
183 // </group>
184 };
185
186 // # Data
187 std::shared_ptr<RefRep> rep_p;
188
189 // # Member functions
190 // Create an instance of MeasRef
191 void create();
192
193 // Copy an instance
195};
196
197} // namespace casacore
198
199#ifndef CASACORE_NO_AUTO_TEMPLATES
200#include <casacore/measures/Measures/MeasRef.tcc>
201#endif // # CASACORE_NO_AUTO_TEMPLATES
202#endif
MeasFrame frame
Reference frame.
Definition MeasRef.h:182
std::unique_ptr< Measure > offmp
Pointer to main Measure, defining an offset.
Definition MeasRef.h:180
Ms::Types type
The actual data.
Definition MeasRef.h:178
RefRep()=default
Constructor Warning: Next one must be in-line for (some?) compilers .
static const MeasFrame & frameRadialVelocity(MRBase &ref1, MRBase &ref2)
std::shared_ptr< RefRep > rep_p
Definition MeasRef.h:187
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:355
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28
unsigned int uInt
Definition aipstype.h:49
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40