casacore
Loading...
Searching...
No Matches
ExprUDFNode.h
Go to the documentation of this file.
1// # ExprUDFNode.h: Class representing a scalar UDF in select expression
2// # Copyright (C) 2010
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_EXPRUDFNODE_H
27#define TABLES_EXPRUDFNODE_H
28
29// # Includes
30#include <casacore/casa/aips.h>
31#include <casacore/tables/TaQL/ExprNodeRep.h>
32#include <casacore/tables/TaQL/UDFBase.h>
33
34namespace casacore { // # NAMESPACE CASACORE - BEGIN
35
36// # Forward Declarations
38
39// <summary>
40// Class representing a scalar UDF in select expression
41// </summary>
42
43// <use visibility=local>
44
45// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
46// </reviewed>
47// <prerequisite>
48// # Classes you should understand before using this one.
49// <li> <linkto class=TableExprNodeMulti>TableExprNodeMulti</linkto>
50// </prerequisite>
51
52// <synopsis>
53// This class represents a function in a table select tree.
54// The <src>rownumber</src> function is represented by class
55// <linkto class=TableExprNodeRownr>TableExprNodeRownr</linkto>.
56// The <src>rowid</src> function is represented by class
57// <linkto class=TableExprNodeRowid>TableExprNodeRowid</linkto>.
58// The <src>rand</src> function is represented by class
59// <linkto class=TableExprNodeRandom>TableExprNodeRandom</linkto>.
60// <p>
61// When one wants to add a function to the table selection grammar,
62// the following has to be done:
63// <ul>
64// <li> Add the function to the enum below.
65// <li> Implement the function in the get functions in ExprFuncNode(Array).cc.
66// <li> Implement the function in the checkOperands in ExprFuncNode.cc.
67// <li> Declare and define the function in ExprNode.h (for C++ binding).
68// <li> Add the function to findFunc in TableParse.cc (for TaQL).
69// </ul>
70// </synopsis>
71
73 public:
74 // Constructor
75 TableExprUDFNode(const std::shared_ptr<UDFBase>& udf, const TableExprInfo&,
76 const TableExprNodeSet& source);
77
78 // Destructor
79 ~TableExprUDFNode() override = default;
80
81 // Is the UDF an aggregate function?
82 Bool isAggregate() const override { return itsUDF->isAggregate(); }
83
84 // Get the table info.
85 TableExprInfo getTableInfo() const override;
86
87 // Flatten the node tree by adding the node and its children to the vector.
88 void flattenTree(std::vector<TableExprNodeRep*>&) override;
89
90 // Do not apply the selection.
91 void disableApplySelection() override;
92
93 // If needed, let the UDF re-create column objects for a selection of rows.
94 // It calls the function recreateColumnObjects.
95 void applySelection(const Vector<rownr_t>& rownrs) override;
96
97 // UDFs do not need a TableExprGroupFuncBase,
98 // so TableExprGroupNull is returned.
99 std::shared_ptr<TableExprGroupFuncBase> makeGroupAggrFunc() override;
100
101 // Functions to get the desired result of a function
102 // <group>
103 Bool getBool(const TableExprId& id) override;
104 Int64 getInt(const TableExprId& id) override;
105 Double getDouble(const TableExprId& id) override;
106 DComplex getDComplex(const TableExprId& id) override;
107 String getString(const TableExprId& id) override;
108 TaqlRegex getRegex(const TableExprId& id) override;
109 MVTime getDate(const TableExprId& id) override;
110 // </group>
111
112 private:
114 std::shared_ptr<UDFBase> itsUDF;
115};
116
117} // namespace casacore
118
119#endif
String: the storage and methods of handling collections of characters.
Definition String.h:355
Class to connect a Table and its alias name.
TableExprNodeMulti(NodeDataType, ValueType, OperType, const TableExprNodeRep &source)
Constructor.
TableExprUDFNode(const std::shared_ptr< UDFBase > &udf, const TableExprInfo &, const TableExprNodeSet &source)
Constructor.
MVTime getDate(const TableExprId &id) override
Double getDouble(const TableExprId &id) override
DComplex getDComplex(const TableExprId &id) override
std::shared_ptr< UDFBase > itsUDF
TaqlRegex getRegex(const TableExprId &id) override
void disableApplySelection() override
Do not apply the selection.
std::shared_ptr< TableExprGroupFuncBase > makeGroupAggrFunc() override
UDFs do not need a TableExprGroupFuncBase, so TableExprGroupNull is returned.
void flattenTree(std::vector< TableExprNodeRep * > &) override
Flatten the node tree by adding the node and its children to the vector.
~TableExprUDFNode() override=default
Destructor.
TableExprInfo getTableInfo() const override
Get the table info.
Bool getBool(const TableExprId &id) override
Functions to get the desired result of a function.
void applySelection(const Vector< rownr_t > &rownrs) override
If needed, let the UDF re-create column objects for a selection of rows.
String getString(const TableExprId &id) override
Bool isAggregate() const override
Is the UDF an aggregate function?
Definition ExprUDFNode.h:82
Int64 getInt(const TableExprId &id) override
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28
long long Int64
Define the extra non-standard types used by Casacore (like proposed uSize, Size).
Definition aipsxtype.h:36
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40
double Double
Definition aipstype.h:53