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