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
34
35namespace casacore { //# NAMESPACE CASACORE - BEGIN
36
37
38// <summary>
39// Unit for scalar values in a table select expression tree
40// </summary>
41
42// <use visibility=local>
43
44// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
45// </reviewed>
46//
47// <prerequisite>
48//# Classes you should understand before using this one.
49// <li> TableExprNode
50// <li> Unit
51// </prerequisite>
52
53// <synopsis>
54// This class represents a unit in a table select expression tree.
55// It contains a unit conversion factor to convert the child to this unit.
56// The factor is 1 if the child has no unit.
57// </synopsis>
58
60{
61public:
62 // Construct from the given child node and unit.
63 TableExprNodeUnit (const TENShPtr& child, const Unit& unit);
64
66
67 // Calculate the conversion factor and return it.
68 // It is static to be useful for TableExprNodeArrayFunc as well.
69 static Double set (TableExprNodeRep& parent,
70 const TENShPtr& child,
71 const Unit& unit);
72
73 // Create a new node if unit conversion is needed.
74 // Otherwise return the current node.
75 static TENShPtr useUnit (const TENShPtr& node,
76 const Unit& unit);
77
78 // Use <src>useUnit</src> to see if a conversion is needed.
79 // If so, adapt the reference counts and replace the node.
80 static void adaptUnit (TENShPtr& node, const Unit& unit);
81
82 // Find the unit to be used and adapt the nodes to it.
83 static Unit adaptUnits (TENShPtr& node1,
84 TENShPtr& node2,
85 TENShPtr& node3);
86
87 // Get the unit factor.
88 virtual Double getUnitFactor() const;
89
90 virtual Double getDouble (const TableExprId& id);
91 virtual DComplex getDComplex (const TableExprId& id);
92private:
94};
95
96
97
98
99// <summary>
100// Unit for array values in a table select expression tree
101// </summary>
102
103// <use visibility=local>
104
105// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
106// </reviewed>
107//
108// <prerequisite>
109//# Classes you should understand before using this one.
110// <li> TableExprNode
111// <li> Unit
112// </prerequisite>
113
114// <synopsis>
115// This class represents a unit in a table select expression tree.
116// It contains a unit conversion factor to convert the child to this unit.
117// The factor is 1 if the child has no unit.
118// </synopsis>
119
131
132
133
134} //# NAMESPACE CASACORE - END
135
136#endif
Unit for array values in a table select expression tree.
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)
Abstract base class for a node having 0, 1, or 2 child nodes.
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.
this file contains all the compiler specific defines
Definition mainpage.dox:28
std::shared_ptr< TableExprNodeRep > TENShPtr
Definition ExprNodeRep.h:55
double Double
Definition aipstype.h:53