casacore
QBase.h
Go to the documentation of this file.
1 //# QBase.h: base class for Quantum
2 //# Copyright (C) 1994,1995,1996,1998,1999
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 //# $Id$
27 
28 #ifndef CASA_QBASE_H
29 #define CASA_QBASE_H
30 
31 
32 //# Includes
33 #include <casacore/casa/aips.h>
34 #include <casacore/casa/Quanta/Unit.h>
35 
36 namespace casacore { //# NAMESPACE CASACORE - BEGIN
37 
38 //# Forward Declarations
39 
40 class LogIO;
41 
42 //# Typedefs
43 
44 //
45 // <summary>
46 // Base for Quantities (i.e. dimensioned values)
47 // </summary>
48 
49 // <use visibility=local>
50 
51 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="tQuantum">
52 //
53 // <prerequisite>
54 // <li> <linkto class=Unit>Unit</linkto>
55 // </prerequisite>
56 //
57 // <etymology>
58 // QBase is the base class for <linkto class=Quantum>Quantum</linkto>.
59 // </etymology>
60 //
61 // <synopsis>
62 // Quantities are values with a unit. Their basic specification can be one of
63 // two forms:
64 // <srcblock>
65 // Quantity( Double value, String unit); // or: Unit unit
66 // Quantum<Type> ( Type value, String unit) // or: Unit unit
67 // </srcblock>
68 // See <linkto class=Quantum>Quantum</linkto> for details.
69 // </synopsis>
70 //
71 // <motivation>
72 // To provide the possibilty of mixing units from different
73 // <src>Quantum<T1></src>, <src>Quantum<T2></src>
74 // </motivation>
75 //
76 // <todo asof="941123">
77 // <li> Some inlining (did not work first go)
78 // </todo>
79 
80 class QBase {
81  //# Friends
82 
83 public:
84  //# Constructors
85  // Default constructor, generates ""
86  QBase();
87  // Construct dimensioned QBase (e.g. 'km/Mpc')
88  // <thrown>
89  // <li> AipsError if non-matching unit dimensions
90  // </thrown>
91  // <group>
92  QBase(const Unit &s);
93  // </group>
94 
95  // Destructor
96  virtual ~QBase();
97 
98  //# Member functions
99  // Get units of QBase
100  // <group name="get">
101  // Return the string representation of the current units attached to QBase
102  const String &getUnit() const;
103  // </group>
104 
105  // Re-specify parts of a QBase
106  // <group name="set">
107  // Set new unit, without changing value
108  void setUnit(const Unit &s);
109  // Set new unit, copied from specified QBase, without changing value
110  void setUnit(const QBase &other);
111  // </group>
112 
113  // Check for conformal matching units (e.g. dam and Mpc)
114  // <group name="check">
115  // Using specified units
116  Bool isConform(const Unit &s) const;
117  // Using units specified in QBase
118  Bool isConform(const QBase &other) const;
119  // </group>
120 
121  // Get a copy of Quantum
122  virtual QBase *clone() const = 0;
123  // Get the unit attached to the Quantum (use getUnit() if only interested in
124  // the String part of the unit)
125  virtual const Unit &getFullUnit() const = 0;
126  // Print a Quantum
127  virtual void print(ostream &os) const = 0;
128  // Get the type of derived Quantum (using QuantumType).
129  // All should have:
130  // static uInt myType();
131  virtual uInt type() const = 0;
132 
133 protected:
134  //# Data members
136 };
137 
138 //# Inline Implementations
139 
140 //# Global functions
141 // <summary> Global functions </summary>
142 // <group name=Output>
143 // Output declaration
144 ostream &operator<<(ostream &os, const QBase &meas);
145 LogIO &operator<<(LogIO &os, const QBase &meas);
146 
147 // </group>
148 
149 
150 } //# NAMESPACE CASACORE - END
151 
152 #endif
virtual const Unit & getFullUnit() const =0
Get the unit attached to the Quantum (use getUnit() if only interested in the String part of the unit...
virtual QBase * clone() const =0
Get a copy of Quantum.
const String & getUnit() const
Get units of QBase
Unit qUnit
Definition: QBase.h:135
void setUnit(const Unit &s)
Re-specify parts of a QBase
QBase(const Unit &s)
Construct dimensioned QBase (e.g.
virtual ~QBase()
Destructor.
Bool isConform(const Unit &s) const
Check for conformal matching units (e.g.
virtual void print(ostream &os) const =0
Print a Quantum.
QBase()
Default constructor, generates "".
virtual uInt type() const =0
Get the type of derived Quantum (using QuantumType).
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
ostream & operator<<(ostream &os, const IComplex &)
Show on ostream.