casacore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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: aips2-request@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 //# $Id: ExprDerNode.h 21521 2014-12-10 08:06:42Z gervandiepen $
27 
28 #ifndef TABLES_EXPRDERNODE_H
29 #define TABLES_EXPRDERNODE_H
30 
31 //# Includes
32 #include <casacore/casa/aips.h>
37 
38 namespace casacore { //# NAMESPACE CASACORE - BEGIN
39 
40 //# Forward Declarations
41 class TableColumn;
42 class Table;
43 
44 //# This file defines classes derived from TableExprNode representing
45 //# the data type and operator in a table expression.
46 //#
47 //# Data types Bool, Int64, Double, DComplex and String are used.
48 //# Char, uChar, Short, uShort, Int, and uInt are converted to Int64,
49 //# Float to Double, and Complex to DComplex.
50 //# Binary operators +, -, *, /, ==, >=, >, <, <= and != are recognized.
51 //# Also &&, ||, parentheses and unary +, - and ! are recognized.
52 
53 
54 
55 // <summary>
56 // Constant Bool in table select expression tree
57 // </summary>
58 
59 // <use visibility=local>
60 
61 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
62 // </reviewed>
63 
64 // <prerequisite>
65 //# Classes you should understand before using this one.
66 // <li> TableExprNode
67 // </prerequisite>
68 
69 // <synopsis>
70 // This class represents a constant in a table select expression tree.
71 // This is also used to hold the value of a table keyword, which is
72 // constant over the entire table.
73 // </synopsis>
74 
76 {
77 public:
80  Bool getBool (const TableExprId& id);
81 private:
83 };
84 
85 
86 // <summary>
87 // Constant Int64 in table select expression tree
88 // </summary>
89 
90 // <use visibility=local>
91 
92 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
93 // </reviewed>
94 
95 // <prerequisite>
96 //# Classes you should understand before using this one.
97 // <li> TableExprNode
98 // </prerequisite>
99 
100 // <synopsis>
101 // This class represents a constant in a table select expression tree.
102 // This is also used to hold the value of a table keyword, which is
103 // constant over the entire table.
104 // </synopsis>
105 
107 {
108 public:
111  Int64 getInt (const TableExprId& id);
112  Double getDouble (const TableExprId& id);
113  DComplex getDComplex (const TableExprId& id);
114 private:
116 };
117 
118 
119 // <summary>
120 // Constant Double in table select expression tree
121 // </summary>
122 
123 // <use visibility=local>
124 
125 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
126 // </reviewed>
127 
128 // <prerequisite>
129 //# Classes you should understand before using this one.
130 // <li> TableExprNode
131 // </prerequisite>
132 
133 // <synopsis>
134 // This class represents a constant in a table select expression tree.
135 // This is also used to hold the value of a table keyword, which is
136 // constant over the entire table.
137 // </synopsis>
138 
140 {
141 public:
144  Double getDouble (const TableExprId& id);
145  DComplex getDComplex (const TableExprId& id);
146 private:
148 };
149 
150 
151 // <summary>
152 // Constant DComplex in table select expression tree
153 // </summary>
154 
155 // <use visibility=local>
156 
157 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
158 // </reviewed>
159 
160 // <prerequisite>
161 //# Classes you should understand before using this one.
162 // <li> TableExprNode
163 // </prerequisite>
164 
165 // <synopsis>
166 // This class represents a constant in a table select expression tree.
167 // This is also used to hold the value of a table keyword, which is
168 // constant over the entire table.
169 // </synopsis>
170 
172 {
173 public:
176  DComplex getDComplex (const TableExprId& id);
177 private:
179 };
180 
181 
182 // <summary>
183 // Constant String in table select expression tree
184 // </summary>
185 
186 // <use visibility=local>
187 
188 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
189 // </reviewed>
190 
191 // <prerequisite>
192 //# Classes you should understand before using this one.
193 // <li> TableExprNode
194 // </prerequisite>
195 
196 // <synopsis>
197 // This class represents a constant in a table select expression tree.
198 // This is also used to hold the value of a table keyword, which is
199 // constant over the entire table.
200 // </synopsis>
201 
203 {
204 public:
207  String getString (const TableExprId& id);
208 private:
210 };
211 
212 
213 // <summary>
214 // Constant Regex or StringDistance in table select expression tree
215 // </summary>
216 
217 // <use visibility=local>
218 
219 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
220 // </reviewed>
221 
222 // <prerequisite>
223 //# Classes you should understand before using this one.
224 // <li> TableExprNode
225 // </prerequisite>
226 
227 // <synopsis>
228 // This class represents a constant in a table select expression tree.
229 // This is also used to hold the value of a table keyword, which is
230 // constant over the entire table.
231 // </synopsis>
232 
234 {
235 public:
238  TaqlRegex getRegex (const TableExprId& id);
239 private:
242 };
243 
244 
245 // <summary>
246 // Constant Date in table select expression tree
247 // </summary>
248 
249 // <use visibility=local>
250 
251 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
252 // </reviewed>
253 
254 // <prerequisite>
255 //# Classes you should understand before using this one.
256 // <li> TableExprNode
257 // </prerequisite>
258 
259 // <synopsis>
260 // This class represents a constant in a table select expression tree.
261 // This is also used to hold the value of a table keyword, which is
262 // constant over the entire table.
263 // </synopsis>
264 
266 {
267 public:
270  Double getDouble(const TableExprId& id);
271  MVTime getDate (const TableExprId& id);
272 private:
274 };
275 
276 
277 
278 // <summary>
279 // Scalar column in table select expression tree
280 // </summary>
281 
282 // <use visibility=local>
283 
284 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
285 // </reviewed>
286 //
287 // <prerequisite>
288 //# Classes you should understand before using this one.
289 // <li> TableExprNode
290 // </prerequisite>
291 
292 // <synopsis>
293 // This class represents a scalar column in a table select expression tree.
294 // When the select expression gets evaluated, the value of the
295 // given row in the column is used.
296 // </synopsis>
297 
298 
300 {
301 public:
302  TableExprNodeColumn (const Table&, const String& columnName);
304 
305  // This node represents a table column.
306  virtual void getColumnNodes (std::vector<TableExprNodeRep*>& cols);
307 
308  // Do not apply the selection.
309  virtual void disableApplySelection();
310 
311  // Re-create the column object for a selection of rows.
312  virtual void applySelection (const Vector<rownr_t>& rownrs);
313 
314  // Get the data type of this scalar column.
315  Bool getColumnDataType (DataType&) const;
316 
317  // Get the data for the given id.
318  Bool getBool (const TableExprId& id);
319  Int64 getInt (const TableExprId& id);
320  Double getDouble (const TableExprId& id);
321  DComplex getDComplex (const TableExprId& id);
322  String getString (const TableExprId& id);
323  const TableColumn& getColumn() const;
324 
325  // Get the data for the given rows.
326  Array<Bool> getColumnBool (const Vector<rownr_t>& rownrs);
330  Array<Int> getColumnInt (const Vector<rownr_t>& rownrs);
331  Array<uInt> getColumnuInt (const Vector<rownr_t>& rownrs);
338 
339  // Get the column unit (can be empty).
340  static Unit getColumnUnit (const TableColumn&);
341 
342 protected:
346 };
347 
348 
349 
350 // <summary>
351 // Rownumber in table select expression tree
352 // </summary>
353 
354 // <use visibility=local>
355 
356 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
357 // </reviewed>
358 
359 // <prerequisite>
360 //# Classes you should understand before using this one.
361 // <li> TableExprNode
362 // </prerequisite>
363 
364 // <synopsis>
365 // This class represents the rownumber() function in a table
366 // select expression tree.
367 // The origin is stored to indicate whether the first rownumber
368 // should be zero (in C++) or another value (1 in TaQL).
369 // </synopsis>
370 
372 {
373 public:
374  TableExprNodeRownr (const Table&, uInt origin);
376  Int64 getInt (const TableExprId& id);
377 private:
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 {
407 public:
408  TableExprNodeRowid (const Table&);
410  virtual void applySelection (const Vector<rownr_t>& rownrs);
411  Int64 getInt (const TableExprId& id);
412 private:
414 };
415 
416 
417 
418 // <summary>
419 // Random number in table select expression tree
420 // </summary>
421 
422 // <use visibility=local>
423 
424 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
425 // </reviewed>
426 
427 // <prerequisite>
428 //# Classes you should understand before using this one.
429 // <li> TableExprNode
430 // </prerequisite>
431 
432 // <synopsis>
433 // This class represents the rand() function in a table
434 // select expression tree.
435 // </synopsis>
436 
438 {
439 public:
440  TableExprNodeRandom (const Table&);
442  Double getDouble (const TableExprId& id);
443 private:
446 };
447 
448 
449 
450 } //# NAMESPACE CASACORE - END
451 
452 #endif
Array< uChar > getColumnuChar(const Vector< rownr_t > &rownrs)
Double getDouble(const TableExprId &id)
long long Int64
Define the extra non-standard types used by Casacore (like proposed uSize, Size)
Definition: aipsxtype.h:38
Array< uShort > getColumnuShort(const Vector< rownr_t > &rownrs)
Uniform distribution.
Definition: Random.h:1273
Vector< rownr_t > rownrs_p
Definition: ExprDerNode.h:413
Double getDouble(const TableExprId &id)
Double getDouble(const TableExprId &id)
Main interface class to a read/write table.
Definition: Table.h:157
TaqlRegex getRegex(const TableExprId &id)
TableExprNodeConstRegex(const TaqlRegex &value)
Constant String in table select expression tree.
Definition: ExprDerNode.h:202
Double getDouble(const TableExprId &id)
Array< Short > getColumnShort(const Vector< rownr_t > &rownrs)
Constant Double in table select expression tree.
Definition: ExprDerNode.h:139
Int64 getInt(const TableExprId &id)
Scalar column in table select expression tree.
Definition: ExprDerNode.h:299
virtual void applySelection(const Vector< rownr_t > &rownrs)
Re-create the column object for a selection of rows.
TableExprNodeColumn(const Table &, const String &columnName)
TableExprNodeRownr(const Table &, uInt origin)
virtual void disableApplySelection()
Do not apply the selection.
DComplex getDComplex(const TableExprId &id)
Array< Complex > getColumnComplex(const Vector< rownr_t > &rownrs)
Int64 getInt(const TableExprId &id)
Bool getBool(const TableExprId &id)
Get a scalar value for this node in the given row.
TableExprNodeConstInt(const Int64 &value)
defines physical units
Definition: Unit.h:189
MVTime getDate(const TableExprId &id)
DComplex getDComplex(const TableExprId &id)
String getString(const TableExprId &id)
Bool getColumnDataType(DataType &) const
Get the data type of this scalar column.
TableExprNodeConstDComplex(const DComplex &value)
Array< Int > getColumnInt(const Vector< rownr_t > &rownrs)
double Double
Definition: aipstype.h:55
TableExprNodeConstDouble(const Double &value)
DComplex getDComplex(const TableExprId &id)
virtual void getColumnNodes(std::vector< TableExprNodeRep * > &cols)
This node represents a table column.
static Unit getColumnUnit(const TableColumn &)
Get the column unit (can be empty).
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
Int64 getInt(const TableExprId &id)
Read/write access to a table column.
Definition: TableColumn.h:98
Array< Bool > getColumnBool(const Vector< rownr_t > &rownrs)
Get the data for the given rows.
Array< uInt > getColumnuInt(const Vector< rownr_t > &rownrs)
DComplex getDComplex(const TableExprId &id)
TableExprNodeConstDate(const MVTime &value)
Constant Date in table select expression tree.
Definition: ExprDerNode.h:265
Constant DComplex in table select expression tree.
Definition: ExprDerNode.h:171
The identification of a TaQL selection subject.
Definition: TableExprId.h:97
Bool getBool(const TableExprId &id)
Get the data for the given id.
TableExprNodeConstBool(const Bool &value)
Constant Regex or StringDistance in table select expression tree.
Definition: ExprDerNode.h:233
Array< DComplex > getColumnDComplex(const Vector< rownr_t > &rownrs)
Int64 getInt(const TableExprId &id)
Array< Float > getColumnFloat(const Vector< rownr_t > &rownrs)
const TableColumn & getColumn() const
Class to handle a Regex or StringDistance.
Definition: ExprNodeRep.h:81
TableExprNodeRowid(const Table &)
Multiplicative linear congruential generator.
Definition: Random.h:306
virtual void applySelection(const Vector< rownr_t > &rownrs)
Re-create the column object for a selection of rows.
TableExprNodeRandom(const Table &)
String: the storage and methods of handling collections of characters.
Definition: String.h:225
Array< Int64 > getColumnInt64(const Vector< rownr_t > &rownrs)
Class to deal with Levensthein distance of strings.
Random number in table select expression tree.
Definition: ExprDerNode.h:437
TableExprNodeConstString(const String &value)
Class to handle date/time type conversions and I/O.
Definition: MVTime.h:270
Constant Int64 in table select expression tree.
Definition: ExprDerNode.h:106
Abstract base class for a node having 0, 1, or 2 child nodes.
Definition: ExprNodeRep.h:558
Double getDouble(const TableExprId &id)
Rowid in table select expression tree.
Definition: ExprDerNode.h:405
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.
String getString(const TableExprId &id)
unsigned int uInt
Definition: aipstype.h:51
Array< String > getColumnString(const Vector< rownr_t > &rownrs)
Array< Double > getColumnDouble(const Vector< rownr_t > &rownrs)
Constant Bool in table select expression tree.
Definition: ExprDerNode.h:75
Rownumber in table select expression tree.
Definition: ExprDerNode.h:371