ExprUDFNode.h

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

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1