00001 //# ExprUDFNodeArray.h: Class representing an array UDF in select expression 00002 //# Copyright (C) 2010 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: ExprUDFNodeArray.h 21262 2012-09-07 12:38:36Z gervandiepen $ 00027 00028 #ifndef TABLES_EXPRUDFNODEARRAY_H 00029 #define TABLES_EXPRUDFNODEARRAY_H 00030 00031 //# Includes 00032 #include <casacore/tables/TaQL/ExprNodeArray.h> 00033 #include <casacore/tables/TaQL/UDFBase.h> 00034 00035 namespace casacore { //# NAMESPACE CASACORE - BEGIN 00036 00037 //# Forward Declarations 00038 class TableExprNodeSet; 00039 00040 // <summary> 00041 // Class representing an array UDF in select expression 00042 // </summary> 00043 00044 // <use visibility=local> 00045 00046 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests=""> 00047 // </reviewed> 00048 // <prerequisite> 00049 //# Classes you should understand before using this one. 00050 // <li> <linkto class=TableExprNodeMulti>TableExprNodeMulti</linkto> 00051 // </prerequisite> 00052 00053 // <synopsis> 00054 // This class represents a function in a table select tree. 00055 // The <src>rownumber</src> function is represented by class 00056 // <linkto class=TableExprNodeRownr>TableExprNodeRownr</linkto>. 00057 // The <src>rowid</src> function is represented by class 00058 // <linkto class=TableExprNodeRowid>TableExprNodeRowid</linkto>. 00059 // The <src>rand</src> function is represented by class 00060 // <linkto class=TableExprNodeRandom>TableExprNodeRandom</linkto>. 00061 // <p> 00062 // When one wants to add a function to the table selection grammar, 00063 // the following has to be done: 00064 // <ul> 00065 // <li> Add the function to the enum below. 00066 // <li> Implement the function in the get functions in ExprFuncNode(Array).cc. 00067 // <li> Implement the function in the checkOperands in ExprFuncNode.cc. 00068 // <li> Declare and define the function in ExprNode.h (for C++ binding). 00069 // <li> Add the function to findFunc in TableParse.cc (for TaQL). 00070 // </ul> 00071 // </synopsis> 00072 00073 00074 class TableExprUDFNodeArray: public TableExprNodeArray 00075 { 00076 public: 00077 00078 // Constructor 00079 TableExprUDFNodeArray (UDFBase* udf, const Table&, 00080 const TableExprNodeSet& source); 00081 00082 // Destructor 00083 virtual ~TableExprUDFNodeArray(); 00084 00085 // Get the nodes representing an aggregate function. 00086 virtual void getAggrNodes (vector<TableExprNodeRep*>& aggr); 00087 00088 // Get the nodes representing a table column. 00089 virtual void getColumnNodes (vector<TableExprNodeRep*>& cols); 00090 00091 // Do not apply the selection. 00092 virtual void disableApplySelection(); 00093 00094 // If needed, let the UDF re-create column objects for a selection of rows. 00095 // It calls the function recreateColumnObjects. 00096 virtual void applySelection (const Vector<uInt>& rownrs); 00097 00098 // UDFs do not need a TableExprGroupFuncBase, so null is returned. 00099 CountedPtr<TableExprGroupFuncBase> makeGroupAggrFunc(); 00100 00101 // Functions to get the desired result of a function 00102 // <group> 00103 virtual MArray<Bool> getArrayBool (const TableExprId& id); 00104 virtual MArray<Int64> getArrayInt (const TableExprId& id); 00105 virtual MArray<Double> getArrayDouble (const TableExprId& id); 00106 virtual MArray<DComplex> getArrayDComplex (const TableExprId& id); 00107 virtual MArray<String> getArrayString (const TableExprId& id); 00108 virtual MArray<MVTime> getArrayDate (const TableExprId& id); 00109 // </group> 00110 00111 private: 00112 UDFBase* itsUDF; 00113 }; 00114 00115 00116 } //# NAMESPACE CASACORE - END 00117 00118 #endif