casacore
Loading...
Searching...
No Matches
ExprDerNode.h
Go to the documentation of this file.
1//# ExprDerNode.h: Nodes representing scalars in table select expression tree
2//# Copyright (C) 1994,1995,1996,1997,1999,2000,2001
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_EXPRDERNODE_H
27#define TABLES_EXPRDERNODE_H
28
29//# Includes
30#include <casacore/casa/aips.h>
31#include <casacore/tables/TaQL/ExprNodeRep.h>
32#include <casacore/tables/Tables/TableColumn.h>
33#include <casacore/casa/Arrays/Vector.h>
34#include <casacore/casa/BasicMath/Random.h>
35
36namespace casacore { //# NAMESPACE CASACORE - BEGIN
37
38//# Forward Declarations
39class TableColumn;
40class Table;
41
42//# This file defines classes derived from TableExprNode representing
43//# the data type and operator in a table expression.
44//#
45//# Data types Bool, Int64, Double, DComplex and String are used.
46//# Char, uChar, Short, uShort, Int, and uInt are converted to Int64,
47//# Float to Double, and Complex to DComplex.
48//# Binary operators +, -, *, /, ==, >=, >, <, <= and != are recognized.
49//# Also &&, ||, parentheses and unary +, - and ! are recognized.
50
51
52
53// <summary>
54// Constant Bool in table select expression tree
55// </summary>
56
57// <use visibility=local>
58
59// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
60// </reviewed>
61
62// <prerequisite>
63//# Classes you should understand before using this one.
64// <li> TableExprNode
65// </prerequisite>
66
67// <synopsis>
68// This class represents a constant in a table select expression tree.
69// This is also used to hold the value of a table keyword, which is
70// constant over the entire table.
71// </synopsis>
72
74{
75public:
77 ~TableExprNodeConstBool() override = default;
78 Bool getBool (const TableExprId& id) override;
79private:
81};
82
83
84// <summary>
85// Constant Int64 in table select expression tree
86// </summary>
87
88// <use visibility=local>
89
90// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
91// </reviewed>
92
93// <prerequisite>
94//# Classes you should understand before using this one.
95// <li> TableExprNode
96// </prerequisite>
97
98// <synopsis>
99// This class represents a constant in a table select expression tree.
100// This is also used to hold the value of a table keyword, which is
101// constant over the entire table.
102// </synopsis>
103
105{
106public:
108 ~TableExprNodeConstInt() override = default;
109 Int64 getInt (const TableExprId& id) override;
110 Double getDouble (const TableExprId& id) override;
111 DComplex getDComplex (const TableExprId& id) override;
112private:
114};
115
116
117// <summary>
118// Constant Double in table select expression tree
119// </summary>
120
121// <use visibility=local>
122
123// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
124// </reviewed>
125
126// <prerequisite>
127//# Classes you should understand before using this one.
128// <li> TableExprNode
129// </prerequisite>
130
131// <synopsis>
132// This class represents a constant in a table select expression tree.
133// This is also used to hold the value of a table keyword, which is
134// constant over the entire table.
135// </synopsis>
136
138{
139public:
141 ~TableExprNodeConstDouble() override = default;
142 Double getDouble (const TableExprId& id) override;
143 DComplex getDComplex (const TableExprId& id) override;
144private:
146};
147
148
149// <summary>
150// Constant DComplex in table select expression tree
151// </summary>
152
153// <use visibility=local>
154
155// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
156// </reviewed>
157
158// <prerequisite>
159//# Classes you should understand before using this one.
160// <li> TableExprNode
161// </prerequisite>
162
163// <synopsis>
164// This class represents a constant in a table select expression tree.
165// This is also used to hold the value of a table keyword, which is
166// constant over the entire table.
167// </synopsis>
168
170{
171public:
173 ~TableExprNodeConstDComplex() override = default;
174 DComplex getDComplex (const TableExprId& id) override;
175private:
176 DComplex value_p;
177};
178
179
180// <summary>
181// Constant String in table select expression tree
182// </summary>
183
184// <use visibility=local>
185
186// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
187// </reviewed>
188
189// <prerequisite>
190//# Classes you should understand before using this one.
191// <li> TableExprNode
192// </prerequisite>
193
194// <synopsis>
195// This class represents a constant in a table select expression tree.
196// This is also used to hold the value of a table keyword, which is
197// constant over the entire table.
198// </synopsis>
199
201{
202public:
204 ~TableExprNodeConstString() override = default;
205 String getString (const TableExprId& id) override;
206private:
208};
209
210
211// <summary>
212// Constant Regex or StringDistance in table select expression tree
213// </summary>
214
215// <use visibility=local>
216
217// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
218// </reviewed>
219
220// <prerequisite>
221//# Classes you should understand before using this one.
222// <li> TableExprNode
223// </prerequisite>
224
225// <synopsis>
226// This class represents a constant in a table select expression tree.
227// This is also used to hold the value of a table keyword, which is
228// constant over the entire table.
229// </synopsis>
230
241
242
243// <summary>
244// Constant Date in table select expression tree
245// </summary>
246
247// <use visibility=local>
248
249// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
250// </reviewed>
251
252// <prerequisite>
253//# Classes you should understand before using this one.
254// <li> TableExprNode
255// </prerequisite>
256
257// <synopsis>
258// This class represents a constant in a table select expression tree.
259// This is also used to hold the value of a table keyword, which is
260// constant over the entire table.
261// </synopsis>
262
264{
265public:
267 ~TableExprNodeConstDate() override = default;
268 Double getDouble(const TableExprId& id) override;
269 MVTime getDate (const TableExprId& id) override;
270private:
272};
273
274
275
276// <summary>
277// Scalar column in table select expression tree
278// </summary>
279
280// <use visibility=local>
281
282// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
283// </reviewed>
284//
285// <prerequisite>
286//# Classes you should understand before using this one.
287// <li> TableExprNode
288// </prerequisite>
289
290// <synopsis>
291// This class represents a scalar column in a table select expression tree.
292// When the select expression gets evaluated, the value of the
293// given row in the column is used.
294// </synopsis>
295
296
298{
299public:
300 TableExprNodeColumn (const TableExprInfo&, const String& columnName);
301 ~TableExprNodeColumn() override = default;
302
303 // Get the table info for this column.
304 TableExprInfo getTableInfo() const override;
305
306 // Do not apply the selection.
307 void disableApplySelection() override;
308
309 // Re-create the column object for a selection of rows.
310 void applySelection (const Vector<rownr_t>& rownrs) override;
311
312 // Get the data type of this scalar column.
313 Bool getColumnDataType (DataType&) const override;
314
315 // Get the data for the given id.
316 Bool getBool (const TableExprId& id) override;
317 Int64 getInt (const TableExprId& id) override;
318 Double getDouble (const TableExprId& id) override;
319 DComplex getDComplex (const TableExprId& id) override;
320 String getString (const TableExprId& id) override;
321 const TableColumn& getColumn() const;
322
323 // Get the data for the given rows.
324 Array<Bool> getColumnBool (const Vector<rownr_t>& rownrs) override;
328 Array<Int> getColumnInt (const Vector<rownr_t>& rownrs) override;
329 Array<uInt> getColumnuInt (const Vector<rownr_t>& rownrs) override;
336
337 // Get the column unit (can be empty).
339
340protected:
344};
345
346
347
348// <summary>
349// Rownumber in table select expression tree
350// </summary>
351
352// <use visibility=local>
353
354// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
355// </reviewed>
356
357// <prerequisite>
358//# Classes you should understand before using this one.
359// <li> TableExprNode
360// </prerequisite>
361
362// <synopsis>
363// This class represents the rownumber() function in a table
364// select expression tree.
365// The origin is stored to indicate whether the first rownumber
366// should be zero (in C++) or another value (1 in TaQL).
367// </synopsis>
368
370{
371public:
373 ~TableExprNodeRownr() override = default;
374 TableExprInfo getTableInfo() const override;
375 Int64 getInt (const TableExprId& id) override;
376private:
379};
380
381
382
383// <summary>
384// Rowid in table select expression tree
385// </summary>
386
387// <use visibility=local>
388
389// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
390// </reviewed>
391
392// <prerequisite>
393//# Classes you should understand before using this one.
394// <li> TableExprNode
395// </prerequisite>
396
397// <synopsis>
398// This class represents the rowid() function in a table
399// select expression tree.
400// It is meant to get the original row number in a GIVING clause,
401// but, of course, it can also be used in the SELECT clause.
402// The row number returned is 0-based.
403// </synopsis>
404
406{
407public:
409 ~TableExprNodeRowid() override = default;
410 TableExprInfo getTableInfo() const override;
411 void applySelection (const Vector<rownr_t>& rownrs) override;
412 Int64 getInt (const TableExprId& id) override;
413private:
416};
417
418
419
420// <summary>
421// Random number in table select expression tree
422// </summary>
423
424// <use visibility=local>
425
426// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
427// </reviewed>
428
429// <prerequisite>
430//# Classes you should understand before using this one.
431// <li> TableExprNode
432// </prerequisite>
433
434// <synopsis>
435// This class represents the rand() function in a table
436// select expression tree.
437// </synopsis>
438
451
452
453
454} //# NAMESPACE CASACORE - END
455
456#endif
Multiplicative linear congruential generator.
Definition Random.h:304
String: the storage and methods of handling collections of characters.
Definition String.h:223
Class to connect a Table and its alias name.
Abstract base class for a node having 0, 1, or 2 child nodes.
Scalar column in table select expression tree.
Array< Float > getColumnFloat(const Vector< rownr_t > &rownrs) override
Array< DComplex > getColumnDComplex(const Vector< rownr_t > &rownrs) override
Array< String > getColumnString(const Vector< rownr_t > &rownrs) override
Double getDouble(const TableExprId &id) override
Array< uInt > getColumnuInt(const Vector< rownr_t > &rownrs) override
void disableApplySelection() override
Do not apply the selection.
static Unit getColumnUnit(const TableColumn &)
Get the column unit (can be empty).
const TableColumn & getColumn() const
~TableExprNodeColumn() override=default
Array< Double > getColumnDouble(const Vector< rownr_t > &rownrs) override
Array< Bool > getColumnBool(const Vector< rownr_t > &rownrs) override
Get the data for the given rows.
Array< Int > getColumnInt(const Vector< rownr_t > &rownrs) override
TableExprInfo getTableInfo() const override
Get the table info for this column.
Bool getColumnDataType(DataType &) const override
Get the data type of this scalar column.
Array< Complex > getColumnComplex(const Vector< rownr_t > &rownrs) override
Int64 getInt(const TableExprId &id) override
String getString(const TableExprId &id) override
Array< uShort > getColumnuShort(const Vector< rownr_t > &rownrs) override
Array< Int64 > getColumnInt64(const Vector< rownr_t > &rownrs) override
Bool getBool(const TableExprId &id) override
Get the data for the given id.
TableExprNodeColumn(const TableExprInfo &, const String &columnName)
void applySelection(const Vector< rownr_t > &rownrs) override
Re-create the column object for a selection of rows.
DComplex getDComplex(const TableExprId &id) override
Array< Short > getColumnShort(const Vector< rownr_t > &rownrs) override
Array< uChar > getColumnuChar(const Vector< rownr_t > &rownrs) override
Bool getBool(const TableExprId &id) override
Get a scalar value for this node in the given row.
TableExprNodeConstBool(const Bool &value)
~TableExprNodeConstBool() override=default
Constant DComplex in table select expression tree.
TableExprNodeConstDComplex(const DComplex &value)
~TableExprNodeConstDComplex() override=default
DComplex getDComplex(const TableExprId &id) override
Constant Date in table select expression tree.
MVTime getDate(const TableExprId &id) override
TableExprNodeConstDate(const MVTime &value)
Double getDouble(const TableExprId &id) override
~TableExprNodeConstDate() override=default
Constant Double in table select expression tree.
DComplex getDComplex(const TableExprId &id) override
~TableExprNodeConstDouble() override=default
Double getDouble(const TableExprId &id) override
TableExprNodeConstDouble(const Double &value)
Constant Int64 in table select expression tree.
DComplex getDComplex(const TableExprId &id) override
Double getDouble(const TableExprId &id) override
TableExprNodeConstInt(const Int64 &value)
~TableExprNodeConstInt() override=default
Int64 getInt(const TableExprId &id) override
Constant Regex or StringDistance in table select expression tree.
~TableExprNodeConstRegex() override=default
TableExprNodeConstRegex(const TaqlRegex &value)
TaqlRegex getRegex(const TableExprId &id) override
Constant String in table select expression tree.
~TableExprNodeConstString() override=default
TableExprNodeConstString(const String &value)
String getString(const TableExprId &id) override
Random number in table select expression tree.
TableExprInfo getTableInfo() const override
Get the table info.
TableExprNodeRandom(const TableExprInfo &)
~TableExprNodeRandom() override=default
Double getDouble(const TableExprId &id) override
Rowid in table select expression tree.
TableExprInfo getTableInfo() const override
Get the table info.
void applySelection(const Vector< rownr_t > &rownrs) override
Re-create the column object for a selection of rows.
~TableExprNodeRowid() override=default
Int64 getInt(const TableExprId &id) override
TableExprNodeRowid(const TableExprInfo &)
Vector< rownr_t > rownrs_p
Rownumber in table select expression tree.
~TableExprNodeRownr() override=default
TableExprNodeRownr(const TableExprInfo &, uInt origin)
Int64 getInt(const TableExprId &id) override
TableExprInfo getTableInfo() const override
Get the table info.
Uniform distribution.
Definition Random.h:1271
this file contains all the compiler specific defines
Definition mainpage.dox:28
unsigned int uInt
Definition aipstype.h:49
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
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.
double Double
Definition aipstype.h:53