casacore
Loading...
Searching...
No Matches
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: 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 TABLES_EXPRUNITNODE_H
27#define TABLES_EXPRUNITNODE_H
28
29// # Includes
30#include <casacore/casa/aips.h>
31#include <casacore/tables/TaQL/ExprNodeRep.h>
32#include <casacore/tables/TaQL/ExprNodeArray.h>
33
34namespace casacore { // # NAMESPACE CASACORE - BEGIN
35
36// <summary>
37// Unit for scalar values in a table select expression tree
38// </summary>
39
40// <use visibility=local>
41
42// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
43// </reviewed>
44//
45// <prerequisite>
46// # Classes you should understand before using this one.
47// <li> TableExprNode
48// <li> Unit
49// </prerequisite>
50
51// <synopsis>
52// This class represents a unit in a table select expression tree.
53// It contains a unit conversion factor to convert the child to this unit.
54// The factor is 1 if the child has no unit.
55// </synopsis>
56
58 public:
59 // Construct from the given child node and unit.
60 TableExprNodeUnit(const TENShPtr& child, const Unit& unit);
61
63
64 // Calculate the conversion factor and return it.
65 // It is static to be useful for TableExprNodeArrayFunc as well.
66 static Double set(TableExprNodeRep& parent, const TENShPtr& child, const Unit& unit);
67
68 // Create a new node if unit conversion is needed.
69 // Otherwise return the current node.
70 static TENShPtr useUnit(const TENShPtr& node, const Unit& unit);
71
72 // Use <src>useUnit</src> to see if a conversion is needed.
73 // If so, adapt the reference counts and replace the node.
74 static void adaptUnit(TENShPtr& node, const Unit& unit);
75
76 // Find the unit to be used and adapt the nodes to it.
77 static Unit adaptUnits(TENShPtr& node1, TENShPtr& node2, TENShPtr& node3);
78
79 // Get the unit factor.
80 virtual Double getUnitFactor() const;
81
82 virtual Double getDouble(const TableExprId& id);
83 virtual DComplex getDComplex(const TableExprId& id);
84
85 private:
87};
88
89// <summary>
90// Unit for array values in a table select expression tree
91// </summary>
92
93// <use visibility=local>
94
95// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
96// </reviewed>
97//
98// <prerequisite>
99// # Classes you should understand before using this one.
100// <li> TableExprNode
101// <li> Unit
102// </prerequisite>
103
104// <synopsis>
105// This class represents a unit in a table select expression tree.
106// It contains a unit conversion factor to convert the child to this unit.
107// The factor is 1 if the child has no unit.
108// </synopsis>
109
121
122} // namespace casacore
123
124#endif
virtual MArray< Double > getArrayDouble(const TableExprId &id)
The default implementation of getArrayDouble does getArrayInt and converts the result.
virtual Double getUnitFactor() const
Get the unit conversion factor.
virtual MArray< DComplex > getArrayDComplex(const TableExprId &id)
The default implementation of getArrayDComplex does getArrayDouble and converts the result.
TableExprNodeArrayUnit(const TENShPtr &child, const Unit &unit)
TableExprNodeArray(NodeDataType, OperType)
Create the object.
TableExprNodeBinary(NodeDataType, ValueType, OperType, ExprType)
Constructor.
Abstract base class for a node in a table column expression tree.
const Unit & unit() const
Get the unit.
virtual Double getUnitFactor() const
Get the unit factor.
static TENShPtr useUnit(const TENShPtr &node, const Unit &unit)
Create a new node if unit conversion is needed.
static void adaptUnit(TENShPtr &node, const Unit &unit)
Use useUnit to see if a conversion is needed.
virtual Double getDouble(const TableExprId &id)
static Unit adaptUnits(TENShPtr &node1, TENShPtr &node2, TENShPtr &node3)
Find the unit to be used and adapt the nodes to it.
virtual DComplex getDComplex(const TableExprId &id)
static Double set(TableExprNodeRep &parent, const TENShPtr &child, const Unit &unit)
Calculate the conversion factor and return it.
TableExprNodeUnit(const TENShPtr &child, const Unit &unit)
Construct from the given child node and unit.
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28
std::shared_ptr< TableExprNodeRep > TENShPtr
Definition ExprNodeRep.h:56
double Double
Definition aipstype.h:53