00001 //# ExprConeNode.h: Class representing a cone search in table select expression 00002 //# Copyright (C) 2005 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: ExprConeNode.h 21262 2012-09-07 12:38:36Z gervandiepen $ 00027 00028 #ifndef TABLES_EXPRCONENODE_H 00029 #define TABLES_EXPRCONENODE_H 00030 00031 //# Includes 00032 #include <casacore/casa/aips.h> 00033 #include <casacore/tables/TaQL/ExprFuncNode.h> 00034 #include <casacore/tables/TaQL/ExprFuncNodeArray.h> 00035 00036 namespace casacore { //# NAMESPACE CASACORE - BEGIN 00037 00038 00039 // <summary> 00040 // Class representing a cone search in table select expression 00041 // </summary> 00042 00043 // <use visibility=local> 00044 00045 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests=""> 00046 // </reviewed> 00047 // <prerequisite> 00048 //# Classes you should understand before using this one. 00049 // <li> <linkto class=TableExprFuncNode>TableExprFuncNode</linkto> 00050 // </prerequisite> 00051 00052 // <synopsis> 00053 // The class represents a cone search. 00054 // It is a specialization of the TableExprFuncNode class. 00055 // Currently the implementation is straightforward, but in the future 00056 // it can do smarter things. 00057 // For instance: 00058 // <ul> 00059 // <li> If the cone positions and radii are constant, one can use 00060 // an integer zone number (e.g. floor(dec)) to avoid the much 00061 // more expensive sine/cosine calculations. Each cone will get a 00062 // minzone and maxzone value (derived from cone position and radius). 00063 // <li> Multiple cones can be ordered on minzone and maxzone. 00064 // </ul> 00065 // </synopsis> 00066 00067 00068 class TableExprConeNode : public TableExprFuncNode 00069 { 00070 public: 00071 // Constructor 00072 TableExprConeNode (FunctionType, NodeDataType, 00073 const TableExprNodeSet& source, uInt origin); 00074 00075 // Destructor 00076 ~TableExprConeNode(); 00077 00078 // 'get' Functions to get the desired result of a function. 00079 // <group> 00080 Bool getBool (const TableExprId& id); 00081 Int64 getInt (const TableExprId& id); 00082 // </group> 00083 00084 // Check the data and value types of the operands. 00085 // It sets the exptected data and value types of the operands. 00086 // Set the value type of the function result and returns 00087 // the data type of the function result. 00088 static NodeDataType checkOperands (Block<Int>& dtypeOper, 00089 ValueType& resVT, 00090 Block<Int>& vtypeOper, 00091 FunctionType, 00092 PtrBlock<TableExprNodeRep*>&); 00093 00094 // Link the children to the node and convert the children 00095 // to constants if possible. Also convert the node to 00096 // constant if possible. 00097 static TableExprNodeRep* fillNode (TableExprConeNode* thisNode, 00098 PtrBlock<TableExprNodeRep*>& nodes, 00099 const Block<Int>& dtypeOper); 00100 00101 // Link the children to the node and convert the children 00102 // to constants if possible. 00103 static void fillChildNodes (TableExprConeNode* thisNode, 00104 PtrBlock<TableExprNodeRep*>& nodes, 00105 const Block<Int>& dtypeOper); 00106 00107 private: 00108 // Try if the function gives a constant result. 00109 // If so, set the expression type to Constant. 00110 void tryToConst(); 00111 00112 // Find the number of elements in an argument. 00113 // It returns -1 if unknown. 00114 static Int findNelem (const TableExprNodeRep* node); 00115 00116 00117 uInt origin_p; 00118 }; 00119 00120 00121 00122 00123 class TableExprConeNodeArray : public TableExprFuncNodeArray 00124 { 00125 public: 00126 // Constructor 00127 TableExprConeNodeArray (TableExprFuncNode::FunctionType, NodeDataType, 00128 const TableExprNodeSet& source, uInt origin); 00129 00130 // Destructor 00131 ~TableExprConeNodeArray(); 00132 00133 // 'get' Functions to get the desired result of a function. 00134 // <group> 00135 MArray<Bool> getArrayBool (const TableExprId& id); 00136 MArray<Int64> getArrayInt (const TableExprId& id); 00137 // </group> 00138 00139 // Link the children to the node and convert the children 00140 // to constants if possible. Also convert the node to 00141 // constant if possible. 00142 static TableExprNodeRep* fillNode (TableExprConeNodeArray* thisNode, 00143 PtrBlock<TableExprNodeRep*>& nodes, 00144 const Block<Int>& dtypeOper); 00145 00146 // Link the children to the node and convert the children 00147 // to constants if possible. 00148 static void fillChildNodes (TableExprConeNodeArray* thisNode, 00149 PtrBlock<TableExprNodeRep*>& nodes, 00150 const Block<Int>& dtypeOper); 00151 00152 private: 00153 // Try if the function gives a constant result. 00154 // If so, set the expression type to Constant. 00155 void tryToConst(); 00156 00157 00158 uInt origin_p; 00159 }; 00160 00161 00162 } //# NAMESPACE CASACORE - END 00163 00164 #endif