casa
$Rev:20696$
|
00001 //# ExprUnitNode.h: Nodes representing unit handling in table select expression tree 00002 //# Copyright (C) 2006 00003 //# Associated Universities, Inc. Washington DC, USA. 00004 //# 00005 //# This library is free software; you can redistribute it and/or modify it 00006 //# under the terms of the GNU Library General Public License as published by 00007 //# the Free Software Foundation; either version 2 of the License, or (at your 00008 //# option) any later version. 00009 //# 00010 //# This library is distributed in the hope that it will be useful, but WITHOUT 00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00012 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 00013 //# License for more details. 00014 //# 00015 //# You should have received a copy of the GNU Library General Public License 00016 //# along with this library; if not, write to the Free Software Foundation, 00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. 00018 //# 00019 //# Correspondence concerning AIPS++ should be addressed as follows: 00020 //# Internet email: aips2-request@nrao.edu. 00021 //# Postal address: AIPS++ Project Office 00022 //# National Radio Astronomy Observatory 00023 //# 520 Edgemont Road 00024 //# Charlottesville, VA 22903-2475 USA 00025 //# 00026 //# $Id: ExprUnitNode.h 20551 2009-03-25 00:11:33Z Malte.Marquarding $ 00027 00028 #ifndef TABLES_EXPRUNITNODE_H 00029 #define TABLES_EXPRUNITNODE_H 00030 00031 //# Includes 00032 #include <casa/aips.h> 00033 #include <tables/Tables/ExprNodeRep.h> 00034 #include <tables/Tables/ExprNodeArray.h> 00035 00036 00037 namespace casa { //# NAMESPACE CASA - BEGIN 00038 00039 00040 // <summary> 00041 // Unit for scalar values in a table select expression tree 00042 // </summary> 00043 00044 // <use visibility=local> 00045 00046 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests=""> 00047 // </reviewed> 00048 // 00049 // <prerequisite> 00050 //# Classes you should understand before using this one. 00051 // <li> TableExprNode 00052 // <li> Unit 00053 // </prerequisite> 00054 00055 // <synopsis> 00056 // This class represents a unit in a table select expression tree. 00057 // It contains a unit conversion factor to convert the child to this unit. 00058 // The factor is 1 if the child has no unit. 00059 // </synopsis> 00060 00061 class TableExprNodeUnit : public TableExprNodeBinary 00062 { 00063 public: 00064 // Constrcut from the given child node and unit. 00065 TableExprNodeUnit (TableExprNodeRep& child, const Unit& unit); 00066 00067 ~TableExprNodeUnit(); 00068 00069 // Calculate the conversion factor and return it. 00070 // It is static to be useful for TableExprNodeArrayFunc as well. 00071 static Double set (TableExprNodeRep& parent, 00072 const TableExprNodeRep& child, 00073 const Unit& unit); 00074 00075 // Create a new node if unit conversion is needed. 00076 // Otherwise return the current node. 00077 static TableExprNodeRep* useUnit (TableExprNodeRep* const node, 00078 const Unit& unit); 00079 00080 // Use <src>useUnit</src> to see if a conversion is needed. 00081 // If so, adapt the reference counts and replace the node. 00082 static void adaptUnit (TableExprNodeRep*& node, const Unit& unit); 00083 00084 // Find the unit to be used and adapt the nodes to it. 00085 static Unit adaptUnits (TableExprNodeRep*& node1, 00086 TableExprNodeRep*& node2, 00087 TableExprNodeRep*& node3); 00088 00089 // Get the unit factor. 00090 virtual Double getUnitFactor() const; 00091 00092 virtual Double getDouble (const TableExprId& id); 00093 virtual DComplex getDComplex (const TableExprId& id); 00094 private: 00095 Double factor_p; 00096 }; 00097 00098 00099 00100 00101 // <summary> 00102 // Unit for array values in a table select expression tree 00103 // </summary> 00104 00105 // <use visibility=local> 00106 00107 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests=""> 00108 // </reviewed> 00109 // 00110 // <prerequisite> 00111 //# Classes you should understand before using this one. 00112 // <li> TableExprNode 00113 // <li> Unit 00114 // </prerequisite> 00115 00116 // <synopsis> 00117 // This class represents a unit in a table select expression tree. 00118 // It contains a unit conversion factor to convert the child to this unit. 00119 // The factor is 1 if the child has no unit. 00120 // </synopsis> 00121 00122 class TableExprNodeArrayUnit : public TableExprNodeArray 00123 { 00124 public: 00125 TableExprNodeArrayUnit (TableExprNodeRep& child, const Unit& unit); 00126 ~TableExprNodeArrayUnit(); 00127 virtual Double getUnitFactor() const; 00128 virtual Array<Double> getArrayDouble (const TableExprId& id); 00129 virtual Array<DComplex> getArrayDComplex (const TableExprId& id); 00130 private: 00131 Double factor_p; 00132 }; 00133 00134 00135 00136 } //# NAMESPACE CASA - END 00137 00138 #endif