casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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>
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  // Copy constructor
88  QBase(const QBase &other);
89  // Construct dimensioned QBase (e.g. 'km/Mpc')
90  // <thrown>
91  // <li> AipsError if non-matching unit dimensions
92  // </thrown>
93  // <group>
94  QBase(const Unit &s);
95  // </group>
96 
97  // Destructor
98  virtual ~QBase();
99 
100  //# Operators
101  // Assignment (copy)
102  QBase &operator=(const QBase &other);
103 
104  //# Member functions
105  // Get units of QBase
106  // <group name="get">
107  // Return the string representation of the current units attached to QBase
108  const String &getUnit() const;
109  // </group>
110 
111  // Re-specify parts of a QBase
112  // <group name="set">
113  // Set new unit, without changing value
114  void setUnit(const Unit &s);
115  // Set new unit, copied from specified QBase, without changing value
116  void setUnit(const QBase &other);
117  // </group>
118 
119  // Check for conformal matching units (e.g. dam and Mpc)
120  // <group name="check">
121  // Using specified units
122  Bool isConform(const Unit &s) const;
123  // Using units specified in QBase
124  Bool isConform(const QBase &other) const;
125  // </group>
126 
127  // Get a copy of Quantum
128  virtual QBase *clone() const = 0;
129  // Get the unit attached to the Quantum (use getUnit() if only interested in
130  // the String part of the unit)
131  virtual const Unit &getFullUnit() const = 0;
132  // Print a Quantum
133  virtual void print(ostream &os) const = 0;
134  // Get the type of derived Quantum (using QuantumType).
135  // All should have:
136  // static uInt myType();
137  virtual uInt type() const = 0;
138 
139 protected:
140  //# Data members
142 };
143 
144 //# Inline Implementations
145 
146 //# Global functions
147 // <summary> Global functions </summary>
148 // <group name=Output>
149 // Output declaration
150 ostream &operator<<(ostream &os, const QBase &meas);
151 LogIO &operator<<(LogIO &os, const QBase &meas);
152 
153 // </group>
154 
155 
156 } //# NAMESPACE CASACORE - END
157 
158 #endif
Base for Quantities (i.e. dimensioned values)
Definition: QBase.h:80
Bool isConform(const Unit &s) const
Check for conformal matching units (e.g.
ostream-like interface to creating log messages.
Definition: LogIO.h:167
QBase()
Default constructor, generates &quot;&quot;.
ostream & operator<<(ostream &os, const std::pair< T, U > &p)
const String & getUnit() const
Get units of QBase.
defines physical units
Definition: Unit.h:189
virtual void print(ostream &os) const =0
Print a Quantum.
Unit qUnit
Definition: QBase.h:141
void setUnit(const Unit &s)
Re-specify parts of a QBase.
virtual QBase * clone() const =0
Get a copy of Quantum.
virtual uInt type() const =0
Get the type of derived Quantum (using QuantumType).
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
virtual ~QBase()
Destructor.
String: the storage and methods of handling collections of characters.
Definition: String.h:223
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...
QBase & operator=(const QBase &other)
Assignment (copy)
unsigned int uInt
Definition: aipstype.h:51
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42