casacore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ExprUnitNode.h
Go to the documentation of this file.
1 //# ExprUnitNode.h: Nodes representing unit handling in table select expression tree
2 //# Copyright (C) 2006
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: ExprUnitNode.h 21262 2012-09-07 12:38:36Z gervandiepen $
27 
28 #ifndef TABLES_EXPRUNITNODE_H
29 #define TABLES_EXPRUNITNODE_H
30 
31 //# Includes
32 #include <casacore/casa/aips.h>
35 
36 
37 namespace casacore { //# NAMESPACE CASACORE - BEGIN
38 
39 
40 // <summary>
41 // Unit for scalar values in a table select expression tree
42 // </summary>
43 
44 // <use visibility=local>
45 
46 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
47 // </reviewed>
48 //
49 // <prerequisite>
50 //# Classes you should understand before using this one.
51 // <li> TableExprNode
52 // <li> Unit
53 // </prerequisite>
54 
55 // <synopsis>
56 // This class represents a unit in a table select expression tree.
57 // It contains a unit conversion factor to convert the child to this unit.
58 // The factor is 1 if the child has no unit.
59 // </synopsis>
60 
62 {
63 public:
64  // Construct from the given child node and unit.
65  TableExprNodeUnit (const TENShPtr& child, const Unit& unit);
66 
68 
69  // Calculate the conversion factor and return it.
70  // It is static to be useful for TableExprNodeArrayFunc as well.
71  static Double set (TableExprNodeRep& parent,
72  const TENShPtr& child,
73  const Unit& unit);
74 
75  // Create a new node if unit conversion is needed.
76  // Otherwise return the current node.
77  static TENShPtr useUnit (const TENShPtr& node,
78  const Unit& unit);
79 
80  // Use <src>useUnit</src> to see if a conversion is needed.
81  // If so, adapt the reference counts and replace the node.
82  static void adaptUnit (TENShPtr& node, const Unit& unit);
83 
84  // Find the unit to be used and adapt the nodes to it.
85  static Unit adaptUnits (TENShPtr& node1,
86  TENShPtr& node2,
87  TENShPtr& node3);
88 
89  // Get the unit factor.
90  virtual Double getUnitFactor() const;
91 
92  virtual Double getDouble (const TableExprId& id);
93  virtual DComplex getDComplex (const TableExprId& id);
94 private:
96 };
97 
98 
99 
100 
101 // <summary>
102 // Unit for array values in a table select expression tree
103 // </summary>
104 
105 // <use visibility=local>
106 
107 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
108 // </reviewed>
109 //
110 // <prerequisite>
111 //# Classes you should understand before using this one.
112 // <li> TableExprNode
113 // <li> Unit
114 // </prerequisite>
115 
116 // <synopsis>
117 // This class represents a unit in a table select expression tree.
118 // It contains a unit conversion factor to convert the child to this unit.
119 // The factor is 1 if the child has no unit.
120 // </synopsis>
121 
123 {
124 public:
125  TableExprNodeArrayUnit (const TENShPtr& child, const Unit& unit);
127  virtual Double getUnitFactor() const;
128  virtual MArray<Double> getArrayDouble (const TableExprId& id);
129  virtual MArray<DComplex> getArrayDComplex (const TableExprId& id);
130 private:
132 };
133 
134 
135 
136 } //# NAMESPACE CASACORE - END
137 
138 #endif
virtual Double getDouble(const TableExprId &id)
TableExprNodeArrayUnit(const TENShPtr &child, const Unit &unit)
virtual MArray< DComplex > getArrayDComplex(const TableExprId &id)
The default implementation of getArrayDComplex does getArrayDouble and converts the result...
virtual DComplex getDComplex(const TableExprId &id)
Base class for arrays in table select expression.
Definition: ExprNodeArray.h:65
Abstract base class for a node in a table column expression tree.
Definition: ExprNodeRep.h:157
virtual Double getUnitFactor() const
Get the unit conversion factor.
defines physical units
Definition: Unit.h:189
static Unit adaptUnits(TENShPtr &node1, TENShPtr &node2, TENShPtr &node3)
Find the unit to be used and adapt the nodes to it.
virtual Double getUnitFactor() const
Get the unit factor.
double Double
Definition: aipstype.h:55
Unit for array values in a table select expression tree.
Definition: ExprUnitNode.h:122
const Unit & unit() const
Get the unit.
Definition: ExprNodeRep.h:731
TableExprNodeUnit(const TENShPtr &child, const Unit &unit)
Construct from the given child node and unit.
static void adaptUnit(TENShPtr &node, const Unit &unit)
Use useUnit to see if a conversion is needed.
static Double set(TableExprNodeRep &parent, const TENShPtr &child, const Unit &unit)
Calculate the conversion factor and return it.
The identification of a TaQL selection subject.
Definition: TableExprId.h:97
virtual MArray< Double > getArrayDouble(const TableExprId &id)
The default implementation of getArrayDouble does getArrayInt and converts the result.
static TENShPtr useUnit(const TENShPtr &node, const Unit &unit)
Create a new node if unit conversion is needed.
Unit for scalar values in a table select expression tree.
Definition: ExprUnitNode.h:61
Abstract base class for a node having 0, 1, or 2 child nodes.
Definition: ExprNodeRep.h:558